use of org.neo4j.io.fs.DefaultFileSystemAbstraction in project neo4j by neo4j.
the class DumpCommandTest method shouldReportAHelpfulErrorIfWeDontHaveWritePermissionsForLock.
@Test
public void shouldReportAHelpfulErrorIfWeDontHaveWritePermissionsForLock() throws Exception {
assumeFalse("We haven't found a way to reliably tests permissions on Windows", SystemUtils.IS_OS_WINDOWS);
try (FileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction();
StoreLocker storeLocker = new StoreLocker(fileSystem)) {
storeLocker.checkLock(databaseDirectory.toFile());
try (Closeable ignored = withPermissions(databaseDirectory.resolve(StoreLocker.STORE_LOCK_FILENAME), emptySet())) {
execute("foo.db");
fail("expected exception");
} catch (CommandFailed e) {
assertThat(e.getMessage(), equalTo("you do not have permission to dump the database -- is Neo4j " + "running as a different user?"));
}
}
}
use of org.neo4j.io.fs.DefaultFileSystemAbstraction in project neo4j by neo4j.
the class BatchInserters method inserter.
/**
* Get a {@link BatchInserter} given a store directory.
*
* @param storeDir the store directory
* @return a new {@link BatchInserter}
* @throws IOException if there is an IO error
*/
public static BatchInserter inserter(File storeDir) throws IOException {
DefaultFileSystemAbstraction fileSystem = createFileSystem();
BatchInserter batchInserter = inserter(storeDir, fileSystem, stringMap());
return new FileSystemClosingBatchInserter(batchInserter, (IndexConfigStoreProvider) batchInserter, fileSystem);
}
use of org.neo4j.io.fs.DefaultFileSystemAbstraction in project neo4j by neo4j.
the class BatchInserters method inserter.
public static BatchInserter inserter(File storeDir, Map<String, String> config) throws IOException {
DefaultFileSystemAbstraction fileSystem = createFileSystem();
BatchInserter inserter = inserter(storeDir, fileSystem, config, loadKernelExtension());
return new FileSystemClosingBatchInserter(inserter, (IndexConfigStoreProvider) inserter, fileSystem);
}
use of org.neo4j.io.fs.DefaultFileSystemAbstraction in project neo4j by neo4j.
the class IndexWorkSyncTransactionApplicationStressIT method shouldApplyIndexUpdatesInWorkSyncedBatches.
@Test
public void shouldApplyIndexUpdatesInWorkSyncedBatches() throws Exception {
// GIVEN
long duration = parseTimeMillis.apply(System.getProperty(getClass().getName() + ".duration", "2s"));
int numThreads = Integer.getInteger(getClass().getName() + ".numThreads", Runtime.getRuntime().availableProcessors());
DefaultFileSystemAbstraction fs = fileSystemRule.get();
PageCache pageCache = pageCacheRule.getPageCache(fs);
CollectingIndexUpdateListener index = new CollectingIndexUpdateListener();
RecordStorageEngine storageEngine = storageEngineRule.getWith(fs, pageCache, DatabaseLayout.ofFlat(directory.directory(DEFAULT_DATABASE_NAME))).indexUpdateListener(index).build();
storageEngine.apply(tx(singletonList(Commands.createIndexRule(DESCRIPTOR, 1, descriptor))), EXTERNAL);
// WHEN
Workers<Worker> workers = new Workers<>(getClass().getSimpleName());
final AtomicBoolean end = new AtomicBoolean();
for (int i = 0; i < numThreads; i++) {
workers.start(new Worker(i, end, storageEngine, 10, index));
}
// let the threads hammer the storage engine for some time
Thread.sleep(duration);
end.set(true);
// THEN (assertions as part of the workers applying transactions)
workers.awaitAndThrowOnError();
}
use of org.neo4j.io.fs.DefaultFileSystemAbstraction in project neo4j by neo4j.
the class IndexConfigMigrationIT method create3_5Database.
@Disabled("Here as reference for how 3.5 db was created")
@Test
void create3_5Database() throws Exception {
Path storeDir = tempStoreDirectory();
DatabaseManagementServiceBuilder builder = new TestDatabaseManagementServiceBuilder(storeDir);
setSpatialConfig(builder);
DatabaseManagementService dbms = builder.build();
GraphDatabaseService db = dbms.database(DEFAULT_DATABASE_NAME);
createIndex(db, NATIVE_BTREE10.providerName(), label1);
// createIndex( db, NATIVE20.providerName(), label2 ); // <- Those index providers are removed in 4.0, but here for reference.
// createIndex( db, NATIVE10.providerName(), label3 );
// createIndex( db, LUCENE10.providerName(), label4 );
createSpatialData(db, label1, label2, label3, label4);
for (FulltextIndexDescription fulltextIndex : FulltextIndexDescription.values()) {
createFulltextIndex(db, fulltextIndex.indexProcedure, fulltextIndex.indexName, fulltextIndex.tokenName, propKey, fulltextIndex.configMap);
}
dbms.shutdown();
Path zipFile = storeDir.resolveSibling(storeDir.getFileName().toString() + ".zip");
ZipUtils.zip(new DefaultFileSystemAbstraction(), storeDir, zipFile);
System.out.println("Db created in " + zipFile.toAbsolutePath());
}
Aggregations