Search in sources :

Example 81 with Endpoint

use of com.google.cloud.aiplatform.v1.Endpoint in project java by wavefrontHQ.

the class ZipkinPortUnificationHandlerTest method testZipkinDurationSampler.

@Test
public void testZipkinDurationSampler() throws Exception {
    ZipkinPortUnificationHandler handler = new ZipkinPortUnificationHandler("9411", new NoopHealthCheckManager(), mockTraceHandler, mockTraceSpanLogsHandler, null, () -> false, () -> false, null, new SpanSampler(new DurationSampler(5), () -> null), null, null);
    Endpoint localEndpoint1 = Endpoint.newBuilder().serviceName("frontend").ip("10.0.0.1").build();
    zipkin2.Span spanServer1 = zipkin2.Span.newBuilder().traceId("2822889fe47043bd").id("2822889fe47043bd").kind(zipkin2.Span.Kind.SERVER).name("getservice").timestamp(startTime * 1000).duration(4 * 1000).localEndpoint(localEndpoint1).putTag("http.method", "GET").putTag("http.url", "none+h1c://localhost:8881/").putTag("http.status_code", "200").addAnnotation(startTime * 1000, "start processing").build();
    zipkin2.Span spanServer2 = zipkin2.Span.newBuilder().traceId("3822889fe47043bd").id("3822889fe47043bd").kind(zipkin2.Span.Kind.SERVER).name("getservice").timestamp(startTime * 1000).duration(9 * 1000).localEndpoint(localEndpoint1).putTag("http.method", "GET").putTag("http.url", "none+h1c://localhost:8881/").putTag("http.status_code", "200").addAnnotation(startTime * 1000, "start processing").build();
    List<zipkin2.Span> zipkinSpanList = ImmutableList.of(spanServer1, spanServer2);
    SpanBytesEncoder encoder = SpanBytesEncoder.values()[1];
    ByteBuf content = Unpooled.copiedBuffer(encoder.encodeList(zipkinSpanList));
    // take care of mocks.
    // Reset mock
    reset(mockTraceHandler, mockTraceSpanLogsHandler);
    // Set Expectation
    Span expectedSpan2 = Span.newBuilder().setCustomer("dummy").setStartMillis(startTime).setDuration(9).setName("getservice").setSource(DEFAULT_SOURCE).setSpanId("00000000-0000-0000-3822-889fe47043bd").setTraceId("00000000-0000-0000-3822-889fe47043bd").setAnnotations(ImmutableList.of(new Annotation("zipkinSpanId", "3822889fe47043bd"), new Annotation("zipkinTraceId", "3822889fe47043bd"), new Annotation("span.kind", "server"), new Annotation("_spanSecondaryId", "server"), new Annotation("service", "frontend"), new Annotation("http.method", "GET"), new Annotation("http.status_code", "200"), new Annotation("http.url", "none+h1c://localhost:8881/"), new Annotation("application", "Zipkin"), new Annotation("cluster", "none"), new Annotation("shard", "none"), new Annotation("ipv4", "10.0.0.1"), new Annotation("_spanLogs", "true"))).build();
    mockTraceHandler.report(expectedSpan2);
    expectLastCall();
    mockTraceSpanLogsHandler.report(SpanLogs.newBuilder().setCustomer("default").setTraceId("00000000-0000-0000-3822-889fe47043bd").setSpanId("00000000-0000-0000-3822-889fe47043bd").setSpanSecondaryId("server").setLogs(ImmutableList.of(SpanLog.newBuilder().setTimestamp(startTime * 1000).setFields(ImmutableMap.of("annotation", "start processing")).build())).build());
    expectLastCall();
    replay(mockTraceHandler, mockTraceSpanLogsHandler);
    ChannelHandlerContext mockCtx = createNiceMock(ChannelHandlerContext.class);
    doMockLifecycle(mockCtx);
    FullHttpRequest httpRequest = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, "http://localhost:9411/api/v1/spans", content, true);
    handler.handleHttpMessage(mockCtx, httpRequest);
    verify(mockTraceHandler, mockTraceSpanLogsHandler);
}
Also used : DefaultFullHttpRequest(io.netty.handler.codec.http.DefaultFullHttpRequest) FullHttpRequest(io.netty.handler.codec.http.FullHttpRequest) DefaultFullHttpRequest(io.netty.handler.codec.http.DefaultFullHttpRequest) SpanBytesEncoder(zipkin2.codec.SpanBytesEncoder) SpanSampler(com.wavefront.agent.sampler.SpanSampler) ChannelHandlerContext(io.netty.channel.ChannelHandlerContext) ByteBuf(io.netty.buffer.ByteBuf) Span(wavefront.report.Span) Annotation(wavefront.report.Annotation) DurationSampler(com.wavefront.sdk.entities.tracing.sampling.DurationSampler) Endpoint(zipkin2.Endpoint) NoopHealthCheckManager(com.wavefront.agent.channel.NoopHealthCheckManager) Test(org.junit.Test)

