use of org.apache.jackrabbit.oak.segment.file.FileStore in project jackrabbit-oak by apache.
the class Compact method run.
public int run() {
System.out.printf("Compacting %s with %s\n", path, fileAccessMode.description);
System.out.printf(" before\n");
Set<File> beforeFiles = listFiles(path);
printFiles(System.out, beforeFiles);
System.out.printf(" size %s\n", printableSize(sizeOfDirectory(path)));
System.out.printf(" -> compacting\n");
Stopwatch watch = Stopwatch.createStarted();
try (FileStore store = newFileStore()) {
if (!store.compactFull()) {
System.out.printf("Compaction cancelled after %s.\n", printableStopwatch(watch));
return 1;
}
System.out.printf(" -> cleaning up\n");
store.cleanup();
JournalFile journal = new LocalJournalFile(path, "journal.log");
String head;
try (JournalReader journalReader = new JournalReader(journal)) {
head = String.format("%s root %s\n", journalReader.next().getRevision(), System.currentTimeMillis());
}
try (JournalFileWriter journalWriter = journal.openJournalWriter()) {
System.out.printf(" -> writing new %s: %s\n", journal.getName(), head);
journalWriter.truncate();
journalWriter.writeLine(head);
}
} catch (Exception e) {
watch.stop();
e.printStackTrace(System.err);
System.out.printf("Compaction failed after %s.\n", printableStopwatch(watch));
return 1;
}
watch.stop();
System.out.printf(" after\n");
Set<File> afterFiles = listFiles(path);
printFiles(System.out, afterFiles);
System.out.printf(" size %s\n", printableSize(sizeOfDirectory(path)));
System.out.printf(" removed files %s\n", fileNames(difference(beforeFiles, afterFiles)));
System.out.printf(" added files %s\n", fileNames(difference(afterFiles, beforeFiles)));
System.out.printf("Compaction succeeded in %s.\n", printableStopwatch(watch));
return 0;
}
use of org.apache.jackrabbit.oak.segment.file.FileStore 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.file.FileStore in project jackrabbit-oak by apache.
the class CheckRepositoryTestBase method addValidRevision.
protected void addValidRevision() 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();
addChildWithBlobProperties(nodeStore, builder, "a", 1);
addChildWithBlobProperties(nodeStore, builder, "b", 2);
addChildWithBlobProperties(nodeStore, builder, "c", 3);
addChildWithProperties(nodeStore, builder, "d", 4);
addChildWithProperties(nodeStore, builder, "e", 5);
addChildWithProperties(nodeStore, builder, "f", 6);
nodeStore.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
// add checkpoints
String cp1 = nodeStore.checkpoint(10_000);
String cp2 = nodeStore.checkpoint(10_000);
checkpoints.add(cp1);
checkpoints.add(cp2);
fileStore.close();
}
use of org.apache.jackrabbit.oak.segment.file.FileStore in project jackrabbit-oak by apache.
the class BrokenNetworkIT method useProxy.
private void useProxy(boolean ssl, int skipPosition, int skipBytes, int flipPosition, boolean intermediateChange) throws Exception {
FileStore serverStore = serverFileStore.fileStore();
FileStore clientStore = clientFileStore1.fileStore();
NodeStore store = SegmentNodeStoreBuilders.builder(serverStore).build();
addTestContent(store, "server");
serverStore.flush();
try (StandbyServerSync serverSync = new StandbyServerSync(serverPort.getPort(), serverStore, MB, ssl)) {
serverSync.start();
File spoolFolder = folder.newFolder();
try (NetworkErrorProxy ignored = new NetworkErrorProxy(proxyPort.getPort(), getServerHost(), serverPort.getPort(), flipPosition, skipPosition, skipBytes);
StandbyClientSync clientSync = new StandbyClientSync(getServerHost(), proxyPort.getPort(), clientStore, ssl, getClientTimeout(), false, spoolFolder)) {
clientSync.run();
}
assertFalse("stores are equal", serverStore.getHead().equals(clientStore.getHead()));
if (intermediateChange) {
addTestContent(store, "server2");
serverStore.flush();
}
try (StandbyClientSync clientSync = new StandbyClientSync(getServerHost(), serverPort.getPort(), clientStore, ssl, getClientTimeout(), false, spoolFolder)) {
clientSync.run();
}
}
assertEquals("stores are not equal", serverStore.getHead(), clientStore.getHead());
}
use of org.apache.jackrabbit.oak.segment.file.FileStore in project jackrabbit-oak by apache.
the class BrokenNetworkIT method testProxy.
@Test
public void testProxy() throws Exception {
FileStore serverStore = serverFileStore.fileStore();
FileStore clientStore = clientFileStore1.fileStore();
NodeStore store = SegmentNodeStoreBuilders.builder(serverStore).build();
addTestContent(store, "server");
serverStore.flush();
try (StandbyServerSync serverSync = new StandbyServerSync(serverPort.getPort(), serverStore, MB, false);
StandbyClientSync clientSync = new StandbyClientSync(getServerHost(), serverPort.getPort(), clientStore, false, getClientTimeout(), false, folder.newFolder())) {
serverSync.start();
clientSync.run();
}
assertEquals(serverStore.getHead(), clientStore.getHead());
}
Aggregations