Search in sources :

Example 1 with DefaultServerRequest

use of com.navercorp.pinpoint.io.request.DefaultServerRequest in project pinpoint by naver.

the class DefaultServerRequestFactory method newServerRequest.

@Override
public <T> ServerRequest<T> newServerRequest(Message<T> message) throws StatusException {
    final Context current = Context.current();
    final Header header = ServerContext.getAgentInfo(current);
    if (header == null) {
        throw Status.INTERNAL.withDescription("Not found request header").asException();
    }
    final TransportMetadata transportMetadata = ServerContext.getTransportMetadata(current);
    if (transportMetadata == null) {
        throw Status.INTERNAL.withDescription("Not found transportMetadata").asException();
    }
    InetSocketAddress inetSocketAddress = transportMetadata.getRemoteAddress();
    ServerRequest<T> request = new DefaultServerRequest<>(message, inetSocketAddress.getHostString(), inetSocketAddress.getPort());
    return request;
}
Also used : ServerContext(com.navercorp.pinpoint.grpc.server.ServerContext) Context(io.grpc.Context) Header(com.navercorp.pinpoint.grpc.Header) TransportMetadata(com.navercorp.pinpoint.grpc.server.TransportMetadata) InetSocketAddress(java.net.InetSocketAddress) DefaultServerRequest(com.navercorp.pinpoint.io.request.DefaultServerRequest)

Aggregations

Header (com.navercorp.pinpoint.grpc.Header)1 ServerContext (com.navercorp.pinpoint.grpc.server.ServerContext)1 TransportMetadata (com.navercorp.pinpoint.grpc.server.TransportMetadata)1 DefaultServerRequest (com.navercorp.pinpoint.io.request.DefaultServerRequest)1 Context (io.grpc.Context)1 InetSocketAddress (java.net.InetSocketAddress)1