Example 82 with Endpoint

use of com.google.cloud.aiplatform.v1.Endpoint in project java by wavefrontHQ.

the class ZipkinPortUnificationHandlerTest method testZipkinCustomSource.

@Test
public void testZipkinCustomSource() throws Exception {
    ZipkinPortUnificationHandler handler = new ZipkinPortUnificationHandler("9411", new NoopHealthCheckManager(), mockTraceHandler, mockTraceSpanLogsHandler, null, () -> false, () -> false, null, new SpanSampler(new RateSampler(1.0D), () -> null), null, null);
    // take care of mocks.
    // Reset mock
    reset(mockTraceHandler, mockTraceSpanLogsHandler);
    // Set Expectation
    mockTraceHandler.report(Span.newBuilder().setCustomer("dummy").setStartMillis(startTime).setDuration(9).setName("getservice").setSource("customZipkinSource").setSpanId("00000000-0000-0000-2822-889fe47043bd").setTraceId("00000000-0000-0000-2822-889fe47043bd").setAnnotations(ImmutableList.of(new Annotation("zipkinSpanId", "2822889fe47043bd"), new Annotation("zipkinTraceId", "2822889fe47043bd"), new Annotation("span.kind", "server"), new Annotation("service", "frontend"), new Annotation("http.method", "GET"), new Annotation("http.status_code", "200"), new Annotation("http.url", "none+h1c://localhost:8881/"), new Annotation("application", "Zipkin"), new Annotation("cluster", "none"), new Annotation("shard", "none"), new Annotation("ipv4", "10.0.0.1"))).build());
    expectLastCall();
    Endpoint localEndpoint1 = Endpoint.newBuilder().serviceName("frontend").ip("10.0.0.1").build();
    zipkin2.Span spanServer1 = zipkin2.Span.newBuilder().traceId("2822889fe47043bd").id("2822889fe47043bd").kind(zipkin2.Span.Kind.SERVER).name("getservice").timestamp(startTime * 1000).duration(9 * 1000).localEndpoint(localEndpoint1).putTag("http.method", "GET").putTag("http.url", "none+h1c://localhost:8881/").putTag("http.status_code", "200").putTag("source", "customZipkinSource").build();
    List<zipkin2.Span> zipkinSpanList = ImmutableList.of(spanServer1);
    SpanBytesEncoder encoder = SpanBytesEncoder.values()[1];
    ByteBuf content = Unpooled.copiedBuffer(encoder.encodeList(zipkinSpanList));
    replay(mockTraceHandler, mockTraceSpanLogsHandler);
    ChannelHandlerContext mockCtx = createNiceMock(ChannelHandlerContext.class);
    doMockLifecycle(mockCtx);
    FullHttpRequest httpRequest = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, "http://localhost:9411/api/v1/spans", content, true);
    handler.handleHttpMessage(mockCtx, httpRequest);
    verify(mockTraceHandler, mockTraceSpanLogsHandler);
}
Also used : DefaultFullHttpRequest(io.netty.handler.codec.http.DefaultFullHttpRequest) FullHttpRequest(io.netty.handler.codec.http.FullHttpRequest) DefaultFullHttpRequest(io.netty.handler.codec.http.DefaultFullHttpRequest) RateSampler(com.wavefront.sdk.entities.tracing.sampling.RateSampler) SpanBytesEncoder(zipkin2.codec.SpanBytesEncoder) SpanSampler(com.wavefront.agent.sampler.SpanSampler) ChannelHandlerContext(io.netty.channel.ChannelHandlerContext) ByteBuf(io.netty.buffer.ByteBuf) Span(wavefront.report.Span) Annotation(wavefront.report.Annotation) Endpoint(zipkin2.Endpoint) NoopHealthCheckManager(com.wavefront.agent.channel.NoopHealthCheckManager) Test(org.junit.Test)

Example 83 with Endpoint

use of com.google.cloud.aiplatform.v1.Endpoint in project wildfly-core by wildfly.

the class EndpointService method start.

/**
 * {@inheritDoc}
 */
public void start(final StartContext context) throws StartException {
    final Endpoint endpoint;
    final EndpointBuilder builder = Endpoint.builder();
    builder.setEndpointName(endpointName);
    builder.setXnioWorker(workerSupplier.get());
    try {
        endpoint = builder.build();
    } catch (IOException e) {
        throw RemotingLogger.ROOT_LOGGER.couldNotStart(e);
    }
    // Reuse the options for the remote connection factory for now
    this.endpoint = endpoint;
    endpointConsumer.accept(endpoint);
}
Also used : Endpoint(org.jboss.remoting3.Endpoint) EndpointBuilder(org.jboss.remoting3.EndpointBuilder) IOException(java.io.IOException)

Example 84 with Endpoint

use of com.google.cloud.aiplatform.v1.Endpoint in project wildfly-core by wildfly.

the class EndpointService method stop.

/**
 * {@inheritDoc}
 */
