public static <T> List<T> createProxies( MetricRegistry metricRegistry, Optional<TrustContext> trustContext, Collection<String> endpointUris, boolean refreshingHttpClient, Class<T> type, String userAgent) { List<T> ret = Lists.newArrayListWithCapacity(endpointUris.size()); for (String uri : endpointUris) { ret.add(createProxy(metricRegistry, trustContext, uri, refreshingHttpClient, type, userAgent)); } return ret; }
public static <T> List<T> createProxies( MetricRegistry metricRegistry, Optional<TrustContext> trustContext, Collection<String> endpointUris, Class<T> type, String userAgent) { List<T> ret = Lists.newArrayListWithCapacity(endpointUris.size()); for (String uri : endpointUris) { ret.add(createProxy(metricRegistry, trustContext, uri, type, userAgent)); } return ret; }
public static <T> T createProxy( MetricRegistry metricRegistry, Optional<TrustContext> trustContext, String uri, Class<T> type, String userAgent) { return AtlasDbMetrics.instrument( metricRegistry, type, AtlasDbFeignTargetFactory.createProxy(trustContext, uri, type, userAgent), MetricRegistry.name(type)); }
private static TimestampService createTimeLockTimestampClient() { String uri = String.format("http://%s:%s/%s", TIMELOCK_CONTAINER, TIMELOCK_PORT, TEST_CLIENT); return AtlasDbHttpClients.createProxy(new MetricRegistry(), Optional.empty(), uri, TimestampService.class); } }
private static <T> T createClientFor(Class<T> clazz, String host, short port) { String uri = String.format("http://%s:%s", host, port); return AtlasDbHttpClients.createProxy(new MetricRegistry(), NO_SSL, uri, clazz); } }
public static Map<PingableLeader, HostAndPort> generatePingables( MetricsManager metricsManager, Collection<String> remoteEndpoints, Optional<TrustContext> trustContext, String userAgent) { /* The interface used as a key here may be a proxy, which may have strange .equals() behavior. * This is circumvented by using an IdentityHashMap which will just use native == for equality. */ Map<PingableLeader, HostAndPort> pingables = new IdentityHashMap<>(); for (String endpoint : remoteEndpoints) { PingableLeader remoteInterface = AtlasDbHttpClients .createProxy(metricsManager.getRegistry(), trustContext, endpoint, true, PingableLeader.class, userAgent); HostAndPort hostAndPort = HostAndPort.fromString(endpoint); pingables.put(remoteInterface, hostAndPort); } return pingables; }
private static <T> T createEteClientFor(Class<T> clazz) { String uri = String.format("http://%s:%s", ETE_CONTAINER, ETE_PORT); return AtlasDbHttpClients.createProxy(new MetricRegistry(), Optional.empty(), uri, clazz); }
public static ClockSkewMonitor create(MetricsManager metricsManager, Set<String> remoteServers, Optional<TrustContext> optionalSecurity) { Map<String, ClockService> clocksByServer = Maps.toMap( remoteServers, (remoteServer) -> AtlasDbHttpClients.createProxy(metricsManager.getRegistry(), optionalSecurity, remoteServer, ClockService.class)); return new ClockSkewMonitor( clocksByServer, new ClockSkewEvents(metricsManager.getRegistry()), PTExecutors.newSingleThreadScheduledExecutor(new NamedThreadFactory("clock-skew-monitor", true)), new ClockServiceImpl()); }
@Test public void userAgentIsPresentOnClientRequests() { TestResource client = AtlasDbHttpClients.createProxy( new MetricRegistry(), NO_SSL, getUriForPort(availablePort), TestResource.class); client.getTestNumber(); String defaultUserAgent = UserAgents.fromStrings(UserAgents.DEFAULT_VALUE, UserAgents.DEFAULT_VALUE); availableServer.verify(getRequestedFor(urlMatching(TEST_ENDPOINT)) .withHeader(FeignOkHttpClients.USER_AGENT_HEADER, WireMock.equalTo(defaultUserAgent))); }
public static <T> List<T> createProxies( MetricRegistry metricRegistry, Optional<TrustContext> trustContext, Collection<String> endpointUris, boolean refreshingHttpClient, Class<T> type, String userAgent) { List<T> ret = Lists.newArrayListWithCapacity(endpointUris.size()); for (String uri : endpointUris) { ret.add(createProxy(metricRegistry, trustContext, uri, refreshingHttpClient, type, userAgent)); } return ret; }
public static <T> List<T> createProxies( MetricRegistry metricRegistry, Optional<TrustContext> trustContext, Collection<String> endpointUris, Class<T> type, String userAgent) { List<T> ret = Lists.newArrayListWithCapacity(endpointUris.size()); for (String uri : endpointUris) { ret.add(createProxy(metricRegistry, trustContext, uri, type, userAgent)); } return ret; }
public static <T> T createProxy( MetricRegistry metricRegistry, Optional<TrustContext> trustContext, String uri, Class<T> type, String userAgent) { return AtlasDbMetrics.instrument( metricRegistry, type, AtlasDbFeignTargetFactory.createProxy(trustContext, uri, type, userAgent), MetricRegistry.name(type)); }
public static Map<PingableLeader, HostAndPort> generatePingables( MetricsManager metricsManager, Collection<String> remoteEndpoints, Optional<TrustContext> trustContext, String userAgent) { /* The interface used as a key here may be a proxy, which may have strange .equals() behavior. * This is circumvented by using an IdentityHashMap which will just use native == for equality. */ Map<PingableLeader, HostAndPort> pingables = new IdentityHashMap<>(); for (String endpoint : remoteEndpoints) { PingableLeader remoteInterface = AtlasDbHttpClients .createProxy(metricsManager.getRegistry(), trustContext, endpoint, true, PingableLeader.class, userAgent); HostAndPort hostAndPort = HostAndPort.fromString(endpoint); pingables.put(remoteInterface, hostAndPort); } return pingables; }
public static ClockSkewMonitor create(MetricsManager metricsManager, Set<String> remoteServers, Optional<TrustContext> optionalSecurity) { Map<String, ClockService> clocksByServer = Maps.toMap( remoteServers, (remoteServer) -> AtlasDbHttpClients.createProxy(metricsManager.getRegistry(), optionalSecurity, remoteServer, ClockService.class)); return new ClockSkewMonitor( clocksByServer, new ClockSkewEvents(metricsManager.getRegistry()), PTExecutors.newSingleThreadScheduledExecutor(new NamedThreadFactory("clock-skew-monitor", true)), new ClockServiceImpl()); }