logmon.log(BasicLevel.DEBUG, "DBTransaction, commit"); Hashtable log = ((Context) perThreadContext.get()).getLog(); if (! log.isEmpty()) { DBOperation op = null;
logmon.log(BasicLevel.DEBUG, "DBTransaction, commit"); Hashtable<String, DBOperation> log = perThreadContext.get().getLog(); if (! log.isEmpty()) { DBOperation op = null;
Hashtable log = ((Context) perThreadContext.get()).getLog(); if (! log.isEmpty()) { Operation op = null;
Hashtable<Object, Operation> log = perThreadContext.get().getLog(); if (! log.isEmpty()) { Operation op = null;
public byte[] loadByteArray(String dirName, String name) throws IOException { String fname = fname(dirName, name); if (logmon.isLoggable(BasicLevel.DEBUG)) logmon.log(BasicLevel.DEBUG, "DBTransaction, loadByteArray(" + fname + ")"); // Searchs in the log a new value for the object. Hashtable log = ((Context) perThreadContext.get()).getLog(); DBOperation op = (DBOperation) log.get(fname); if (op != null) { if (op.type == DBOperation.SAVE) { return op.value; } else if (op.type == DBOperation.DELETE) { // The object was deleted. return null; } } try { // Creating a statement lets us issue commands against the connection. Statement s = conn.createStatement(); // ResultSet rs = s.executeQuery("SELECT content FROM JoramDB WHERE name='" + name + "'"); if (!rs.next()) return null; byte[] content = rs.getBytes(1); rs.close(); s.close(); return content; } catch (SQLException sqle) { throw new IOException(sqle.getMessage()); } }
public byte[] loadByteArray(String dirName, String name) throws IOException { String fname = fname(dirName, name); if (logmon.isLoggable(BasicLevel.DEBUG)) logmon.log(BasicLevel.DEBUG, "DBTransaction, loadByteArray(" + fname + ")"); // Searchs in the log a new value for the object. Hashtable<String, DBOperation> log = perThreadContext.get().getLog(); DBOperation op = log.get(fname); if (op != null) { if (op.type == DBOperation.SAVE) { return op.value; } else if (op.type == DBOperation.DELETE) { // The object was deleted. return null; } } try { // Creating a statement lets us issue commands against the connection. Statement s = conn.createStatement(); // ResultSet rs = s.executeQuery("SELECT content FROM " + dbtable + " WHERE name='" + name + "'"); if (!rs.next()) return null; byte[] content = rs.getBytes(1); rs.close(); s.close(); return content; } catch (SQLException sqle) { throw new IOException(sqle.getMessage()); } }
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"); // TODO (AF): Only the call to logManager.commit and the phase change needs to // be synchronized.. Hashtable log = ((Context) perThreadContext.get()).getLog(); if (! log.isEmpty()) { logManager.commit(log); log.clear(); } // Change the transaction state to COMMIT or FREE if (release) { setPhase(FREE); // wake-up an eventually user's thread in begin notify(); } else { setPhase(COMMIT); } if (logmon.isLoggable(BasicLevel.DEBUG)) logmon.log(BasicLevel.DEBUG, "NTransaction, committed"); }
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"); // TODO (AF): Only the call to logManager.commit and the phase change needs to // be synchronized.. Hashtable<Object, Operation> log = perThreadContext.get().getLog(); if (! log.isEmpty()) { logManager.commit(log); log.clear(); } // Change the transaction state to COMMIT or FREE if (release) { setPhase(FREE); // wake-up an eventually user's thread in begin notify(); } else { setPhase(COMMIT); } if (logmon.isLoggable(BasicLevel.DEBUG)) logmon.log(BasicLevel.DEBUG, "NTransaction, committed"); }
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(); } }
protected synchronized Object initialValue() { return new Context(); } };
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(); } }
/** * Indicates whether some operations have been done in * this transaction. */ public boolean containsOperations() { return (perThreadContext.get().getLog().size() > 0); }
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(); }
protected synchronized Context initialValue() { return new Context(); } };
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(); }