コード例 #1
0
 private void syncAndClose(Bin bin) {
   try {
     bin.sync();
   } finally {
     bin.close();
   }
 }
コード例 #2
0
 private void writeToLockFile(int lockSignal) {
   ByteArrayBuffer lockBuffer = newLockFileBuffer();
   lockBuffer.writeInt(lockSignal);
   lockBuffer.writeInt(lockSignal);
   write(_lockFile, lockBuffer);
   _lockFile.sync();
 }
コード例 #3
0
  @Override
  public void applySlotChanges(
      Visitable<SlotChange> slotChangeTree, int slotChangeCount, Slot reservedSlot) {
    if (slotChangeCount < 1) {
      return;
    }

    Runnable commitHook = _container.commitHook();
    flushDatabaseFile();

    ensureLogAndLock();
    int length = transactionLogSlotLength(slotChangeCount);
    ByteArrayBuffer logBuffer = new ByteArrayBuffer(length);
    logBuffer.writeInt(length);
    logBuffer.writeInt(slotChangeCount);

    appendSlotChanges(logBuffer, slotChangeTree);
    write(_logFile, logBuffer);
    _logFile.sync();

    writeToLockFile(LOCK_INT);

    writeSlots(slotChangeTree);
    commitHook.run();
    flushDatabaseFile();
    writeToLockFile(0);
  }
コード例 #4
0
 private void write(Bin storage, ByteArrayBuffer buffer) {
   storage.write(0, buffer._buffer, buffer.length());
 }
コード例 #5
0
 private void read(Bin storage, ByteArrayBuffer buffer) {
   storage.read(0, buffer._buffer, buffer.length());
 }