/** * Returns the number of operations to be committed. * @return the number of operations to be committed. */ public int getOperationCount() { return perThreadContext.get().getLog().size(); }
/** * Indicates whether some operations have been done in * this transaction. */ public boolean containsOperations() { return (perThreadContext.get().getLog().size() > 0); }
public final synchronized void rollback() { if (phase != RUN) throw new IllegalStateException("Can not rollback."); if (logmon.isLoggable(BasicLevel.DEBUG)) logmon.log(BasicLevel.DEBUG, "ATransaction, rollback"); setPhase(ROLLBACK); perThreadContext.get().getLog().clear(); }
public final synchronized void commit(boolean release) throws IOException { if (phase != RUN) throw new IllegalStateException("Can not commit."); if (logmon.isLoggable(BasicLevel.DEBUG)) logmon.log(BasicLevel.DEBUG, "NTransaction, commit(" + release + ')'); Hashtable<Object, Operation> log = perThreadContext.get().getLog(); if (! log.isEmpty()) { logFile.commit(log); log.clear(); } setPhase(COMMIT); if (logmon.isLoggable(BasicLevel.DEBUG)) logmon.log(BasicLevel.DEBUG, "NTransaction, committed"); if (release) { setPhase(FREE); // wake-up an eventually user's thread in begin notify(); } }
public final synchronized void commit(boolean release) throws IOException { if (phase != RUN) throw new IllegalStateException("Can not commit."); if (logmon.isLoggable(BasicLevel.DEBUG)) logmon.log(BasicLevel.DEBUG, "NTransaction, commit(" + release + ')'); Hashtable log = ((Context) perThreadContext.get()).getLog(); if (! log.isEmpty()) { logFile.commit(log); log.clear(); } setPhase(COMMIT); if (logmon.isLoggable(BasicLevel.DEBUG)) logmon.log(BasicLevel.DEBUG, "NTransaction, committed"); if (release) { setPhase(FREE); // wake-up an eventually user's thread in begin notify(); } }
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(); } }
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<Object, Operation> log = perThreadContext.get().getLog(); Operation op = Operation.alloc(Operation.DELETE, dirName, name); Operation old = log.put(key, op); if (old != null) { if (old.type == Operation.CREATE) op.type = Operation.NOOP; old.free(); } }
public void delete(String dirName, String name) { String fname = fname(dirName, name); if (logmon.isLoggable(BasicLevel.DEBUG)) logmon.log(BasicLevel.DEBUG, "DBTransaction, delete(" + fname + ")"); Hashtable<String, DBOperation> log = perThreadContext.get().getLog(); DBOperation op = DBOperation.alloc(DBOperation.DELETE, fname); op = log.put(fname, op); if (op != null) op.free(); }
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<Object, Operation> log = perThreadContext.get().getLog(); Operation op = Operation.alloc(Operation.DELETE, dirName, name); Operation old = 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 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; }
public final synchronized void rollback() { if (phase != RUN) throw new IllegalStateException("Can not rollback."); if (logmon.isLoggable(BasicLevel.DEBUG)) logmon.log(BasicLevel.DEBUG, "ATransaction, rollback"); setPhase(ROLLBACK); ((Context) perThreadContext.get()).getLog().clear(); }
public void delete(String dirName, String name) { String fname = fname(dirName, name); if (logmon.isLoggable(BasicLevel.DEBUG)) logmon.log(BasicLevel.DEBUG, "DBTransaction, delete(" + fname + ")"); Hashtable log = ((Context) perThreadContext.get()).getLog(); DBOperation op = DBOperation.alloc(DBOperation.DELETE, fname); op = (DBOperation) log.put(fname, op); if (op != null) op.free(); }
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); }
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(); }
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) { 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(); }
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 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 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; }