/** * Creates a new key for the specified object. * * @param dirName relative path of the object. * @param name name of the object. * @return A new key for the specified object. */ public static Object newKey(String dirName, String name) { if (dirName == null) return name; return new OperationKey(dirName, name); }
public byte[] getFromLog(String dirName, String name) throws IOException { // First searches in the logs a new value for the object. Operation op = log.get(OperationKey.newKey(dirName, name)); if (op != null) { if ((op.type == Operation.SAVE) || (op.type == Operation.CREATE)) { // reads the value from the log file return getFromLog(op); } else if (op.type == Operation.DELETE) { // The object was deleted. throw new FileNotFoundException(); } } return null; }
public byte[] getFromLog(String dirName, String name) throws IOException { // First searches in the logs a new value for the object. Operation op = log.get(OperationKey.newKey(dirName, name)); if (op != null) { if ((op.type == Operation.SAVE) || (op.type == Operation.CREATE)) { // reads the value from the log file return getFromLog(op); } else if (op.type == Operation.DELETE) { // The object was deleted. throw new FileNotFoundException(); } } return null; }
/** * Creates a new key for the specified object. * * @param dirName relative path of the object. * @param name name of the object. * @return A new key for the specified object. */ public static Object newKey(String dirName, String name) { if (dirName == null) return name; return new OperationKey(dirName, name); }
public void delete(String dirName, String name) { if (phase == RUN) { // We are during a transaction mark the object deleted in the log. Object key = OperationKey.newKey(dirName, name); log.put(key, Operation.alloc(Operation.DELETE, dirName, name)); } else { File file; if (dirName == null) { file = new File(dir, name); file.delete(); } else { File parentDir = new File(dir, dirName); file = new File(parentDir, name); file.delete(); deleteDir(parentDir); } } }
public void delete(String dirName, String name) { if (phase == RUN) { // We are during a transaction mark the object deleted in the log. Object key = OperationKey.newKey(dirName, name); log.put(key, Operation.alloc(Operation.DELETE, dirName, name)); } else { File file; if (dirName == null) { file = new File(dir, name); file.delete(); } else { File parentDir = new File(dir, dirName); file = new File(parentDir, name); file.delete(); deleteDir(parentDir); } } }
public byte[] loadByteArray(String dirName, String name) throws IOException { if (phase == RUN) { Object key = OperationKey.newKey(dirName, name); Operation op = (Operation) log.get(key); if (op != null) {
public byte[] loadByteArray(String dirName, String name) throws IOException { if (phase == RUN) { Object key = OperationKey.newKey(dirName, name); Operation op = (Operation) log.get(key); if (op != null) {
public void saveByteArray(byte[] buf, String dirName, String name, boolean copy, boolean first) throws IOException { if (phase == RUN) { // We are during a transaction put the new state in the log. Object key = OperationKey.newKey(dirName, name); log.put(key, Operation.alloc(Operation.SAVE, dirName, name, buf)); } else { // Save the new state on the disk. File file; if (dirName == null) { file = new File(dir, name); } else { File parentDir = new File(dir, dirName); if (!parentDir.exists()) { parentDir.mkdirs(); } file = new File(parentDir, name); } FileOutputStream fos = new FileOutputStream(file); fos.write(buf); fos.close(); } }
public void saveByteArray(byte[] buf, String dirName, String name, boolean copy, boolean first) throws IOException { if (phase == RUN) { // We are during a transaction put the new state in the log. Object key = OperationKey.newKey(dirName, name); log.put(key, Operation.alloc(Operation.SAVE, dirName, name, buf)); } else { // Save the new state on the disk. File file; if (dirName == null) { file = new File(dir, name); } else { File parentDir = new File(dir, dirName); if (!parentDir.exists()) { parentDir.mkdirs(); } file = new File(parentDir, name); } FileOutputStream fos = new FileOutputStream(file); fos.write(buf); fos.close(); } }
public final void delete(String dirName, String name) { Object key = OperationKey.newKey(dirName, name); Hashtable log = ((Context) perThreadContext.get()).getLog(); Operation op = Operation.alloc(Operation.DELETE, dirName, name); op = (Operation) log.put(key, op); if (op != null) op.free(); }
public final void delete(String dirName, String name) { Object key = OperationKey.newKey(dirName, name); Hashtable<Object, Operation> log = perThreadContext.get().getLog(); Operation op = Operation.alloc(Operation.DELETE, dirName, name); op = log.put(key, op); if (op != null) op.free(); }
private final byte[] getFromLog(String dirName, String name) throws IOException { // First searches in the logs a new value for the object. Object key = OperationKey.newKey(dirName, name); byte[] buf = getFromLog(perThreadContext.get().getLog(), key); if (buf != null) return buf; if ((buf = getFromLog(logFile.log, key)) != null) { return buf; } return null; }
private final synchronized byte[] getFromLog(String dirName, String name) throws IOException { // First searches in the current transaction log a new value for the object. Object key = OperationKey.newKey(dirName, name); byte[] buf = getFromLog(((Context) perThreadContext.get()).getLog(), key); if (buf != null) return buf; // Then search in the log files and repository. return logManager.load(dirName, name); }
private final synchronized byte[] getFromLog(String dirName, String name) throws IOException { // First searches in the current transaction log a new value for the object. Object key = OperationKey.newKey(dirName, name); byte[] buf = getFromLog(perThreadContext.get().getLog(), key); if (buf != null) return buf; // Then search in the log files and repository. return logManager.load(dirName, name); }
private final byte[] getFromLog(String dirName, String name) throws IOException { // First searches in the logs a new value for the object. Object key = OperationKey.newKey(dirName, name); byte[] buf = getFromLog(((Context) perThreadContext.get()).getLog(), key); if (buf != null) return buf; if ((buf = getFromLog(logFile.log, key)) != null) { return buf; } return null; }
private final byte[] getFromLog(String dirName, String name) throws IOException { // First searchs in the logs a new value for the object. Object key = OperationKey.newKey(dirName, name); byte[] buf = getFromLog(((Context) perThreadContext.get()).getLog(), key); if (buf != null) return buf; if (((buf = getFromLog(clog, key)) != null) || ((buf = getFromLog(plog, key)) != null)) { return buf; } return null; }
public final void delete(String dirName, String name) { if (logmon.isLoggable(BasicLevel.DEBUG)) logmon.log(BasicLevel.DEBUG, "NTransaction, delete(" + dirName + ", " + name + ")"); Object key = OperationKey.newKey(dirName, name); Hashtable log = ((Context) perThreadContext.get()).getLog(); Operation op = Operation.alloc(Operation.DELETE, dirName, name); Operation old = (Operation) log.put(key, op); if (old != null) { if (old.type == Operation.CREATE) op.type = Operation.NOOP; old.free(); } }
private final byte[] getFromLog(String dirName, String name) throws IOException { // First searchs in the logs a new value for the object. Object key = OperationKey.newKey(dirName, name); byte[] buf = getFromLog(perThreadContext.get().getLog(), key); if (buf != null) return buf; if (((buf = getFromLog(clog, key)) != null) || ((buf = getFromLog(plog, key)) != null)) { return buf; } return null; }
public final void delete(String dirName, String name) { if (logmon.isLoggable(BasicLevel.DEBUG)) logmon.log(BasicLevel.DEBUG, "NTransaction, delete(" + dirName + ", " + name + ")"); Object key = OperationKey.newKey(dirName, name); Hashtable log = ((Context) perThreadContext.get()).getLog(); Operation op = Operation.alloc(Operation.DELETE, dirName, name); Operation old = (Operation) log.put(key, op); if (old != null) { if (old.type == Operation.CREATE) op.type = Operation.NOOP; old.free(); } }