private static void setCurrentVersion() {
   myRecords.putInt(HEADER_VERSION_OFFSET, VERSION);
   myRecords.putLong(HEADER_TIMESTAMP_OFFSET, System.currentTimeMillis());
   myAttributes.setVersion(VERSION);
   myContents.setVersion(VERSION);
   myRecords.putInt(HEADER_CONNECTION_STATUS_OFFSET, SAFELY_CLOSED_MAGIC);
 }
    private static int getVersion() {
      final int recordsVersion = myRecords.getInt(HEADER_VERSION_OFFSET);
      if (myAttributes.getVersion() != recordsVersion || myContents.getVersion() != recordsVersion)
        return -1;

      return recordsVersion;
    }
 public static boolean isDirty() {
   return myDirty
       || myNames.isDirty()
       || myAttributes.isDirty()
       || myContents.isDirty()
       || myRecords.isDirty();
 }
  private static int findAttributePage(int fileId, String attrId, boolean toWrite)
      throws IOException {
    checkFileIsValid(fileId);

    Storage storage = getAttributesStorage();

    int encodedAttrId = DbConnection.getAttributeId(attrId);
    int recordId = getAttributeRecordId(fileId);

    if (recordId == 0) {
      if (!toWrite) return 0;

      recordId = storage.createNewRecord();
      setAttributeRecordId(fileId, recordId);
    } else {
      DataInputStream attrRefs = storage.readStream(recordId);
      try {
        while (attrRefs.available() > 0) {
          final int attIdOnPage = DataInputOutputUtil.readINT(attrRefs);
          final int attrAddress = DataInputOutputUtil.readINT(attrRefs);

          if (attIdOnPage == encodedAttrId) return attrAddress;
        }
      } finally {
        attrRefs.close();
      }
    }

    if (toWrite) {
      Storage.AppenderStream appender = storage.appendStream(recordId);
      DataInputOutputUtil.writeINT(appender, encodedAttrId);
      int attrAddress = storage.createNewRecord();
      DataInputOutputUtil.writeINT(appender, attrAddress);
      DbConnection.REASONABLY_SMALL.myAttrPageRequested = true;
      try {
        appender.close();
      } finally {
        DbConnection.REASONABLY_SMALL.myAttrPageRequested = false;
      }
      return attrAddress;
    }

    return 0;
  }
 public static void force() {
   try {
     w.lock();
     if (myRecords != null) {
       markClean();
     }
     if (myNames != null) {
       myNames.force();
       myAttributes.force();
       myContents.force();
       myRecords.force();
     }
   } finally {
     w.unlock();
   }
 }
    public static void flushSome() {
      if (!isDirty() || HeavyProcessLatch.INSTANCE.isRunning()) return;

      try {
        w.lock();
        if (myFlushingFuture == null) {
          return; // avoid NPE when close has already taken place
        }
        myNames.force();

        final boolean attribsFlushed = myAttributes.flushSome();
        final boolean contentsFlushed = myContents.flushSome();
        if (attribsFlushed && contentsFlushed) {
          markClean();
          myRecords.force();
        }
      } finally {
        w.unlock();
      }
    }