use of org.neo4j.io.layout.DatabaseLayout in project neo4j by neo4j.
the class AllNodesInStoreExistInLabelIndexTest method replaceLabelIndexWithCopy.
private void replaceLabelIndexWithCopy(Path labelIndexFileCopy) throws IOException {
managementService.shutdown();
DatabaseLayout databaseLayout = db.databaseLayout();
fs.deleteFile(databaseLayout.labelScanStore());
fs.copyFile(labelIndexFileCopy, databaseLayout.labelScanStore());
}
use of org.neo4j.io.layout.DatabaseLayout in project neo4j by neo4j.
the class AllNodesInStoreExistInLabelIndexTest method reportNotCleanLabelIndex.
@Test
void reportNotCleanLabelIndex() throws IOException, ConsistencyCheckIncompleteException {
DatabaseLayout databaseLayout = db.databaseLayout();
someData();
checkPointer.forceCheckPoint(new SimpleTriggerInfo("forcedCheckpoint"));
Path labelIndexFileCopy = databaseLayout.file("label_index_copy");
copyFile(databaseLayout.labelScanStore(), labelIndexFileCopy);
try (Transaction tx = db.beginTx()) {
tx.createNode(LABEL_ONE);
tx.commit();
}
managementService.shutdown();
copyFile(labelIndexFileCopy, databaseLayout.labelScanStore());
ConsistencyCheckService.Result result = fullConsistencyCheck();
assertFalse(result.isSuccessful(), "Expected consistency check to fail");
assertThat(readReport(result)).contains("WARN Index was dirty on startup which means it was not shutdown correctly and need to be cleaned up with a successful recovery.");
}
use of org.neo4j.io.layout.DatabaseLayout in project neo4j by neo4j.
the class AllNodesInStoreExistInLabelIndexTest method reportNotCleanLabelIndexWithCorrectData.
@Test
void reportNotCleanLabelIndexWithCorrectData() throws IOException, ConsistencyCheckIncompleteException {
DatabaseLayout databaseLayout = db.databaseLayout();
someData();
checkPointer.forceCheckPoint(new SimpleTriggerInfo("forcedCheckpoint"));
Path labelIndexFileCopy = databaseLayout.file("label_index_copy");
copyFile(databaseLayout.labelScanStore(), labelIndexFileCopy);
managementService.shutdown();
copyFile(labelIndexFileCopy, databaseLayout.labelScanStore());
ConsistencyCheckService.Result result = fullConsistencyCheck();
assertTrue(result.isSuccessful(), "Expected consistency check to fail");
assertThat(readReport(result)).contains("WARN Index was dirty on startup which means it was not shutdown correctly and need to be cleaned up with a successful recovery.");
}
use of org.neo4j.io.layout.DatabaseLayout in project neo4j by neo4j.
the class MemoryRecommendationsCommandTest method includeAllDatabasesToMemoryRecommendations.
@Test
void includeAllDatabasesToMemoryRecommendations() throws IOException {
PrintStream output = mock(PrintStream.class);
Path homeDir = neo4jLayout.homeDirectory();
Path configDir = homeDir.resolve("conf");
Files.createDirectories(configDir);
Path configFile = configDir.resolve(DEFAULT_CONFIG_FILE_NAME);
Files.createFile(configFile);
long totalPageCacheSize = 0;
long totalLuceneIndexesSize = 0;
for (int i = 0; i < 5; i++) {
DatabaseLayout databaseLayout = neo4jLayout.databaseLayout("db" + i);
createDatabaseWithNativeIndexes(homeDir, databaseLayout.getDatabaseName());
long[] expectedSizes = calculatePageCacheFileSize(databaseLayout);
totalPageCacheSize += expectedSizes[0];
totalLuceneIndexesSize += expectedSizes[1];
}
DatabaseLayout systemLayout = neo4jLayout.databaseLayout(SYSTEM_DATABASE_NAME);
long[] expectedSizes = calculatePageCacheFileSize(systemLayout);
totalPageCacheSize += expectedSizes[0];
totalLuceneIndexesSize += expectedSizes[1];
MemoryRecommendationsCommand command = new MemoryRecommendationsCommand(new ExecutionContext(homeDir, configDir, output, mock(PrintStream.class), testDirectory.getFileSystem()));
CommandLine.populateCommand(command, "--memory=8g");
command.execute();
final long expectedLuceneIndexesSize = totalLuceneIndexesSize;
final long expectedPageCacheSize = totalPageCacheSize;
verify(output).println(contains("Total size of lucene indexes in all databases: " + bytesToString(expectedLuceneIndexesSize)));
verify(output).println(contains("Total size of data and native indexes in all databases: " + bytesToString(expectedPageCacheSize)));
}
use of org.neo4j.io.layout.DatabaseLayout in project neo4j by neo4j.
the class IndexConsistencyIT method fullConsistencyCheck.
private ConsistencyCheckService.Result fullConsistencyCheck() throws ConsistencyCheckIncompleteException, IOException {
try (FileSystemAbstraction fsa = new DefaultFileSystemAbstraction()) {
ConsistencyCheckService service = new ConsistencyCheckService();
DatabaseLayout databaseLayout = db.databaseLayout();
Config config = Config.defaults(logs_directory, databaseLayout.databaseDirectory());
return service.runFullConsistencyCheck(databaseLayout, config, NONE, log, fsa, false, ConsistencyFlags.DEFAULT);
}
}
Aggregations