public final void delete(String name) { delete(null, name); }
public final Object load(String name) throws IOException, ClassNotFoundException { return load(null, name); }
public final byte[] loadByteArray(String name) throws IOException { return loadByteArray(null, name); }
loadProperties(dir); LogThresholdOperation = getInteger("LogThresholdOperation", LogThresholdOperation).intValue(); Operation.initPool(LogThresholdOperation); saveProperties(dir); _commit(); setPhase(FREE);
public final void createByteArray(byte[] buf, String dirName, String name) throws IOException { saveByteArray(buf, dirName, name, true, true); }
public final void save(Serializable obj, String dirName, String name) throws IOException { save(obj, dirName, name, false); }
public synchronized void commit(boolean release) throws IOException { if (phase != RUN) throw new NotActiveException("Can not commit inexistent transaction."); // Save the log to disk logFile.seek(4L); for (Enumeration e = log.elements(); e.hasMoreElements(); ) { Operation op = (Operation) e.nextElement(); logFile.writeUTF(op.name); if (op.dirName != null) { logFile.writeUTF(op.dirName); } else { logFile.writeUTF(EMPTY_STRING); } logFile.writeByte(op.type); if (op.type == Operation.SAVE) { logFile.writeInt(op.value.length); logFile.write(op.value); } } logFile.writeUTF(""); setPhase(COMMIT); _commit(); log.clear(); if (release) { // Change the transaction state and save it. setPhase(FREE); notify(); } }
/** * Delete the specified directory if it is empty. * Also recursively delete the parent directories if they are empty. */ private void deleteDir(File dir) { String[] children = dir.list(); // children may be null if dir doesn't exist any more. if (children != null && children.length == 0) { dir.delete(); if (dir.getAbsolutePath().length() > this.dir.getAbsolutePath().length()) { deleteDir(dir.getParentFile()); } } }
loadProperties(dir); LogThresholdOperation = getInteger("LogThresholdOperation", LogThresholdOperation).intValue(); Operation.initPool(LogThresholdOperation); saveProperties(dir); _commit(); setPhase(FREE);
public final void createByteArray(byte[] buf, String dirName, String name) throws IOException { saveByteArray(buf, dirName, name, true, true); }
public final void create(Serializable obj, String dirName, String name) throws IOException { save(obj, dirName, name, true); }
public synchronized void commit(boolean release) throws IOException { if (phase != RUN) throw new NotActiveException("Can not commit inexistent transaction."); // Save the log to disk logFile.seek(4L); for (Enumeration e = log.elements(); e.hasMoreElements(); ) { Operation op = (Operation) e.nextElement(); logFile.writeUTF(op.name); if (op.dirName != null) { logFile.writeUTF(op.dirName); } else { logFile.writeUTF(EMPTY_STRING); } logFile.writeByte(op.type); if (op.type == Operation.SAVE) { logFile.writeInt(op.value.length); logFile.write(op.value); } } logFile.writeUTF(""); setPhase(COMMIT); _commit(); log.clear(); if (release) { // Change the transaction state and save it. setPhase(FREE); notify(); } }
/** * Delete the specified directory if it is empty. * Also recursively delete the parent directories if they are empty. */ private void deleteDir(File dir) { String[] children = dir.list(); // children may be null if dir doesn't exist any more. if (children != null && children.length == 0) { dir.delete(); if (dir.getAbsolutePath().length() > this.dir.getAbsolutePath().length()) { deleteDir(dir.getParentFile()); } } }
public final void createByteArray(byte[] buf, String name) throws IOException { saveByteArray(buf, null, name, true, true); }
public final void save(Serializable obj, String name) throws IOException { save(obj, null, name, false); }
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 final byte[] loadByteArray(String name) throws IOException { return loadByteArray(null, name); }
public final void delete(String name) { delete(null, name); }
public final Object load(String name) throws IOException, ClassNotFoundException { return load(null, name); }
public final void saveByteArray(byte[] buf, String name) throws IOException { saveByteArray(buf, null, name, true, false); }