Search in sources :

Example 36 with DependencyResolver

use of org.neo4j.common.DependencyResolver in project neo4j by neo4j.

the class TransactionStateMachineSPIProviderV4Test method managementService.

private DatabaseManagementService managementService(String databaseName) {
    DatabaseManagementService managementService = mock(DatabaseManagementService.class);
    GraphDatabaseFacade databaseFacade = mock(GraphDatabaseFacade.class);
    final DependencyResolver dependencyResolver = mock(DependencyResolver.class);
    GraphDatabaseQueryService queryService = mock(GraphDatabaseQueryService.class);
    when(databaseFacade.isAvailable(anyLong())).thenReturn(true);
    when(managementService.database(databaseName)).thenReturn(databaseFacade);
    when(databaseFacade.getDependencyResolver()).thenReturn(dependencyResolver);
    when(dependencyResolver.resolveDependency(GraphDatabaseQueryService.class)).thenReturn(queryService);
    when(dependencyResolver.resolveDependency(Database.class)).thenReturn(mock(Database.class));
    when(queryService.getDependencyResolver()).thenReturn(dependencyResolver);
    return managementService;
}
Also used : GraphDatabaseQueryService(org.neo4j.kernel.GraphDatabaseQueryService) Database(org.neo4j.kernel.database.Database) GraphDatabaseFacade(org.neo4j.kernel.impl.factory.GraphDatabaseFacade) DatabaseManagementService(org.neo4j.dbms.api.DatabaseManagementService) DependencyResolver(org.neo4j.common.DependencyResolver)

Example 37 with DependencyResolver

use of org.neo4j.common.DependencyResolver in project neo4j by neo4j.

the class UniqueIndexRecoveryTest method rotateLogAndCheckPoint.

private void rotateLogAndCheckPoint() throws IOException {
    DependencyResolver resolver = db.getDependencyResolver();
    resolver.resolveDependency(LogRotation.class).rotateLogFile(LogAppendEvent.NULL);
    resolver.resolveDependency(CheckPointer.class).forceCheckPoint(new SimpleTriggerInfo("test"));
}
Also used : SimpleTriggerInfo(org.neo4j.kernel.impl.transaction.log.checkpoint.SimpleTriggerInfo) CheckPointer(org.neo4j.kernel.impl.transaction.log.checkpoint.CheckPointer) LogRotation(org.neo4j.kernel.impl.transaction.log.rotation.LogRotation) DependencyResolver(org.neo4j.common.DependencyResolver)

Example 38 with DependencyResolver

use of org.neo4j.common.DependencyResolver in project neo4j by neo4j.

the class BuiltInDbmsProcedures method listFunctions.

