public String read(String transaction, String resource, boolean isReadOnly) {
        if (isReadOnly) {
            if (!snapshot.containsKey(transaction)) {
                throw new IllegalArgumentException(
                        "A read transaction which has no snapshot");
            }
            if (!snapshot.get(transaction).containsKey(resource)) {
                throw new IllegalArgumentException(
                        "snapshot doesn't contains resource: " + resource
                                + "for transaction: " + transaction);
            }
            return snapshot.get(transaction).get(resource);
        } else {
            // check if resource is in a write log
            if (this.writeLog.containsKey(transaction)) {
                if (writeLog.get(transaction).containsKey(resource)) {
                    // Add to read log
                    if (readLog.containsKey(transaction)) {
                        readLog.get(transaction).add(resource);
                    } else {
                        HashSet<String> tmpSet = new HashSet<String>();
                        tmpSet.add(resource);
                        readLog.put(transaction, tmpSet);
                    }
                    return writeLog.get(transaction).get(resource);
                }
            }
            // read from database directly
            if (this.data.get(resource) == null) {
                System.out.println(resource);
                throw new RuntimeException("no requested resource in this site");
            }
            // Add to read log
            if (readLog.containsKey(transaction)) {
                readLog.get(transaction).add(resource);
            } else {
                HashSet<String> tmpSet = new HashSet<String>();
                tmpSet.add(resource);
                readLog.put(transaction, tmpSet);
            }
            return this.data.get(resource);
        }
    }