コード例 #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();
    }
  }
コード例 #2
0
ファイル: JournalWriter.java プロジェクト: ame89/nfsdb
  @Override
  public final void close() {
    if (open) {
      if (partitionCleaner != null) {
        partitionCleaner.halt();
        partitionCleaner = null;
      }
      try {
        if (isCommitOnClose()) {
          commit();
          purgeUnusedTempPartitions(txLog);
        }
        super.close();
        if (writeLock != null) {
          LockManager.release(writeLock);
          writeLock = null;
        }

        if (discardTxtRaf != null) {
          try {
            discardSink.close();
            discardTxtRaf.close();
          } catch (IOException e) {
            LOGGER.warn("Failed to close discard file");
          }
        }
      } catch (JournalException e) {
        throw new JournalRuntimeException(e);
      }
    }
  }
コード例 #3
0
ファイル: JournalWriter.java プロジェクト: ame89/nfsdb
 public void append(Journal<T> journal) throws JournalException {
   try (ConcurrentIterator<T> iterator = journal.concurrentIterator()) {
     for (T obj : iterator) {
       append(obj);
     }
   }
 }
コード例 #4
0
ファイル: JournalWriter.java プロジェクト: ame89/nfsdb
 @Override
 void closePartitions() {
   super.closePartitions();
   appendPartition = null;
   appendTimestampHi = -1;
 }