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