コード例 #1
0
ファイル: JournalWriter.java プロジェクト: ame89/nfsdb
  @Override
  protected void configure() throws JournalException {
    writeLock = LockManager.lockExclusive(getLocation());
    if (writeLock == null || !writeLock.isValid()) {
      close();
      throw new JournalException("Journal is already open for APPEND at %s", getLocation());
    }
    if (txLog.isEmpty()) {
      commit(Tx.TX_NORMAL, 0L, 0L);
    }
    txLog.head(tx);

    File meta = new File(getLocation(), JournalConfiguration.FILE_NAME);
    if (!meta.exists()) {
      try (UnstructuredFile hb = new UnstructuredFile(meta, 12, JournalMode.APPEND)) {
        getMetadata().write(hb);
      }
    }

    super.configure();

    beginTx();
    rollback();
    rollbackPartitionDirs();

    if (tx.journalMaxRowID > 0
        && getPartitionCount() <= Rows.toPartitionIndex(tx.journalMaxRowID)) {
      beginTx();
      commit();
    }
    if (getMetadata().getLag() != -1) {
      this.partitionCleaner = new PartitionCleaner(this, getLocation().getName());
      this.partitionCleaner.start();
    }
  }