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);
}
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);
}
}
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);
}
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;
}
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);
}
}
Aggregations