use of org.neo4j.kernel.api.Kernel in project neo4j by neo4j.
the class CheckerTestBase method tx.
/**
* Convenience for a transaction that auto-commits.
*/
AutoCloseable tx() throws TransactionFailureException {
Kernel kernel = db.getDependencyResolver().resolveDependency(Kernel.class);
KernelTransaction tx = kernel.beginTransaction(KernelTransaction.Type.EXPLICIT, LoginContext.AUTH_DISABLED);
return () -> {
tx.commit();
tx.close();
};
}
use of org.neo4j.kernel.api.Kernel in project neo4j by neo4j.
the class IndexPopulationJobTest method before.
@BeforeEach
void before() throws Exception {
kernel = db.getDependencyResolver().resolveDependency(Kernel.class);
tokens = db.getDependencyResolver().resolveDependency(TokenNameLookup.class);
tokenHolders = db.getDependencyResolver().resolveDependency(TokenHolders.class);
stateHolder = new DatabaseSchemaState(NullLogProvider.getInstance());
IndexingService indexingService = db.getDependencyResolver().resolveDependency(IndexingService.class);
indexStoreView = db.getDependencyResolver().resolveDependency(IndexStoreViewFactory.class).createTokenIndexStoreView(indexingService::getIndexProxy);
indexStatisticsStore = db.getDependencyResolver().resolveDependency(IndexStatisticsStore.class);
jobScheduler = db.getDependencyResolver().resolveDependency(JobScheduler.class);
try (KernelTransaction tx = kernel.beginTransaction(IMPLICIT, LoginContext.AUTH_DISABLED)) {
labelId = tx.tokenWrite().labelGetOrCreateForName(FIRST.name());
tx.tokenWrite().labelGetOrCreateForName(SECOND.name());
tx.commit();
}
}
use of org.neo4j.kernel.api.Kernel in project neo4j by neo4j.
the class CompositeUniquenessConstraintValidationIT method setup.
@BeforeEach
public void setup() throws Exception {
kernel = db.getDependencyResolver().resolveDependency(Kernel.class);
newTransaction();
// This transaction allocates all the tokens we'll need in this test.
// We rely on token ids being allocated sequentially, from and including zero.
TokenWrite tokenWrite = transaction.tokenWrite();
tokenWrite.labelGetOrCreateForName("Label0");
label = tokenWrite.labelGetOrCreateForName("Label1");
propIds = new int[10];
for (int i = 0; i < propIds.length; i++) {
propIds[i] = tokenWrite.propertyKeyGetOrCreateForName("prop" + i);
}
commit();
}
use of org.neo4j.kernel.api.Kernel in project neo4j by neo4j.
the class IsolatedTransactionTokenCreator method createToken.
@Override
public synchronized int createToken(String name, boolean internal) throws KernelException {
Kernel kernel = kernelSupplier.get();
try (KernelTransaction tx = kernel.beginTransaction(Type.IMPLICIT, AUTH_DISABLED)) {
int id = createKey(tx, name, internal);
tx.commit();
return id;
}
}
use of org.neo4j.kernel.api.Kernel 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