use of org.neo4j.io.fs.DefaultFileSystemAbstraction in project neo4j by neo4j.
the class Runner method call.
@Override
public Long call() throws Exception {
long lastCommittedTransactionId;
try (FileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction();
Lifespan life = new Lifespan()) {
TransactionIdStore transactionIdStore = new SimpleTransactionIdStore();
TransactionMetadataCache transactionMetadataCache = new TransactionMetadataCache();
LogFiles logFiles = life.add(createLogFiles(transactionIdStore, fileSystem));
TransactionAppender transactionAppender = life.add(createBatchingTransactionAppender(transactionIdStore, transactionMetadataCache, logFiles));
ExecutorService executorService = Executors.newFixedThreadPool(threads);
try {
List<Future<?>> handlers = new ArrayList<>(threads);
for (int i = 0; i < threads; i++) {
TransactionRepresentationFactory factory = new TransactionRepresentationFactory();
Worker task = new Worker(transactionAppender, factory, condition);
handlers.add(executorService.submit(task));
}
// wait for all the workers to complete
Futures.getAll(handlers);
} finally {
executorService.shutdown();
}
lastCommittedTransactionId = transactionIdStore.getLastCommittedTransactionId();
}
return lastCommittedTransactionId;
}
use of org.neo4j.io.fs.DefaultFileSystemAbstraction in project neo4j by neo4j.
the class NumberArrayPageCacheTestSupport method prepareDirectoryAndPageCache.
static Fixture prepareDirectoryAndPageCache(Class<?> testClass) throws IOException {
DefaultFileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction();
TestDirectory testDirectory = TestDirectory.testDirectory(testClass, fileSystem);
Path dir = testDirectory.prepareDirectoryForTest("test");
ThreadPoolJobScheduler scheduler = new ThreadPoolJobScheduler();
PageCache pageCache = StandalonePageCacheFactory.createPageCache(fileSystem, scheduler, PageCacheTracer.NULL);
return new Fixture(pageCache, fileSystem, dir, scheduler);
}
use of org.neo4j.io.fs.DefaultFileSystemAbstraction in project neo4j by neo4j.
the class CheckConsistencyCommandIT method warnsOnUseOfDeprecatedOptions.
@Test
void warnsOnUseOfDeprecatedOptions() throws Exception {
ConsistencyCheckService consistencyCheckService = mock(ConsistencyCheckService.class);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintStream out = new PrintStream(baos);
CheckConsistencyCommand checkConsistencyCommand = new CheckConsistencyCommand(new ExecutionContext(homeDir, confPath, out, System.err, new DefaultFileSystemAbstraction()), consistencyCheckService);
DatabaseLayout databaseLayout = neo4jLayout.databaseLayout("mydb");
when(consistencyCheckService.runFullConsistencyCheck(eq(databaseLayout), any(Config.class), any(ProgressMonitorFactory.class), any(LogProvider.class), any(FileSystemAbstraction.class), eq(false), any(), any(ConsistencyFlags.class))).thenReturn(ConsistencyCheckService.Result.success(null, null));
CommandLine.populateCommand(checkConsistencyCommand, "--database=mydb", "--check-label-scan-store=true", "--check-relationship-type-scan-store=true", "--check-property-owners=true");
checkConsistencyCommand.execute();
// See that warnings were printed and that command was still run.
String log = baos.toString();
assertThat(log).contains("Option '--check-label-scan-store' has been deprecated and its value will be ignored");
assertThat(log).contains("Option '--check-relationship-type-scan-store' has been deprecated and its value will be ignored");
assertThat(log).contains("Option '--check-property-owners' has been deprecated and its value will be ignored");
verify(consistencyCheckService).runFullConsistencyCheck(eq(databaseLayout), any(Config.class), any(ProgressMonitorFactory.class), any(LogProvider.class), any(FileSystemAbstraction.class), eq(false), any(), any(ConsistencyFlags.class));
}
use of org.neo4j.io.fs.DefaultFileSystemAbstraction in project neo4j by neo4j.
the class DumpCommandIT method shouldRespectTheDatabaseLock.
@Test
void shouldRespectTheDatabaseLock() throws Exception {
Path databaseDirectory = homeDir.resolve("data/databases/foo");
DatabaseLayout databaseLayout = DatabaseLayout.ofFlat(databaseDirectory);
try (FileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction();
Locker locker = new DatabaseLocker(fileSystem, databaseLayout)) {
locker.checkLock();
CommandFailedException commandFailed = assertThrows(CommandFailedException.class, () -> execute("foo"));
assertEquals("The database is in use. Stop database 'foo' and try again.", commandFailed.getMessage());
}
}
use of org.neo4j.io.fs.DefaultFileSystemAbstraction in project neo4j by neo4j.
the class DumpCommandIT method shouldReportAHelpfulErrorIfWeDontHaveWritePermissionsForLock.
@Test
@DisabledOnOs(OS.WINDOWS)
@DisabledForRoot
void shouldReportAHelpfulErrorIfWeDontHaveWritePermissionsForLock() throws Exception {
DatabaseLayout databaseLayout = DatabaseLayout.ofFlat(databaseDirectory);
try (FileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction()) {
Path file = databaseLayout.databaseLockFile();
try (Closeable ignored = withPermissions(file, emptySet())) {
CommandFailedException commandFailed = assertThrows(CommandFailedException.class, () -> execute("foo"));
assertEquals("You do not have permission to dump the database.", commandFailed.getMessage());
}
}
}
Aggregations