use of org.neo4j.kernel.impl.transaction.log.files.TransactionLogFilesHelper in project neo4j by neo4j.
the class BatchingNeoStores method databaseExistsAndContainsData.
private boolean databaseExistsAndContainsData() {
TransactionLogFilesHelper logFilesHelper = new TransactionLogFilesHelper(fileSystem, databaseLayout.getTransactionLogsDirectory());
TransactionLogFilesHelper checkpointFilesHelper = new TransactionLogFilesHelper(fileSystem, databaseLayout.getTransactionLogsDirectory(), CHECKPOINT_FILE_PREFIX);
try {
if (logFilesHelper.getMatchedFiles().length > 0 || checkpointFilesHelper.getMatchedFiles().length > 0) {
return true;
}
} catch (IOException e) {
// Could not check txlogs (does not exist?) Do nothing
}
Path metaDataFile = databaseLayout.metadataStore();
try (PagedFile pagedFile = pageCache.map(metaDataFile, pageCache.pageSize(), databaseName, immutable.of(READ))) {
// OK so the db probably exists
} catch (IOException e) {
// It's OK
return false;
}
try (NeoStores stores = newStoreFactory(databaseLayout, idGeneratorFactory, pageCacheTracer, immutable.empty()).openNeoStores(StoreType.NODE, StoreType.RELATIONSHIP)) {
return stores.getNodeStore().getHighId() > 0 || stores.getRelationshipStore().getHighId() > 0;
}
}
Aggregations