Search in sources :

Example 86 with Endpoint

use of com.google.cloud.servicedirectory.v1.Endpoint in project crnk-framework by crnk-project.

the class AbstractBraveModuleTest method setup.

@Before
@SuppressWarnings("unchecked")
public void setup() {
    Endpoint localEndpoint = Endpoint.newBuilder().serviceName("testClient").build();
    clientReporter = Mockito.mock(Reporter.class);
    Tracing clientTracing = Tracing.newBuilder().spanReporter(clientReporter).localEndpoint(localEndpoint).build();
    client = new CrnkClient(getBaseUri().toString());
    client.setHttpAdapter(httpAdapter);
    client.addModule(BraveClientModule.create(clientTracing));
    taskRepo = client.getRepositoryForType(Task.class);
    TaskRepository.clear();
    ProjectRepository.clear();
    httpAdapter.setReceiveTimeout(10000, TimeUnit.SECONDS);
}
Also used : CrnkClient(io.crnk.client.CrnkClient) Task(io.crnk.monitor.brave.mock.models.Task) Endpoint(zipkin2.Endpoint) Reporter(zipkin2.reporter.Reporter) Tracing(brave.Tracing) Before(org.junit.Before)

Example 87 with Endpoint

use of com.google.cloud.servicedirectory.v1.Endpoint in project zipkin-gcp by openzipkin.

the class AttributesExtractorTest method testEndpointIsSetIpv6.

@Test
public void testEndpointIsSetIpv6() {
    Endpoint.Builder serverEndpointBuilder = Endpoint.newBuilder().serviceName("service1").port(80);
    serverEndpointBuilder.parseIp("::1");
    Endpoint serverEndpoint = serverEndpointBuilder.build();
    Endpoint.Builder clientEndpointBuilder = Endpoint.newBuilder().serviceName("service2").port(80);
    clientEndpointBuilder.parseIp("::1");
    Endpoint clientEndpoint = clientEndpointBuilder.build();
    Span serverSpan = Span.newBuilder().kind(Kind.SERVER).traceId("4").name("test-span").id("5").localEndpoint(serverEndpoint).build();
    Span clientSpan = Span.newBuilder().kind(Kind.CLIENT).traceId("4").name("test-span").id("6").parentId("5").localEndpoint(clientEndpoint).build();
    AttributesExtractor extractor = new AttributesExtractor(Collections.emptyMap());
    Map<String, AttributeValue> serverLabels = extractor.extract(serverSpan).getAttributeMapMap();
    assertThat(serverLabels).doesNotContainKey("endpoint.ipv4");
    assertThat(serverLabels).containsEntry("endpoint.ipv6", toAttributeValue("::1"));
    Map<String, AttributeValue> clientLabels = extractor.extract(clientSpan).getAttributeMapMap();
    assertThat(clientLabels).doesNotContainKeys("endpoint.ipv4", "endpoint.ipv6");
}
Also used : AttributeValue(com.google.devtools.cloudtrace.v2.AttributeValue) AttributesExtractor.toAttributeValue(zipkin2.translation.stackdriver.AttributesExtractor.toAttributeValue) Endpoint(zipkin2.Endpoint) Span(zipkin2.Span) Test(org.junit.Test)

Example 88 with Endpoint

use of com.google.cloud.servicedirectory.v1.Endpoint in project java-servicedirectory by googleapis.

the class RegistrationServiceClientTest method listEndpointsTest2.

@Test
public void listEndpointsTest2() throws Exception {
    Endpoint responsesElement = Endpoint.newBuilder().build();
    ListEndpointsResponse expectedResponse = ListEndpointsResponse.newBuilder().setNextPageToken("").addAllEndpoints(Arrays.asList(responsesElement)).build();
    mockRegistrationService.addResponse(expectedResponse);
    String parent = "parent-995424086";
    ListEndpointsPagedResponse pagedListResponse = client.listEndpoints(parent);
    List<Endpoint> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getEndpointsList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockRegistrationService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListEndpointsRequest actualRequest = ((ListEndpointsRequest) actualRequests.get(0));
    Assert.assertEquals(parent, actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListEndpointsPagedResponse(com.google.cloud.servicedirectory.v1.RegistrationServiceClient.ListEndpointsPagedResponse) ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Example 89 with Endpoint

use of com.google.cloud.servicedirectory.v1.Endpoint in project java-servicedirectory by googleapis.

the class EndpointsDelete method deleteEndpoint.

// Delete an endpoint.
public static void deleteEndpoint(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 endpoint to delete.
        EndpointName endpointName = EndpointName.of(projectId, locationId, namespaceId, serviceId, endpointId);
        // Send the request to delete the endpoint.
        client.deleteEndpoint(endpointName);
        // Log the action.
        System.out.println("Deleted Endpoint: " + endpointName.toString());
    }
}
Also used : EndpointName(com.google.cloud.servicedirectory.v1.EndpointName) RegistrationServiceClient(com.google.cloud.servicedirectory.v1.RegistrationServiceClient)

Example 90 with Endpoint

use of com.google.cloud.servicedirectory.v1.Endpoint in project java-servicedirectory by googleapis.

the class ServicesResolve method resolveService.

// Resolve a service.
public static void resolveService(String projectId, String locationId, String namespaceId, String serviceId) throws IOException {
    // the "close" method on the client to safely clean up any remaining background resources.
    try (LookupServiceClient client = LookupServiceClient.create()) {
        // The service to resolve.
        ServiceName name = ServiceName.of(projectId, locationId, namespaceId, serviceId);
        // Construct the resolve request to be sent to the client.
        ResolveServiceRequest request = ResolveServiceRequest.newBuilder().setName(name.toString()).build();
        // Send the request to resolve the service.
        ResolveServiceResponse resolveResponse = client.resolveService(request);
        // Process the response.
        System.out.println("Resolved Service: " + resolveResponse.getService().getName());
        System.out.println("Endpoints found:");
        for (Endpoint endpoint : resolveResponse.getService().getEndpointsList()) {
            System.out.println(endpoint.getName() + " -- " + endpoint.getAddress() + ":" + endpoint.getPort());
        }
    }
}
Also used : ResolveServiceResponse(com.google.cloud.servicedirectory.v1.ResolveServiceResponse) Endpoint(com.google.cloud.servicedirectory.v1.Endpoint) ServiceName(com.google.cloud.servicedirectory.v1.ServiceName) ResolveServiceRequest(com.google.cloud.servicedirectory.v1.ResolveServiceRequest) LookupServiceClient(com.google.cloud.servicedirectory.v1.LookupServiceClient)

Aggregations

Endpoint (zipkin2.Endpoint)73 Span (zipkin2.Span)33 Test (org.junit.Test)28 Endpoint (org.jboss.remoting3.Endpoint)21 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 Annotation (wavefront.report.Annotation)8 ServiceName (org.jboss.msc.service.ServiceName)7 RateSampler (com.wavefront.sdk.entities.tracing.sampling.RateSampler)6 IOException (java.io.IOException)6 URI (java.net.URI)6 SaslAuthenticationFactory (org.wildfly.security.auth.server.SaslAuthenticationFactory)6 SpanBytesEncoder (zipkin2.codec.SpanBytesEncoder)6