public void write(String transactionName, String variableName, 
      int value, long timestamp) {
    Transaction transaction = transactionMap.get(transactionName);
    if( transaction != null && transaction.getType() 
        == Transaction.Type.READ_WRITE) {
      Lock lock = lockManager
          .acquireWrite(transaction, variableName);
      Status lockStatus = lock.getStatus();
      if( lockStatus == Status.ACCEPT ) {
        if( transaction.write(variableName, value, timestamp) ) {
          String output = new StringBuilder("Read/Write Transaction ")
              .append(transactionName).append(" writing variable ")
                  .append(variableName).append(" = ").append(value)
                      .toString();
          writeToStreamln(output);
        }
        else {
          String output = new StringBuilder("Read/Write Transaction ")
              .append(transactionName).append(" unable to write variable ")
                  .append(variableName).append(" because all sites are down ")
                      .toString();
          writeToStreamln(output);
          output = new StringBuilder("Transaction ")
              .append(transactionName).append(" aborted").toString(); 
          writeToStreamln(output);
          abort(transaction, timestamp);
        }
      }
      else if( lockStatus == Status.BLOCK ) {
        LinkedHashMap<Transaction, Lock> transactionLockMap 
            = blockedTransactions.get(variableName);
        if( transactionLockMap == null ) {
          transactionLockMap = new LinkedHashMap<Transaction, Lock>();
          blockedTransactions.put(variableName, transactionLockMap);
        }
        
        if( transactionLockMap.containsKey(transaction)) {
          writeToStreamln("Blocked transaction can be blocked"
              + "on just one operation");
          return;
        }
        for (Transaction trans : transactionLockMap.keySet()) {
        	if (trans.getTimestamp() < transaction.getTimestamp()) {
        		String output = new StringBuilder("Read/Write Transaction ")
                	.append(transactionName).append(" aborted by wait-die.").toString();
        		writeToStreamln(output);
        		abort(transaction, timestamp);
        		return;
        	}
        }
        lock.setWriteOperation(new WriteOperation(variableName, value));
        transactionLockMap.put(transaction, lock);
        String output = new StringBuilder("Read/Write Transaction ")
            .append(transactionName).append(" blocked.").toString();
        writeToStreamln(output);
      }
      else {
        String output = new StringBuilder("Read/Write Transaction ")
          .append(transactionName).append(" aborted by wait-die.").toString();
        writeToStreamln(output);
        abort(transaction, timestamp);
      }
    }
  }