use of org.neo4j.io.fs.FileSystemAbstraction in project neo4j by neo4j.
the class TestArrayStore method before.
@Before
public void before() throws Exception {
File dir = testDirectory.graphDbDir();
FileSystemAbstraction fs = fileSystemRule.get();
DefaultIdGeneratorFactory idGeneratorFactory = new DefaultIdGeneratorFactory(fs);
PageCache pageCache = pageCacheRule.getPageCache(fs);
StoreFactory factory = new StoreFactory(dir, Config.empty(), idGeneratorFactory, pageCache, fs, NullLogProvider.getInstance());
neoStores = factory.openAllNeoStores(true);
arrayStore = neoStores.getPropertyStore().getArrayStore();
}
use of org.neo4j.io.fs.FileSystemAbstraction in project neo4j by neo4j.
the class NeoStoresTest method shouldNotSetHighestTransactionIdWhenNeeded.
@Test
public void shouldNotSetHighestTransactionIdWhenNeeded() throws Throwable {
// GIVEN
FileSystemAbstraction fileSystem = fs.get();
fileSystem.mkdirs(storeDir);
StoreFactory factory = new StoreFactory(storeDir, pageCache, fileSystem, NullLogProvider.getInstance());
try (NeoStores neoStore = factory.openAllNeoStores(true)) {
MetaDataStore store = neoStore.getMetaDataStore();
store.setLastCommittedAndClosedTransactionId(40, 4444, BASE_TX_COMMIT_TIMESTAMP, LogHeader.LOG_HEADER_SIZE, 0);
// WHEN
store.transactionCommitted(39, 3333, BASE_TX_COMMIT_TIMESTAMP);
// THEN
assertEquals(new TransactionId(40, 4444, BASE_TX_COMMIT_TIMESTAMP), store.getLastCommittedTransaction());
assertArrayEquals(store.getLastClosedTransaction(), new long[] { 40, 0, LogHeader.LOG_HEADER_SIZE });
}
}
use of org.neo4j.io.fs.FileSystemAbstraction in project neo4j by neo4j.
the class CheckConsistencyCommand method execute.
@Override
public void execute(String[] args) throws IncorrectUsage, CommandFailed {
final String database;
final boolean verbose;
final Optional<Path> additionalConfigFile;
final Path reportDir;
final Optional<Path> backupPath;
final boolean checkGraph;
final boolean checkIndexes;
final boolean checkLabelScanStore;
final boolean checkPropertyOwners;
try {
database = arguments.parse("database", args);
backupPath = arguments.parseOptionalPath("backup", args);
verbose = arguments.parseBoolean("verbose", args);
additionalConfigFile = arguments.parseOptionalPath("additional-config", args);
reportDir = arguments.parseOptionalPath("report-dir", args).orElseThrow(() -> new IllegalArgumentException("report-dir must be a valid path"));
} catch (IllegalArgumentException e) {
throw new IncorrectUsage(e.getMessage());
}
if (backupPath.isPresent()) {
if (arguments.has("database", args)) {
throw new IncorrectUsage("Only one of '--database' and '--backup' can be specified.");
}
if (!backupPath.get().toFile().isDirectory()) {
throw new CommandFailed(format("Specified backup should be a directory: %s", backupPath.get()));
}
}
Config config = loadNeo4jConfig(homeDir, configDir, database, loadAdditionalConfig(additionalConfigFile));
try {
// We can remove the loading from config file in 4.0
if (arguments.has(CHECK_GRAPH, args)) {
checkGraph = arguments.parseBoolean(CHECK_GRAPH, args);
} else {
checkGraph = ConsistencyCheckSettings.consistency_check_graph.from(config);
}
if (arguments.has(CHECK_INDEXES, args)) {
checkIndexes = arguments.parseBoolean(CHECK_INDEXES, args);
} else {
checkIndexes = ConsistencyCheckSettings.consistency_check_indexes.from(config);
}
if (arguments.has(CHECK_LABEL_SCAN_STORE, args)) {
checkLabelScanStore = arguments.parseBoolean(CHECK_LABEL_SCAN_STORE, args);
} else {
checkLabelScanStore = ConsistencyCheckSettings.consistency_check_label_scan_store.from(config);
}
if (arguments.has(CHECK_PROPERTY_OWNERS, args)) {
checkPropertyOwners = arguments.parseBoolean(CHECK_PROPERTY_OWNERS, args);
} else {
checkPropertyOwners = ConsistencyCheckSettings.consistency_check_property_owners.from(config);
}
} catch (IllegalArgumentException e) {
throw new IncorrectUsage(e.getMessage());
}
try (FileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction()) {
File storeDir = backupPath.map(Path::toFile).orElse(config.get(database_path));
checkDbState(storeDir, config);
ConsistencyCheckService.Result consistencyCheckResult = consistencyCheckService.runFullConsistencyCheck(storeDir, config, ProgressMonitorFactory.textual(System.err), FormattedLogProvider.toOutputStream(System.out), fileSystem, verbose, reportDir.toFile(), new CheckConsistencyConfig(checkGraph, checkIndexes, checkLabelScanStore, checkPropertyOwners));
if (!consistencyCheckResult.isSuccessful()) {
throw new CommandFailed(format("Inconsistencies found. See '%s' for details.", consistencyCheckResult.reportFile()));
}
} catch (ConsistencyCheckIncompleteException | IOException e) {
throw new CommandFailed("Consistency checking failed." + e.getMessage(), e);
}
}
use of org.neo4j.io.fs.FileSystemAbstraction in project neo4j by neo4j.
the class RealOutsideWorldTest method closeFilesystemOnExit.
@Test
public void closeFilesystemOnExit() throws IOException {
RealOutsideWorld outsideWorld = new RealOutsideWorld();
FileSystemAbstraction fileSystemMock = mock(FileSystemAbstraction.class);
outsideWorld.fileSystemAbstraction = fileSystemMock;
systemExitRule.expectExit(0);
outsideWorld.exit(0);
verify(fileSystemMock).close();
}
use of org.neo4j.io.fs.FileSystemAbstraction in project neo4j by neo4j.
the class RealOutsideWorldTest method closeFileSystemOnClose.
@Test
public void closeFileSystemOnClose() throws Exception {
RealOutsideWorld outsideWorld = new RealOutsideWorld();
FileSystemAbstraction fileSystemMock = mock(FileSystemAbstraction.class);
outsideWorld.fileSystemAbstraction = fileSystemMock;
outsideWorld.close();
verify(fileSystemMock).close();
}
Aggregations