use of org.neo4j.dbms.api.DatabaseManagementService in project neo4j by neo4j.
the class DumpCommandIT method putStoreInDirectory.
private void putStoreInDirectory(Config config, Path databaseDirectory) {
String databaseName = databaseDirectory.getFileName().toString();
DatabaseManagementService managementService = new TestDatabaseManagementServiceBuilder(databaseDirectory.getParent().getParent().getParent()).setConfig(config).setConfig(default_database, databaseName).build();
managementService.shutdown();
}
use of org.neo4j.dbms.api.DatabaseManagementService in project neo4j by neo4j.
the class MemoryRecommendationsCommandTest method createDatabaseWithNativeIndexes.
private static void createDatabaseWithNativeIndexes(Path homeDirectory, String databaseName) {
// Create one index for every provider that we have
for (SchemaIndex schemaIndex : SchemaIndex.values()) {
DatabaseManagementService managementService = new TestDatabaseManagementServiceBuilder(homeDirectory).setConfig(default_schema_provider, schemaIndex.providerName()).setConfig(default_database, databaseName).build();
GraphDatabaseService db = managementService.database(databaseName);
String key = "key-" + schemaIndex.name();
try {
Label labelOne = Label.label("one");
try (Transaction tx = db.beginTx()) {
tx.schema().indexFor(labelOne).on(key).create();
tx.commit();
}
try (Transaction tx = db.beginTx()) {
RandomValues randomValues = RandomValues.create();
for (int i = 0; i < 10_000; i++) {
tx.createNode(labelOne).setProperty(key, randomValues.nextValue().asObject());
}
tx.commit();
}
} finally {
managementService.shutdown();
}
}
}
use of org.neo4j.dbms.api.DatabaseManagementService in project neo4j by neo4j.
the class PushToCloudCommandTest method createDbAndDump.
private void createDbAndDump() {
Config config = Config.newBuilder().set(GraphDatabaseSettings.neo4j_home, homeDir.toAbsolutePath()).set(default_database, DBNAME).build();
DatabaseLayout databaseLayout = DatabaseLayout.of(config);
Neo4jLayout neo4jLayout = databaseLayout.getNeo4jLayout();
DatabaseManagementService managementService = new TestDatabaseManagementServiceBuilder(neo4jLayout.homeDirectory()).setConfig(config).build();
managementService.database(databaseLayout.getDatabaseName());
managementService.shutdown();
dump = directory.file("some-archive.dump");
new RealDumpCreator(ctx).dumpDatabase(DBNAME, dump);
}
use of org.neo4j.dbms.api.DatabaseManagementService in project neo4j by neo4j.
the class IndexConfigMigrationIT method shouldHaveCorrectDataAndIndexConfiguration.
@Test
void shouldHaveCorrectDataAndIndexConfiguration() throws IOException, IndexNotFoundKernelException {
Path databaseDir = databaseLayout.databaseDirectory();
unzip(getClass(), ZIP_FILE_3_5, databaseDir);
// when
DatabaseManagementServiceBuilder builder = new TestDatabaseManagementServiceBuilder(testDirectory.homePath()).setConfig(GraphDatabaseSettings.allow_upgrade, true);
DatabaseManagementService dbms = builder.build();
try {
GraphDatabaseAPI db = (GraphDatabaseAPI) dbms.database(DEFAULT_DATABASE_NAME);
Set<CoordinateReferenceSystem> allCRS = Iterables.asSet(all());
try (Transaction tx = db.beginTx()) {
validateIndexes(tx);
for (Node node : tx.getAllNodes()) {
hasLabels(node, label1, label2, label3, label4);
Object property = node.getProperty(propKey);
if (property instanceof PointValue) {
allCRS.remove(((PointValue) property).getCoordinateReferenceSystem());
}
}
assertTrue(allCRS.isEmpty(), "Expected all CRS to be represented in store, but missing " + allCRS);
assertIndexConfiguration(db, tx);
assertFulltextIndexConfiguration(db, tx);
tx.commit();
}
} finally {
dbms.shutdown();
}
// Assert old index files has been removed
Path baseSchemaIndexFolder = IndexDirectoryStructure.baseSchemaIndexFolder(databaseDir);
Set<Path> retiredIndexProviderDirectories = Set.of(baseSchemaIndexFolder.resolve("lucene"), baseSchemaIndexFolder.resolve("lucene-1.0"), baseSchemaIndexFolder.resolve("lucene_native-1.0"), baseSchemaIndexFolder.resolve("lucene_native-2.0"));
try (Stream<Path> list = Files.list(baseSchemaIndexFolder)) {
list.forEach(indexProviderDirectory -> assertFalse(retiredIndexProviderDirectories.contains(indexProviderDirectory), "Expected old index provider directories to be deleted during migration but store still had directory " + indexProviderDirectory));
}
}
use of org.neo4j.dbms.api.DatabaseManagementService in project neo4j by neo4j.
the class IndexSamplingIntegrationTest method fetchIndexSamplingValues.
private IndexSample fetchIndexSamplingValues() throws IndexNotFoundKernelException, TransactionFailureException {
DatabaseManagementService managementService = null;
try {
// Then
managementService = new TestDatabaseManagementServiceBuilder(databaseLayout).build();
GraphDatabaseService db = managementService.database(DEFAULT_DATABASE_NAME);
GraphDatabaseAPI api = (GraphDatabaseAPI) db;
Kernel kernel = api.getDependencyResolver().resolveDependency(Kernel.class);
try (KernelTransaction tx = kernel.beginTransaction(EXPLICIT, AUTH_DISABLED)) {
return tx.schemaRead().indexSample(indexId(tx));
}
} finally {
if (managementService != null) {
managementService.shutdown();
}
}
}
Aggregations