blockSequence = old.getBlockSequence(); final long firstCommitTime = (old.getFirstCommitTime() == 0L ? commitTime : old.getFirstCommitTime()); final long priorCommitTime = old.getLastCommitTime(); newRootBlock = new RootBlockView(!old.isRootBlock0(), old.getOffsetBits(), nextOffset, firstCommitTime, lastCommitTime, newCommitCounter, commitRecordAddr, commitRecordIndexAddr, old.getUUID(), // blockSequence, metaStartAddr, metaBitsAddr, old.getStoreType(), old.getCreateTime(), old.getCloseTime(), old.getVersion(), store.checker);
private static IRootBlockView closeRBV(final IRootBlockView rbv) { return new RootBlockView( // !rbv.isRootBlock0(), 0, 0, System.currentTimeMillis() /* commitTime */, 0, rbv .getCommitCounter() + 1 /* commitCounter */, 100, 100, // non-zero commit records rbv.getUUID(), 0, // VERSION3 rbv.getQuorumToken(), 0, // VERSION1 0, // VERSION1 rbv.getStoreType(), // storetype rbv.getCreateTime(), System.currentTimeMillis(), RootBlockView.currentVersion, ChecksumUtility.getCHK()); }
final long nxtOffset = rbv.getNextOffset(); final int nxtalloc = -(int) (nxtOffset >> 32); final long metaAddr = rbv.getMetaStartAddr(); final long rawMetaBitsAddr = rbv.getMetaBitsAddr(); if (metaAddr == 0 || rawMetaBitsAddr == 0) { final int commitRecordAddr = (int) (rbv.getCommitRecordAddr() >> 32); log.trace("CommitRecord " + rbv.getCommitRecordAddr() + " at physical address: " + physicalAddress(commitRecordAddr)); final long commitCounter = rbv.getCommitCounter();
/** * Record level checksums are enabled for the RW store since * {@link RootBlockView#VERSION1} and for the WORM store since * {@link RootBlockView#VERSION2}. * * @param rootBlock * A root block. * * @return Whether or not record level checksums are enabled. */ static private boolean useChecksums(final IRootBlockView rootBlock) { return rootBlock.getVersion() >= RootBlockView.VERSION2 || (rootBlock.getVersion() == 1 && rootBlock.getStoreType() == StoreTypeEnum.RW); }
@Override public void resetFromHARootBlock(final IRootBlockView rootBlock) { final long rbNextOffset = rootBlock.getNextOffset(); nextOffset.set(rbNextOffset); commitOffset.set(rbNextOffset); // Note: Potentially updated (if root blocks were reinstalled). storeUUIDRef.set(rootBlock.getUUID()); }
final long lastCommitTime = _rootBlock.getLastCommitTime(); if (old.getCommitCounter() == 0L) { final long metaBitsAddr = _bufferStrategy.getMetaBitsAddr(); final IRootBlockView newRootBlock = new RootBlockView(// !old.isRootBlock0(), old.getOffsetBits(), old.getNextOffset(), old.getFirstCommitTime(), old .getLastCommitTime(), // old.getCommitCounter() + 1, // old.getCommitRecordAddr(), // old.getCommitRecordIndexAddr(), // old.getUUID(), // old.getStoreType(), // old.getCreateTime(), closeTime, // old.getVersion(), checker);
final IRootBlockView rbv = openRBV(StoreTypeEnum.RW); assertTrue(rbv.getStoreType() == StoreTypeEnum.RW); final IHAWriteMessage msg = new HAWriteMessage(storeUUID, rbv.getCommitCounter(), rbv .getFirstCommitTime(), sequence, data.limit(), checker .checksum(data), rbv.getStoreType(), rbv.getQuorumToken(), 1000, 0); final IHAWriteMessage msg2 = new HAWriteMessage(storeUUID, rbv.getCommitCounter(), rbv .getFirstCommitTime(), sequence+1, data.limit(), checker .checksum(data), rbv.getStoreType(), rbv.getQuorumToken(), 1000, 0);
this.bufferMode = BufferMode.getDefaultBufferMode(rootBlock.getStoreType()); this.offsetBits = rootBlock.getOffsetBits(); this.nextOffset = rootBlock.getNextOffset(); this.createTime = rootBlock.getCreateTime(); this.closeTime = rootBlock.getCloseTime();
data.limit(200 + r.nextInt(1800)); final IHAWriteMessage msg = new HAWriteMessage(storeUUID, rbv .getCommitCounter(), rbv.getLastCommitTime(), sequence++, data.limit(), checker.checksum(data), rbv.getStoreType(), rbv.getQuorumToken(), 1000, 0);
this.nextOffset = rbu.rootBlock.getNextOffset(); this.offsetBits = rbu.rootBlock.getOffsetBits(); this.createTime = rbu.rootBlock.getCreateTime(); this.closeTime = rbu.rootBlock.getCloseTime(); final IRootBlockView rootBlock0 = rbu.rootBlock0; final IRootBlockView rootBlock1 = rbu.rootBlock1; .asReadOnlyBuffer(), OFFSET_ROOT_BLOCK0); .asReadOnlyBuffer(), OFFSET_ROOT_BLOCK1);
+ rootBlock.getCommitCounter() + ", commitRecordAddr: " + rootBlock.getCommitRecordAddr() + ", commitRecordIndexAddr: " + rootBlock.getCommitRecordIndexAddr()); final ByteBuffer data = rootBlock.asReadOnlyBuffer(); final long pos = rootBlock.isRootBlock0() ? FileMetadata.OFFSET_ROOT_BLOCK0 : FileMetadata.OFFSET_ROOT_BLOCK1;
.getRootBlockView().getCreateTime(); .getUUID(); assertEquals("uuid", uuid0, oldJournal.getRootBlockView().getUUID()); assertNotSame("closeTime", 0L, oldJournal.getRootBlockView() .getCloseTime()); .getLastCommitTime(), segmentMetadata.getCreateTime());
/** * The description of a journal. The {@link JournalMetadata} state will not * change as writes are made on the journal since it does not reflect * anything exception the {@link UUID}, the filename, and the create time. * * @param journal * The journal. */ public JournalMetadata(final AbstractJournal journal) { this(getFileString(journal), //journal.getBufferStrategy().getExtent(), journal.getRootBlockView().getUUID(), // journal.getRootBlockView().getCreateTime(), // createTime. 0L // commitTime ); }
log.debug("commitTimeToPreserve=" + commitTimeToPreserve + ", lastCommitTime=" + getLiveJournal().getRootBlockView().getLastCommitTime()); uuids.add(getLiveJournal().getRootBlockView().getUUID()); .getLastCommitTime(); + journal.getFile() + ", lastCommitTime=" + lastCommitTime + ", uuid=" + journal.getRootBlockView().getUUID()); .getCommitRecordIndexAddr(),true/*readOnly*/);
/** * * @return true if the file is complete and its size indicates no content */ public boolean isEmpty() { return (m_closeRootBlock != null) && (m_openRootBlock.getCommitCounter() == m_closeRootBlock .getCommitCounter()); }
@Override final public long getLastCommitTime() { // final ReadLock lock = _fieldReadWriteLock.readLock(); // // lock.lock(); // // try { return _rootBlock.getLastCommitTime(); // } finally { // // lock.unlock(); // // } }
@Override public void sample() { final AbstractJournal jnl = ref.get(); if (jnl != null) { final IRootBlockView rootBlock = jnl._rootBlock; if (rootBlock != null) { setValue(rootBlock.getCloseTime()); } } } });
/** * Return a read-only view of the last committed state of the * {@link CommitRecordIndex}. * * @return The read-only view of the {@link CommitRecordIndex}. */ public CommitRecordIndex getReadOnlyCommitRecordIndex() { final ReadLock lock = _fieldReadWriteLock.readLock(); lock.lock(); try { assertOpen(); final CommitRecordIndex commitRecordIndex = getCommitRecordIndex( _rootBlock.getCommitRecordIndexAddr(), true/* readOnly */); // return new ReadOnlyIndex(commitRecordIndex); return commitRecordIndex; } finally { lock.unlock(); } }
@Override public void postHACommit(final IRootBlockView rootBlock) { final long rbNextOffset = rootBlock.getNextOffset(); nextOffset.set(rbNextOffset); commitOffset.set(rbNextOffset); }
private static void doFile(final File file, final IBufferAccess buf) throws IOException { final HALogFile f = new HALogFile(file); final IHALogReader r = f.getReader(); try { final IRootBlockView openingRootBlock = r.getOpeningRootBlock(); final IRootBlockView closingRootBlock = r.getClosingRootBlock(); final boolean isWORM = openingRootBlock.getStoreType() == StoreTypeEnum.WORM; if (openingRootBlock.getCommitCounter() == closingRootBlock .getCommitCounter()) { System.err.println("EMPTY LOG: " + file); } System.out.println("----------begin----------"); System.out.println("file=" + file); System.out.println("openingRootBlock=" + openingRootBlock); System.out.println("closingRootBlock=" + closingRootBlock); while (r.hasMoreBuffers()) { // don't pass buffer in if WORM, just validate the messages final IHAWriteMessage msg = r.processNextBuffer(isWORM ? null : buf.buffer()); System.out.println(msg.toString()); } System.out.println("-----------end-----------"); } finally { r.close(); } }