@Deprecated(since = "4.3.0", forRemoval = true)
@SystemProcedure
@Description("List all functions in the DBMS.")
@Procedure(name = "dbms.functions", mode = DBMS, deprecatedBy = "SHOW FUNCTIONS command")
public Stream<FunctionResult> listFunctions() {
    DependencyResolver resolver = graph.getDependencyResolver();
    QueryExecutionEngine queryExecutionEngine = resolver.resolveDependency(QueryExecutionEngine.class);
    List<FunctionInformation> providedLanguageFunctions = queryExecutionEngine.getProvidedLanguageFunctions();
    var globalProcedures = resolver.resolveDependency(GlobalProcedures.class);
    // gets you all functions provided by the query language
    Stream<FunctionResult> languageFunctions = providedLanguageFunctions.stream().map(FunctionResult::new);
    // gets you all non-aggregating functions that are registered in the db (incl. those from libs like apoc)
    Stream<FunctionResult> loadedFunctions = globalProcedures.getAllNonAggregatingFunctions().map(f -> new FunctionResult(f, false));
    // gets you all aggregation functions that are registered in the db (incl. those from libs like apoc)
    Stream<FunctionResult> loadedAggregationFunctions = globalProcedures.getAllAggregatingFunctions().map(f -> new FunctionResult(f, true));
    return Stream.concat(Stream.concat(languageFunctions, loadedFunctions), loadedAggregationFunctions).sorted(Comparator.comparing(a -> a.name));
}
Also used : QueryExecutionEngine(org.neo4j.kernel.impl.query.QueryExecutionEngine) SystemGraphComponent(org.neo4j.dbms.database.SystemGraphComponent) Log(org.neo4j.logging.Log) StoreIdProvider(org.neo4j.storageengine.api.StoreIdProvider) Status(org.neo4j.kernel.api.exceptions.Status) FunctionInformation(org.neo4j.kernel.impl.query.FunctionInformation) Config(org.neo4j.configuration.Config) ProcedureException(org.neo4j.internal.kernel.api.exceptions.ProcedureException) ProceduresTimeFormatHelper.formatTime(org.neo4j.procedure.builtin.ProceduresTimeFormatHelper.formatTime) ProcedureCallFailed(org.neo4j.kernel.api.exceptions.Status.Procedure.ProcedureCallFailed) InternalTransaction(org.neo4j.kernel.impl.coreapi.InternalTransaction) FabricTransaction(org.neo4j.fabric.transaction.FabricTransaction) SystemProcedure(org.neo4j.kernel.api.procedure.SystemProcedure) Collections.singletonList(java.util.Collections.singletonList) Capability(org.neo4j.capabilities.Capability) UserFunctionSignature(org.neo4j.internal.kernel.api.procs.UserFunctionSignature) Map(java.util.Map) SecurityContext(org.neo4j.internal.kernel.api.security.SecurityContext) ExecutingQuery(org.neo4j.kernel.api.query.ExecutingQuery) NamedDatabaseId(org.neo4j.kernel.database.NamedDatabaseId) Transaction(org.neo4j.graphdb.Transaction) Procedure(org.neo4j.procedure.Procedure) DatabaseIdRepository(org.neo4j.kernel.database.DatabaseIdRepository) Dependencies(org.neo4j.collection.Dependencies) TrackedNetworkConnection(org.neo4j.kernel.api.net.TrackedNetworkConnection) Set(java.util.Set) SHOW_TRANSACTION(org.neo4j.internal.kernel.api.security.PrivilegeAction.SHOW_TRANSACTION) Collectors(java.util.stream.Collectors) ZoneId(java.time.ZoneId) DatabaseContext(org.neo4j.dbms.database.DatabaseContext) Internal(org.neo4j.procedure.Internal) String.format(java.lang.String.format) GraphDatabaseAPI(org.neo4j.kernel.internal.GraphDatabaseAPI) List(java.util.List) Stream(java.util.stream.Stream) UserSegment(org.neo4j.internal.kernel.api.security.UserSegment) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) Optional(java.util.Optional) Name(org.neo4j.procedure.Name) StoreIdDecodeUtils.decodeId(org.neo4j.procedure.builtin.StoreIdDecodeUtils.decodeId) DatabaseManagementService(org.neo4j.dbms.api.DatabaseManagementService) Admin(org.neo4j.procedure.Admin) DatabaseManager(org.neo4j.dbms.database.DatabaseManager) FabricStatementLifecycles(org.neo4j.fabric.executor.FabricStatementLifecycles) KernelTransactions(org.neo4j.kernel.impl.api.KernelTransactions) QueryExecutionEngine(org.neo4j.kernel.impl.query.QueryExecutionEngine) GraphDatabaseSettings(org.neo4j.configuration.GraphDatabaseSettings) Context(org.neo4j.procedure.Context) UNINITIALIZED(org.neo4j.dbms.database.SystemGraphComponent.Status.UNINITIALIZED) HashMap(java.util.HashMap) CapabilitiesService(org.neo4j.capabilities.CapabilitiesService) SYSTEM_DATABASE_NAME(org.neo4j.configuration.GraphDatabaseSettings.SYSTEM_DATABASE_NAME) ArrayList(java.util.ArrayList) GlobalProcedures(org.neo4j.kernel.api.procedure.GlobalProcedures) HashSet(java.util.HashSet) WRITE(org.neo4j.procedure.Mode.WRITE) SystemGraphComponents(org.neo4j.dbms.database.SystemGraphComponents) Objects.requireNonNull(java.util.Objects.requireNonNull) DBMS(org.neo4j.procedure.Mode.DBMS) DependencyResolver(org.neo4j.common.DependencyResolver) TransactionManager(org.neo4j.fabric.transaction.TransactionManager) QuerySnapshot(org.neo4j.kernel.api.query.QuerySnapshot) REQUIRES_UPGRADE(org.neo4j.dbms.database.SystemGraphComponent.Status.REQUIRES_UPGRADE) READ(org.neo4j.procedure.Mode.READ) InvalidArgumentsException(org.neo4j.kernel.api.exceptions.InvalidArgumentsException) Description(org.neo4j.procedure.Description) KernelTransactionHandle(org.neo4j.kernel.api.KernelTransactionHandle) TERMINATE_TRANSACTION(org.neo4j.internal.kernel.api.security.PrivilegeAction.TERMINATE_TRANSACTION) ProcedureCallContext(org.neo4j.internal.kernel.api.procs.ProcedureCallContext) Collectors.toList(java.util.stream.Collectors.toList) NetworkConnectionTracker(org.neo4j.kernel.api.net.NetworkConnectionTracker) KernelTransaction(org.neo4j.kernel.api.KernelTransaction) ProcedureSignature(org.neo4j.internal.kernel.api.procs.ProcedureSignature) ALL(org.neo4j.internal.kernel.api.security.AdminActionOnResource.DatabaseScope.ALL) Comparator(java.util.Comparator) AdminActionOnResource(org.neo4j.internal.kernel.api.security.AdminActionOnResource) Collections(java.util.Collections) DatabaseScope(org.neo4j.internal.kernel.api.security.AdminActionOnResource.DatabaseScope) FunctionInformation(org.neo4j.kernel.impl.query.FunctionInformation) DependencyResolver(org.neo4j.common.DependencyResolver) Description(org.neo4j.procedure.Description) SystemProcedure(org.neo4j.kernel.api.procedure.SystemProcedure) SystemProcedure(org.neo4j.kernel.api.procedure.SystemProcedure) Procedure(org.neo4j.procedure.Procedure)