public void stop(final StopContext context) {
    context.asynchronous();
    endpointConsumer.accept(null);
    final Endpoint endpoint = this.endpoint;
    this.endpoint = null;
    try {
        endpoint.closeAsync();
    } finally {
        endpoint.addCloseHandler((closed, exception) -> {
            context.complete();
        });
    }
}
Also used : Endpoint(org.jboss.remoting3.Endpoint)

Example 85 with Endpoint

use of com.google.cloud.aiplatform.v1.Endpoint in project wildfly-core by wildfly.

the class HostControllerConnectionService method start.

@Override
@SuppressWarnings("deprecation")
public synchronized void start(final StartContext context) throws StartException {
    final Endpoint endpoint = endpointSupplier.get();
    try {
        // we leave local auth enabled as an option for domain servers to use if available. elytron only configuration
        // will require this to be enabled and available on the server side for servers to connect successfully.
        // final OptionMap options = OptionMap.create(Options.SASL_DISALLOWED_MECHANISMS, Sequence.of(JBOSS_LOCAL_USER));
        // Create the connection configuration
        final ProtocolConnectionConfiguration configuration = ProtocolConnectionConfiguration.create(endpoint, connectionURI, OptionMap.EMPTY);
        final String userName = this.userName != null ? this.userName : serverName;
        configuration.setCallbackHandler(HostControllerConnection.createClientCallbackHandler(userName, initialAuthKey));
        configuration.setConnectionTimeout(SERVER_CONNECTION_TIMEOUT);
        configuration.setSslContext(sslContextSupplier.get());
        this.responseAttachmentSupport = new ResponseAttachmentInputStreamSupport(scheduledExecutorSupplier.get());
        // Create the connection
        final HostControllerConnection connection = new HostControllerConnection(serverProcessName, userName, connectOperationID, configuration, responseAttachmentSupport, executorSupplier.get());
        // Trigger the started notification based on the process state listener
        final ProcessStateNotifier processService = processStateNotifierSupplier.get();
        processService.addPropertyChangeListener(new PropertyChangeListener() {

            @Override
            public void propertyChange(final PropertyChangeEvent evt) {
                final ControlledProcessState.State old = (ControlledProcessState.State) evt.getOldValue();
                final ControlledProcessState.State current = (ControlledProcessState.State) evt.getNewValue();
                if (old == ControlledProcessState.State.STARTING) {
                    // After starting reload has to be cleared, may still require a restart
                    if (current == ControlledProcessState.State.RUNNING || current == ControlledProcessState.State.RESTART_REQUIRED) {
                        connection.started();
                    } else {
                        IoUtils.safeClose(connection);
                    }
                }
            }
        });
        this.client = new HostControllerClient(serverName, connection.getChannelHandler(), connection, managementSubsystemEndpoint, executorSupplier.get());
    } catch (Exception e) {
        throw new StartException(e);
    }
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeListener(java.beans.PropertyChangeListener) ResponseAttachmentInputStreamSupport(org.jboss.as.controller.remote.ResponseAttachmentInputStreamSupport) ProcessStateNotifier(org.jboss.as.controller.ProcessStateNotifier) KeyStoreException(java.security.KeyStoreException) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) GeneralSecurityException(java.security.GeneralSecurityException) StartException(org.jboss.msc.service.StartException) IOException(java.io.IOException) KeyManagementException(java.security.KeyManagementException) CertificateException(java.security.cert.CertificateException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) Endpoint(org.jboss.remoting3.Endpoint) ProtocolConnectionConfiguration(org.jboss.as.protocol.ProtocolConnectionConfiguration) ControlledProcessState(org.jboss.as.controller.ControlledProcessState) ControlledProcessState(org.jboss.as.controller.ControlledProcessState) StartException(org.jboss.msc.service.StartException)

Aggregations

Endpoint (zipkin2.Endpoint)73 Span (zipkin2.Span)33 Test (org.junit.Test)28 Endpoint (org.jboss.remoting3.Endpoint)22 Test (org.junit.jupiter.api.Test)20 V1Span (zipkin2.v1.V1Span)16 NoopHealthCheckManager (com.wavefront.agent.channel.NoopHealthCheckManager)10 SpanSampler (com.wavefront.agent.sampler.SpanSampler)10 ByteBuf (io.netty.buffer.ByteBuf)10 ChannelHandlerContext (io.netty.channel.ChannelHandlerContext)10 DefaultFullHttpRequest (io.netty.handler.codec.http.DefaultFullHttpRequest)10 FullHttpRequest (io.netty.handler.codec.http.FullHttpRequest)10 Span (wavefront.report.Span)10 IOException (java.io.IOException)8 URI (java.net.URI)8 HashMap (java.util.HashMap)8 Annotation (wavefront.report.Annotation)8 ServiceName (org.jboss.msc.service.ServiceName)7 RateSampler (com.wavefront.sdk.entities.tracing.sampling.RateSampler)6 SaslAuthenticationFactory (org.wildfly.security.auth.server.SaslAuthenticationFactory)6