use of org.apache.jackrabbit.oak.segment.RecordId in project jackrabbit-oak by apache.
the class TarRevisions method doFlush.
private void doFlush(Callable<Void> persisted) throws IOException {
try {
RecordId before = persistedHead.get();
RecordId after = getHead();
if (!after.equals(before)) {
persisted.call();
LOG.debug("TarMK journal update {} -> {}", before, after);
journalFile.writeBytes(after.toString10() + " root " + System.currentTimeMillis() + "\n");
journalFile.getChannel().force(false);
persistedHead.set(after);
}
} catch (Exception e) {
propagateIfInstanceOf(e, IOException.class);
propagate(e);
}
}
use of org.apache.jackrabbit.oak.segment.RecordId in project jackrabbit-oak by apache.
the class DebugStore method analyseSegment.
private static void analyseSegment(final Segment segment, final RecordUsageAnalyser analyser) {
final List<RecordId> ids = newArrayList();
segment.forEachRecord((number, type, offset) -> {
if (type == NODE) {
ids.add(new RecordId(segment.getSegmentId(), number));
}
});
for (RecordId id : ids) {
try {
analyser.analyseNode(id);
} catch (Exception e) {
System.err.format("Error while processing node at %s", id);
e.printStackTrace(System.err);
}
}
}
use of org.apache.jackrabbit.oak.segment.RecordId in project jackrabbit-oak by apache.
the class CheckRepositoryTestBase method addInvalidRevision.
protected void addInvalidRevision() throws InvalidFileStoreVersionException, IOException, CommitFailedException {
FileStore fileStore = FileStoreBuilder.fileStoreBuilder(temporaryFolder.getRoot()).withMaxFileSize(256).withSegmentCacheSize(64).build();
SegmentNodeStore nodeStore = SegmentNodeStoreBuilders.builder(fileStore).build();
NodeBuilder builder = nodeStore.getRoot().builder();
// add a new child "z"
addChildWithBlobProperties(nodeStore, builder, "z", 5);
// add a new property value to existing child "a"
addChildWithBlobProperties(nodeStore, builder, "a", 1);
NodeState after = nodeStore.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
// get record number to corrupt (NODE record for "z")
SegmentNodeState child = (SegmentNodeState) after.getChildNode("z");
RecordId zRecordId = child.getRecordId();
// get record number to corrupt (NODE record for "a")
child = (SegmentNodeState) after.getChildNode("a");
RecordId aRecordId = child.getRecordId();
fileStore.close();
corruptRecord(zRecordId, "data00001a.tar");
corruptRecord(aRecordId, "data00001a.tar");
}
use of org.apache.jackrabbit.oak.segment.RecordId in project jackrabbit-oak by apache.
the class DefaultStandbyReferenceReaderTest method shouldReturnReferences.
@Test
public void shouldReturnReferences() throws Exception {
try (FileStore store = newFileStore()) {
SegmentWriter writer = defaultSegmentWriterBuilder("test").build(store);
RecordId a = writer.writeNode(EmptyNodeState.EMPTY_NODE);
writer.flush();
NodeBuilder builder = EmptyNodeState.EMPTY_NODE.builder();
builder.setChildNode("reference", store.getReader().readNode(a));
RecordId b = writer.writeNode(builder.getNodeState());
writer.flush();
DefaultStandbyReferencesReader reader = new DefaultStandbyReferencesReader(store);
Iterator<String> i = reader.readReferences(b.getSegmentId().asUUID().toString()).iterator();
assertTrue(i.hasNext());
assertEquals(a.getSegmentId().asUUID().toString(), i.next());
assertFalse(i.hasNext());
}
}
use of org.apache.jackrabbit.oak.segment.RecordId in project jackrabbit-oak by apache.
the class TarRevisions method doFlush.
private void doFlush(Flusher flusher) throws IOException {
if (journalFileWriter == null) {
LOG.debug("No journal file available, skipping flush");
return;
}
RecordId before = persistedHead.get();
RecordId after = getHead();
if (after.equals(before)) {
LOG.debug("Head state did not change, skipping flush");
return;
}
flusher.flush();
LOG.debug("TarMK journal update {} -> {}", before, after);
journalFileWriter.writeLine(after.toString10() + " root " + System.currentTimeMillis());
persistedHead.set(after);
}
Aggregations