use of com.google.cloud.aiplatform.v1.Endpoint in project axis-axis2-java-core by apache.
the class WSDL20ToAxisServiceBuilder method processEndpoints.
private void processEndpoints(Interface serviceInterface) throws AxisFault {
Endpoint[] endpoints = wsdlService.getEndpoints();
if (endpoints.length == 0) {
throw new AxisFault("No endpoints found in the WSDL");
}
processedBindings = new HashMap();
Endpoint endpoint = null;
// 3. Use the first endpoint
if (this.interfaceName != null) {
for (int i = 0; i < endpoints.length; ++i) {
if (this.interfaceName.equals(endpoints[i].getName().toString())) {
endpoint = endpoints[i];
// found it. Stop looking
break;
}
}
if (endpoint == null) {
throw new AxisFault("No endpoint found for the given name :" + this.interfaceName);
}
axisService.addEndpoint(endpoint.getName().toString(), processEndpoint(endpoint, serviceInterface));
} else if (this.isCodegen && !this.isAllPorts) {
Endpoint soap11Endpoint = null;
for (int i = 0; i < endpoints.length; ++i) {
Binding binding = endpoints[i].getBinding();
if (WSDL2Constants.URI_WSDL2_SOAP.equals(binding.getType().toString())) {
SOAPBindingExtensions soapBindingExtensions;
try {
soapBindingExtensions = (SOAPBindingExtensions) binding.getComponentExtensionContext(new URI(WSDL2Constants.URI_WSDL2_SOAP));
} catch (URISyntaxException e) {
throw new AxisFault("Soap Binding Extention not found");
}
if (!WSDL2Constants.SOAP_VERSION_1_1.equals(soapBindingExtensions.getSoapVersion())) {
endpoint = endpoints[i];
// found it. Stop looking
break;
} else if (soap11Endpoint == null) {
soap11Endpoint = endpoints[i];
}
}
}
if (endpoint == null) {
endpoint = endpoints[0];
}
axisService.addEndpoint(endpoint.getName().toString(), processEndpoint(endpoint, serviceInterface));
} else {
for (int i = 0; i < endpoints.length; i++) {
axisService.addEndpoint(endpoints[i].getName().toString(), processEndpoint(endpoints[i], serviceInterface));
}
}
if (endpoint == null && endpoints.length > 0) {
endpoint = endpoints[0];
}
if (endpoint != null) {
axisService.setEndpointName(endpoint.getName().toString());
axisService.setBindingName(endpoint.getBinding().getName().getLocalPart());
axisService.setEndpointURL(endpoint.getAddress().toString());
}
}
use of com.google.cloud.aiplatform.v1.Endpoint in project java by wavefrontHQ.
the class ZipkinPortUnificationHandlerTest method testZipkinHandler.
@Test
public void testZipkinHandler() throws Exception {
ZipkinPortUnificationHandler handler = new ZipkinPortUnificationHandler("9411", new NoopHealthCheckManager(), mockTraceHandler, mockTraceSpanLogsHandler, null, () -> false, () -> false, null, new SpanSampler(new RateSampler(1.0D), () -> null), "ProxyLevelAppTag", 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(1234 * 1000).localEndpoint(localEndpoint1).putTag("http.method", "GET").putTag("http.url", "none+h1c://localhost:8881/").putTag("http.status_code", "200").build();
Endpoint localEndpoint2 = Endpoint.newBuilder().serviceName("backend").ip("10.0.0.1").build();
zipkin2.Span spanServer2 = zipkin2.Span.newBuilder().traceId("2822889fe47043bd").id("d6ab73f8a3930ae8").parentId("2822889fe47043bd").kind(zipkin2.Span.Kind.SERVER).name("getbackendservice").timestamp(startTime * 1000).duration(2234 * 1000).localEndpoint(localEndpoint2).putTag("http.method", "GET").putTag("http.url", "none+h2c://localhost:9000/api").putTag("http.status_code", "200").putTag("component", "jersey-server").putTag("application", "SpanLevelAppTag").addAnnotation(startTime * 1000, "start processing").build();
zipkin2.Span spanServer3 = zipkin2.Span.newBuilder().traceId("2822889fe47043bd").id("d6ab73f8a3930ae8").kind(zipkin2.Span.Kind.CLIENT).name("getbackendservice2").timestamp(startTime * 1000).duration(2234 * 1000).localEndpoint(localEndpoint2).putTag("http.method", "GET").putTag("http.url", "none+h2c://localhost:9000/api").putTag("http.status_code", "200").putTag("component", "jersey-server").putTag("application", "SpanLevelAppTag").putTag("emptry.tag", "").addAnnotation(startTime * 1000, "start processing").build();
List<zipkin2.Span> zipkinSpanList = ImmutableList.of(spanServer1, spanServer2, spanServer3);
// Validate all codecs i.e. JSON_V1, JSON_V2, THRIFT and PROTO3.
for (SpanBytesEncoder encoder : SpanBytesEncoder.values()) {
ByteBuf content = Unpooled.copiedBuffer(encoder.encodeList(zipkinSpanList));
// take care of mocks.
doMockLifecycle(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 testZipkinPreprocessedDerivedMetrics.
/**
* Test for derived metrics emitted from Zipkin trace listeners. Derived metrics should report
* tag values post applying preprocessing rules to the span.
*/
@Test
public void testZipkinPreprocessedDerivedMetrics() throws Exception {
Supplier<ReportableEntityPreprocessor> preprocessorSupplier = () -> {
ReportableEntityPreprocessor preprocessor = new ReportableEntityPreprocessor();
PreprocessorRuleMetrics preprocessorRuleMetrics = new PreprocessorRuleMetrics(null, null, null);
preprocessor.forSpan().addTransformer(new SpanReplaceRegexTransformer(APPLICATION_TAG_KEY, "^Zipkin.*", PREPROCESSED_APPLICATION_TAG_VALUE, null, null, false, x -> true, preprocessorRuleMetrics));
preprocessor.forSpan().addTransformer(new SpanReplaceRegexTransformer(SERVICE_TAG_KEY, "^test.*", PREPROCESSED_SERVICE_TAG_VALUE, null, null, false, x -> true, preprocessorRuleMetrics));
preprocessor.forSpan().addTransformer(new SpanReplaceRegexTransformer("sourceName", "^zipkin.*", PREPROCESSED_SOURCE_VALUE, null, null, false, x -> true, preprocessorRuleMetrics));
preprocessor.forSpan().addTransformer(new SpanReplaceRegexTransformer(CLUSTER_TAG_KEY, "^none.*", PREPROCESSED_CLUSTER_TAG_VALUE, null, null, false, x -> true, preprocessorRuleMetrics));
preprocessor.forSpan().addTransformer(new SpanReplaceRegexTransformer(SHARD_TAG_KEY, "^none.*", PREPROCESSED_SHARD_TAG_VALUE, null, null, false, x -> true, preprocessorRuleMetrics));
return preprocessor;
};
ZipkinPortUnificationHandler handler = new ZipkinPortUnificationHandler("9411", new NoopHealthCheckManager(), mockTraceHandler, mockTraceSpanLogsHandler, mockWavefrontSender, () -> false, () -> false, preprocessorSupplier, new SpanSampler(new RateSampler(1.0D), () -> null), null, null);
Endpoint localEndpoint1 = Endpoint.newBuilder().serviceName("testService").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(1234 * 1000).localEndpoint(localEndpoint1).build();
List<zipkin2.Span> zipkinSpanList = ImmutableList.of(spanServer1);
// Reset mock
reset(mockTraceHandler, mockWavefrontSender);
// Set Expectation
mockTraceHandler.report(Span.newBuilder().setCustomer("dummy").setStartMillis(startTime).setDuration(1234).setName("getservice").setSource(PREPROCESSED_SOURCE_VALUE).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", PREPROCESSED_SERVICE_TAG_VALUE), new Annotation("application", PREPROCESSED_APPLICATION_TAG_VALUE), new Annotation("cluster", PREPROCESSED_CLUSTER_TAG_VALUE), new Annotation("shard", PREPROCESSED_SHARD_TAG_VALUE), new Annotation("ipv4", "10.0.0.1"))).build());
expectLastCall();
Capture<HashMap<String, String>> tagsCapture = EasyMock.newCapture();
mockWavefrontSender.sendMetric(eq(HEART_BEAT_METRIC), eq(1.0), anyLong(), eq(PREPROCESSED_SOURCE_VALUE), EasyMock.capture(tagsCapture));
expectLastCall().anyTimes();
replay(mockTraceHandler, mockWavefrontSender);
ChannelHandlerContext mockCtx = createNiceMock(ChannelHandlerContext.class);
doMockLifecycle(mockCtx);
ByteBuf content = Unpooled.copiedBuffer(SpanBytesEncoder.JSON_V2.encodeList(zipkinSpanList));
FullHttpRequest httpRequest = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, "http://localhost:9411/api/v2/spans", content, true);
handler.handleHttpMessage(mockCtx, httpRequest);
handler.run();
verifyWithTimeout(500, mockTraceHandler, mockWavefrontSender);
HashMap<String, String> tagsReturned = tagsCapture.getValue();
assertEquals(PREPROCESSED_APPLICATION_TAG_VALUE, tagsReturned.get(APPLICATION_TAG_KEY));
assertEquals(PREPROCESSED_SERVICE_TAG_VALUE, tagsReturned.get(SERVICE_TAG_KEY));
assertEquals(PREPROCESSED_CLUSTER_TAG_VALUE, tagsReturned.get(CLUSTER_TAG_KEY));
assertEquals(PREPROCESSED_SHARD_TAG_VALUE, tagsReturned.get(SHARD_TAG_KEY));
}
use of com.google.cloud.aiplatform.v1.Endpoint in project easeagent by megaease.
the class ConvertSpanReporter method convert.
static ReportSpan convert(MutableSpan span) {
ReportSpanBuilder result = ReportSpanBuilder.newBuilder().traceId(span.traceId()).parentId(span.parentId()).id(span.id()).name(span.name());
long start = span.startTimestamp();
long finish = span.finishTimestamp();
result.timestamp(start);
if (start != 0 && finish != 0L) {
result.duration(Math.max(finish - start, 1));
}
// use ordinal comparison to defend against version skew
Kind kind = span.kind();
if (kind != null) {
result.kind(BRAVE_TO_ZIPKIN_KIND.get(kind));
}
String localServiceName = span.localServiceName();
String localIp = span.localIp();
if (localServiceName != null || localIp != null) {
zipkin2.Endpoint e = Endpoint.newBuilder().serviceName(localServiceName).ip(localIp).port(span.localPort()).build();
result.localEndpoint(ReportSpanBuilder.endpoint(e));
}
String remoteServiceName = span.remoteServiceName();
String remoteIp = span.remoteIp();
if (remoteServiceName != null || remoteIp != null) {
zipkin2.Endpoint e = Endpoint.newBuilder().serviceName(remoteServiceName).ip(remoteIp).port(span.remotePort()).build();
result.remoteEndpoint(ReportSpanBuilder.endpoint(e));
}
span.forEachTag(Consumer.INSTANCE, result);
span.forEachAnnotation(Consumer.INSTANCE, result);
if (span.shared())
result.shared(true);
if (span.debug())
result.debug(true);
return result.build();
}
use of com.google.cloud.aiplatform.v1.Endpoint in project java-servicedirectory by googleapis.
the class EndpointsCreate method createEndpoint.
// Create a new endpoint.
public static void createEndpoint(String projectId, String locationId, String namespaceId, String serviceId, String endpointId) throws IOException {
// the "close" method on the client to safely clean up any remaining background resources.
try (RegistrationServiceClient client = RegistrationServiceClient.create()) {
// The service to create the endpoint in.
ServiceName parent = ServiceName.of(projectId, locationId, namespaceId, serviceId);
// The endpoint to create, with fields filled in.
// Optionally set an IP address and port for the endpoint.
Endpoint endpoint = Endpoint.newBuilder().setAddress("10.0.0.1").setPort(443).build();
// Send the request to create the endpoint.
Endpoint createdEndpoint = client.createEndpoint(parent, endpoint, endpointId);
// Process the response.
System.out.println("Created Endpoint: " + createdEndpoint.getName());
System.out.println("IP Address: " + createdEndpoint.getAddress());
System.out.println("Port: " + createdEndpoint.getPort());
}
}
Aggregations