public String getDatabaseDirAbsolutePath() { return databaseLayout().databaseDirectory().getAbsolutePath(); }
private File archiveFile() { File indexDir = nativeIndexDirectoryStructure( db.databaseLayout() ).rootDirectory(); File[] files = indexDir.listFiles( pathname -> pathname.isFile() && pathname.getName().startsWith( "archive-" ) ); if ( files == null || files.length == 0 ) { return null; } assertEquals( 1, files.length ); return files[0]; }
@Before public void setup() { databaseLayout = db.databaseLayout(); fs = db.getDependencyResolver().resolveDependency( FileSystemAbstraction.class ); }
@Test public void scanStoreStartWithoutExistentIndex() throws Throwable { LabelScanStore labelScanStore = getLabelScanStore(); GroupingRecoveryCleanupWorkCollector workCollector = getGroupingRecoveryCleanupWorkCollector(); labelScanStore.shutdown(); workCollector.shutdown(); deleteLabelScanStoreFiles( dbRule.databaseLayout() ); workCollector.init(); labelScanStore.init(); workCollector.start(); labelScanStore.start(); checkLabelScanStoreAccessible( labelScanStore ); }
@Test public void pruningStrategyShouldBeDynamic() throws IOException { CheckPointer checkPointer = getInstanceFromDb( CheckPointer.class ); Config config = getInstanceFromDb( Config.class ); FileSystemAbstraction fs = getInstanceFromDb( FileSystemAbstraction.class ); LogFiles logFiles = LogFilesBuilder.builder( db.databaseLayout(), fs ) .withLogVersionRepository( new SimpleLogVersionRepository() ) .withLastCommittedTransactionIdSupplier( () -> 1 ) .withTransactionIdStore( new SimpleTransactionIdStore() ).build(); // Force transaction log rotation writeTransactionsAndRotateTwice(); // Checkpoint to make sure strategy is evaluated checkPointer.forceCheckPoint( triggerInfo ); // Make sure file is still there since we have disable pruning assertThat( countTransactionLogs( logFiles ), is( 3 ) ); // Change pruning to true config.updateDynamicSetting( keep_logical_logs.name(), "false", "test" ); // Checkpoint to make sure strategy is evaluated checkPointer.forceCheckPoint( triggerInfo ); // Make sure file is removed assertThat( countTransactionLogs( logFiles ), is( 2 ) ); }
@Test public void scanStoreRecreateCorruptedIndexOnStartup() throws Throwable { LabelScanStore labelScanStore = getLabelScanStore(); GroupingRecoveryCleanupWorkCollector workCollector = getGroupingRecoveryCleanupWorkCollector(); createTestNode(); long[] labels = readNodesForLabel( labelScanStore ); assertEquals( "Label scan store see 1 label for node", 1, labels.length ); labelScanStore.force( IOLimiter.UNLIMITED ); labelScanStore.shutdown(); workCollector.shutdown(); corruptLabelScanStoreFiles( dbRule.databaseLayout() ); workCollector.init(); labelScanStore.init(); workCollector.start(); labelScanStore.start(); long[] rebuildLabels = readNodesForLabel( labelScanStore ); assertArrayEquals( "Store should rebuild corrupted index", labels, rebuildLabels ); }
@Test public void recoveryForRelationshipCommandsOnly() throws Throwable { // shutdown db here DatabaseLayout databaseLayout = db.databaseLayout(); shutdownDB(); try ( Transaction tx = db.beginTx() ) { Index<Relationship> index = db.index().forRelationships( "myIndex" ); Node node = db.createNode(); Relationship relationship = db.createNode().createRelationshipTo( node, RelationshipType.withName( "KNOWS" ) ); index.add( relationship, "key", "value" ); tx.success(); } db.shutdown(); Config config = Config.defaults(); IndexConfigStore indexStore = new IndexConfigStore( databaseLayout, fileSystemRule.get() ); LuceneDataSource ds = new LuceneDataSource( databaseLayout, config, indexStore, fileSystemRule.get(), OperationalMode.single ); ds.start(); ds.stop(); }
public String getDatabaseDirAbsolutePath() { return databaseLayout().databaseDirectory().getAbsolutePath(); }