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