Search in sources :

Example 1 with NetworkConnectionTracker

use of org.neo4j.kernel.api.net.NetworkConnectionTracker in project neo4j by neo4j.

the class SocketTransportTest method shouldManageChannelsInChannelInitializer.

@Test
void shouldManageChannelsInChannelInitializer() {
    NetworkConnectionTracker connectionTracker = mock(NetworkConnectionTracker.class);
    SocketTransport socketTransport = newSocketTransport(connectionTracker, NO_THROTTLE);
    EmbeddedChannel channel = new EmbeddedChannel(socketTransport.channelInitializer());
    ArgumentCaptor<TrackedNetworkConnection> captor = ArgumentCaptor.forClass(TrackedNetworkConnection.class);
    verify(connectionTracker).add(captor.capture());
    verify(connectionTracker, never()).remove(any());
    channel.close();
    verify(connectionTracker).remove(captor.getValue());
}
Also used : TrackedNetworkConnection(org.neo4j.kernel.api.net.TrackedNetworkConnection) EmbeddedChannel(io.netty.channel.embedded.EmbeddedChannel) NetworkConnectionTracker(org.neo4j.kernel.api.net.NetworkConnectionTracker) Test(org.junit.jupiter.api.Test)

Example 2 with NetworkConnectionTracker

use of org.neo4j.kernel.api.net.NetworkConnectionTracker in project neo4j by neo4j.

the class BuiltInDbmsProcedures method listConnections.

@SystemProcedure
@Description("List all accepted network connections at this instance that are visible to the user.")
@Procedure(name = "dbms.listConnections", mode = DBMS)
public Stream<ListConnectionResult> listConnections() {
    NetworkConnectionTracker connectionTracker = getConnectionTracker();
    ZoneId timeZone = getConfiguredTimeZone();
    return connectionTracker.activeConnections().stream().filter(connection -> isAdminOrSelf(connection.username())).map(connection -> new ListConnectionResult(connection, timeZone));
}
Also used : 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) ZoneId(java.time.ZoneId) NetworkConnectionTracker(org.neo4j.kernel.api.net.NetworkConnectionTracker) Description(org.neo4j.procedure.Description) SystemProcedure(org.neo4j.kernel.api.procedure.SystemProcedure) SystemProcedure(org.neo4j.kernel.api.procedure.SystemProcedure) Procedure(org.neo4j.procedure.Procedure)

Aggregations

EmbeddedChannel (io.netty.channel.embedded.EmbeddedChannel)1 String.format (java.lang.String.format)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 ZoneId (java.time.ZoneId)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 Collections.singletonList (java.util.Collections.singletonList)1 Comparator (java.util.Comparator)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 Objects.requireNonNull (java.util.Objects.requireNonNull)1 Optional (java.util.Optional)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 Collectors.toList (java.util.stream.Collectors.toList)1 Stream (java.util.stream.Stream)1 Test (org.junit.jupiter.api.Test)1 CapabilitiesService (org.neo4j.capabilities.CapabilitiesService)1