Example 39 with DependencyResolver

use of org.neo4j.common.DependencyResolver in project neo4j by neo4j.

the class DatabaseAvailabilityIT method notConfusingMessageOnDatabaseNonAvailability.

@Test
void notConfusingMessageOnDatabaseNonAvailability() {
    DependencyResolver dependencyResolver = database.getDependencyResolver();
    DatabaseManager<?> databaseManager = getDatabaseManager(dependencyResolver);
    DatabaseContext databaseContext = databaseManager.getDatabaseContext(defaultNamedDatabaseId).get();
    DatabaseAvailability databaseAvailability = databaseContext.database().getDependencyResolver().resolveDependency(DatabaseAvailability.class);
    databaseAvailability.stop();
    TransactionFailureException exception = assertThrows(TransactionFailureException.class, () -> database.beginTx());
    assertEquals("Timeout waiting for database to become available and allow new transactions. Waited 1s. 1 reasons for blocking: Database unavailable.", exception.getMessage());
}
Also used : DatabaseContext(org.neo4j.dbms.database.DatabaseContext) TransactionFailureException(org.neo4j.graphdb.TransactionFailureException) DatabaseAvailability(org.neo4j.kernel.availability.DatabaseAvailability) DependencyResolver(org.neo4j.common.DependencyResolver) Test(org.junit.jupiter.api.Test)

Example 40 with DependencyResolver

use of org.neo4j.common.DependencyResolver in project neo4j by neo4j.

the class BoltV3TransportIT method getLastClosedTransactionId.

private long getLastClosedTransactionId() {
    DependencyResolver resolver = ((GraphDatabaseAPI) server.graphDatabaseService()).getDependencyResolver();
    TransactionIdStore txIdStore = resolver.resolveDependency(TransactionIdStore.class);
    return txIdStore.getLastClosedTransactionId();
}
Also used : TransactionIdStore(org.neo4j.storageengine.api.TransactionIdStore) GraphDatabaseAPI(org.neo4j.kernel.internal.GraphDatabaseAPI) DependencyResolver(org.neo4j.common.DependencyResolver)

Aggregations

DependencyResolver (org.neo4j.common.DependencyResolver)41 GraphDatabaseAPI (org.neo4j.kernel.internal.GraphDatabaseAPI)13 Config (org.neo4j.configuration.Config)12 Test (org.junit.jupiter.api.Test)10 DatabaseManagementService (org.neo4j.dbms.api.DatabaseManagementService)8 DatabaseContext (org.neo4j.dbms.database.DatabaseContext)6 GraphDatabaseFacade (org.neo4j.kernel.impl.factory.GraphDatabaseFacade)5 TestDatabaseManagementServiceBuilder (org.neo4j.test.TestDatabaseManagementServiceBuilder)5 GraphDatabaseQueryService (org.neo4j.kernel.GraphDatabaseQueryService)4 KernelTransaction (org.neo4j.kernel.api.KernelTransaction)4 IndexingService (org.neo4j.kernel.impl.api.index.IndexingService)4 SystemGraphComponents (org.neo4j.dbms.database.SystemGraphComponents)3 Transaction (org.neo4j.graphdb.Transaction)3 IdGeneratorFactory (org.neo4j.internal.id.IdGeneratorFactory)3 PageCache (org.neo4j.io.pagecache.PageCache)3 CheckPointer (org.neo4j.kernel.impl.transaction.log.checkpoint.CheckPointer)3 SimpleTriggerInfo (org.neo4j.kernel.impl.transaction.log.checkpoint.SimpleTriggerInfo)3 TokenHolders (org.neo4j.token.TokenHolders)3 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2