Search in sources :

Example 6 with TransportMetadata

use of com.navercorp.pinpoint.grpc.server.TransportMetadata in project pinpoint by naver.

the class DefaultPingEventHandler method connect.

@Override
public void connect() {
    final TransportMetadata transportMetadata = ServerContext.getTransportMetadata();
    if (transportMetadata == null) {
        logger.info("Skip connect event handle of ping, not found TransportMetadata. header={}", ServerContext.getAgentInfo());
        return;
    }
    final Long transportId = transportMetadata.getTransportId();
    final Header header = ServerContext.getAgentInfo();
    final PingSession pingSession = new PingSession(transportId, header);
    pingSession.setLastPingTimeMillis(System.currentTimeMillis());
    final PingSession oldSession = pingSessionRegistry.add(pingSession.getId(), pingSession);
    if (oldSession != null) {
        logger.warn("Duplicated ping session old={}, new={}", oldSession, pingSession);
    }
    lifecycleListener.connect(pingSession);
}
Also used : Header(com.navercorp.pinpoint.grpc.Header) TransportMetadata(com.navercorp.pinpoint.grpc.server.TransportMetadata)

Example 7 with TransportMetadata

use of com.navercorp.pinpoint.grpc.server.TransportMetadata in project pinpoint by naver.

the class DefaultPingEventHandler method update.

@Override
public void update(final short serviceType) {
    final TransportMetadata transportMetadata = ServerContext.getTransportMetadata();
    if (transportMetadata == null) {
        logger.info("Skip update event handle of ping, not found TransportMetadata. header={}", ServerContext.getAgentInfo());
        return;
    }
    final PingSession pingSession = pingSessionRegistry.get(transportMetadata.getTransportId());
    if (pingSession == null) {
        logger.info("Skip update event handle of ping, not found ping session. transportMetadata={}", transportMetadata);
        return;
    }
    pingSession.setServiceType(serviceType);
    if (logger.isDebugEnabled()) {
        logger.debug("Update ping session. PingSession={}", pingSession);
    }
    if (!pingSession.isUpdated()) {
        lifecycleListener.connect(pingSession);
        pingSession.setUpdated(true);
    }
}
Also used : TransportMetadata(com.navercorp.pinpoint.grpc.server.TransportMetadata)

Example 8 with TransportMetadata

use of com.navercorp.pinpoint.grpc.server.TransportMetadata in project pinpoint by naver.

the class DefaultPingEventHandler method ping.

@Override
public void ping() {
    final TransportMetadata transportMetadata = ServerContext.getTransportMetadata();
    if (transportMetadata == null) {
        logger.info("Skip ping event handle of ping, not found TransportMetadata. header={}", ServerContext.getAgentInfo());
        return;
    }
    final PingSession pingSession = pingSessionRegistry.get(transportMetadata.getTransportId());
    if (pingSession == null) {
        logger.info("Skip ping event handle of ping, not found ping session. transportMetadata={}", transportMetadata);
        return;
    }
    // Avoid too frequent updates.
    final long currentTimeMillis = System.currentTimeMillis();
    if (PING_MIN_TIME_MILLIS < (currentTimeMillis - pingSession.getLastPingTimeMillis())) {
        return;
    }
    pingSession.setLastPingTimeMillis(currentTimeMillis);
    lifecycleListener.handshake(pingSession);
}
Also used : TransportMetadata(com.navercorp.pinpoint.grpc.server.TransportMetadata)

Example 9 with TransportMetadata

use of com.navercorp.pinpoint.grpc.server.TransportMetadata in project pinpoint by naver.

the class ChannelzServerTransportFilter method transportReady.

@Override
public Attributes transportReady(Attributes transportAttrs) {
    final TransportMetadata transportMetadata = getTransportMetadata(transportAttrs);
    final long logId = transportMetadata.getLogId();
    final InetSocketAddress remoteAddress = transportMetadata.getRemoteAddress();
    final InetSocketAddress localAddress = transportMetadata.getLocalAddress();
    if (logger.isDebugEnabled()) {
        logger.debug("Add logId:{} remoteAddress:{} localAddress:{}", logId, SocketAddressUtils.toString(remoteAddress), SocketAddressUtils.toString(localAddress));
    }
    registry.addSocket(logId, remoteAddress, localAddress);
    return transportAttrs;
}
Also used : TransportMetadata(com.navercorp.pinpoint.grpc.server.TransportMetadata) InetSocketAddress(java.net.InetSocketAddress)

Example 10 with TransportMetadata

use of com.navercorp.pinpoint.grpc.server.TransportMetadata in project pinpoint by naver.

the class ChannelzServerTransportFilter method transportTerminated.

@Override
public void transportTerminated(Attributes transportAttrs) {
    // transport is not ready
    if (transportAttrs == null) {
        return;
    }
    final TransportMetadata transportMetadata = getTransportMetadata(transportAttrs);
    final InetSocketAddress remoteAddress = transportMetadata.getRemoteAddress();
    final Long logId = registry.removeSocket(remoteAddress);
    if (logger.isDebugEnabled()) {
        logger.debug("Remove logId:{} remoteAddress:{}", logId, remoteAddress);
    }
}
Also used : TransportMetadata(com.navercorp.pinpoint.grpc.server.TransportMetadata) InetSocketAddress(java.net.InetSocketAddress)

Aggregations

TransportMetadata (com.navercorp.pinpoint.grpc.server.TransportMetadata)10 InetSocketAddress (java.net.InetSocketAddress)6 Header (com.navercorp.pinpoint.grpc.Header)5 ZookeeperClusterService (com.navercorp.pinpoint.collector.cluster.zookeeper.ZookeeperClusterService)3 ZookeeperProfilerClusterManager (com.navercorp.pinpoint.collector.cluster.zookeeper.ZookeeperProfilerClusterManager)3 GrpcCommandService (com.navercorp.pinpoint.collector.receiver.grpc.service.command.GrpcCommandService)3 DefaultTransportMetadata (com.navercorp.pinpoint.grpc.server.DefaultTransportMetadata)3 PCmdMessage (com.navercorp.pinpoint.grpc.trace.PCmdMessage)3 Test (org.junit.Test)3 ServerContext (com.navercorp.pinpoint.grpc.server.ServerContext)1 PCmdRequest (com.navercorp.pinpoint.grpc.trace.PCmdRequest)1 DefaultServerRequest (com.navercorp.pinpoint.io.request.DefaultServerRequest)1 Context (io.grpc.Context)1