@Override
	public WriteMsg write(long txnID, long msgSeqNum, FileContent data)
			throws RemoteException, IOException {
		String fileName = data.getFileName();
		// if this is the first message, we obtain a lock on file first
		if (msgSeqNum == 1) {
			Semaphore lock = null;
			if (!fileLock.containsKey(fileName)) {
				lock = new Semaphore(1);
				fileLock.put(fileName, lock);
			} else {
				lock = fileLock.get(fileName);
			}
			try {
				lock.acquire();
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
			fileNameTransaction.put(txnID, fileName);
			cache.put(fileName, data);
		} else {
			cache.get(fileName).appendData(data.getData());
		}
		return null;
	}