.withHostDiscoverySource(new UserAccessControlFixedHostDiscoverySource("http://localhost:" + selfHostAndPort.getPort())) .withServiceFactory(UserAccessControlClientFactory.forCluster(cluster, metricRegistry).usingCredentials(adminApiKey)) .withMetricRegistry(metricRegistry) .buildProxy(new ExponentialBackoffRetry(5, 50, 1000, TimeUnit.MILLISECONDS));
/** Create an SOA Databus client for forwarding non-partition-aware clients to the right server. */ @Provides @Singleton @PartitionAwareClient SubjectDatabus provideSubjectDatabusClient(MultiThreadedServiceFactory<SubjectDatabus> serviceFactory, @DatabusHostDiscovery HostDiscovery hostDiscovery, SubjectDatabus localSubjectDatabus, @SelfHostAndPort HostAndPort self, MetricRegistry metricRegistry, HealthCheckRegistry healthCheckRegistry) { SubjectDatabus client = ServicePoolBuilder.create(SubjectDatabus.class) .withHostDiscovery(hostDiscovery) .withServiceFactory( new PartitionAwareServiceFactory<>(SubjectDatabus.class, serviceFactory, localSubjectDatabus, self, healthCheckRegistry, metricRegistry)) .withMetricRegistry(metricRegistry) .withCachingPolicy(ServiceCachingPolicyBuilder.getMultiThreadedClientPolicy()) .buildProxy(new ExponentialBackoffRetry(5, 50, 1000, TimeUnit.MILLISECONDS)); _environment.lifecycle().manage(new ManagedServicePoolProxy(client)); return client; }
/** Provides a DataStore client that delegates to the remote system center data store. */ @Provides @Singleton @SystemDataStore DataStore provideSystemDataStore (DataCenterConfiguration config, Client jerseyClient, @Named ("AdminKey") String apiKey, MetricRegistry metricRegistry) { ServiceFactory<DataStore> clientFactory = DataStoreClientFactory .forClusterAndHttpClient(_configuration.getCluster(), jerseyClient) .usingCredentials(apiKey); URI uri = config.getSystemDataCenterServiceUri(); ServiceEndPoint endPoint = new ServiceEndPointBuilder() .withServiceName(clientFactory.getServiceName()) .withId(config.getSystemDataCenter()) .withPayload(new PayloadBuilder() .withUrl(uri.resolve(DataStoreClient.SERVICE_PATH)) .withAdminUrl(uri) .toString()) .build(); return ServicePoolBuilder.create(DataStore.class) .withMetricRegistry(metricRegistry) .withHostDiscovery(new FixedHostDiscovery(endPoint)) .withServiceFactory(clientFactory) .buildProxy(new ExponentialBackoffRetry(30, 1, 10, TimeUnit.SECONDS)); }
/** Provides a BlobStore client that delegates to the remote system center blob store. */ @Provides @Singleton @SystemBlobStore BlobStore provideSystemBlobStore (DataCenterConfiguration config, Client jerseyClient, @Named ("AdminKey") String apiKey, MetricRegistry metricRegistry) { ServiceFactory<BlobStore> clientFactory = BlobStoreClientFactory .forClusterAndHttpClient(_configuration.getCluster(), jerseyClient) .usingCredentials(apiKey); URI uri = config.getSystemDataCenterServiceUri(); ServiceEndPoint endPoint = new ServiceEndPointBuilder() .withServiceName(clientFactory.getServiceName()) .withId(config.getSystemDataCenter()) .withPayload(new PayloadBuilder() .withUrl(uri.resolve(BlobStoreClient.SERVICE_PATH)) .withAdminUrl(uri) .toString()) .build(); return ServicePoolBuilder.create(BlobStore.class) .withMetricRegistry(metricRegistry) .withHostDiscovery(new FixedHostDiscovery(endPoint)) .withServiceFactory(clientFactory) .buildProxy(new ExponentialBackoffRetry(30, 1, 10, TimeUnit.SECONDS)); } }
@Provides @Singleton @AllCompactionControlSources public List<CompactionControlSource> getAllCompactionControlSources(@LocalCompactionControl CompactionControlSource localCompactionControlSource, @ServerCluster String serverCluster, Client client, DataCenters dataCenters, @CompControlApiKey String compControlApiKey, HealthCheckRegistry healthCheckRegistry, MetricRegistry metrics) { List<CompactionControlSource> compactionControlSources = Lists.newArrayList(); for (DataCenter dataCenter : dataCenters.getAll()) { MultiThreadedServiceFactory<CompactionControlSource> clientFactory = new CompactionControlClientFactory(serverCluster, new JerseyEmoClient(client), compControlApiKey); if (dataCenter.equals(dataCenters.getSelf())) { compactionControlSources.add(localCompactionControlSource); } else { ServiceEndPoint endPoint = new ServiceEndPointBuilder() .withServiceName(clientFactory.getServiceName()) .withId(dataCenter.getName()) .withPayload(new PayloadBuilder() .withUrl(dataCenter.getServiceUri().resolve(DataStoreClient.SERVICE_PATH)) .withAdminUrl(dataCenter.getAdminUri()) .toString()) .build(); compactionControlSources.add(ServicePoolBuilder.create(CompactionControlSource.class) .withHostDiscovery(new FixedHostDiscovery(endPoint)) .withServiceFactory(clientFactory) .withCachingPolicy(ServiceCachingPolicyBuilder.getMultiThreadedClientPolicy()) .withMetricRegistry(metrics) .buildProxy(new ExponentialBackoffRetry(30, 1, 10, TimeUnit.SECONDS))); } } return compactionControlSources; }
/** Create an SOA DedupQueue client for forwarding non-partition-aware clients to the right server. */ @Provides @Singleton @PartitionAwareClient DedupQueueServiceAuthenticator provideDedupQueueClient(MultiThreadedServiceFactory<AuthDedupQueueService> serviceFactory, @DedupQueueHostDiscovery HostDiscovery hostDiscovery, DedupQueueService databus, @SelfHostAndPort HostAndPort self, HealthCheckRegistry healthCheckRegistry, MetricRegistry metricRegistry) { AuthDedupQueueService client = ServicePoolBuilder.create(AuthDedupQueueService.class) .withHostDiscovery(hostDiscovery) .withServiceFactory(new PartitionAwareServiceFactory<>( AuthDedupQueueService.class, serviceFactory, new TrustedDedupQueueService(databus), self, healthCheckRegistry, metricRegistry)) .withMetricRegistry(_environment.metrics()) .withCachingPolicy(ServiceCachingPolicyBuilder.getMultiThreadedClientPolicy()) .buildProxy(new ExponentialBackoffRetry(5, 50, 1000, TimeUnit.MILLISECONDS)); _environment.lifecycle().manage(new ManagedServicePoolProxy(client)); return DedupQueueServiceAuthenticator.proxied(client); } }
/** Create an SOA QueueService client for forwarding non-partition-aware clients to the right server. */ @Provides @Singleton @PartitionAwareClient QueueServiceAuthenticator provideQueueClient(QueueService queueService, Client jerseyClient, @SelfHostAndPort HostAndPort self, @Global CuratorFramework curator, MetricRegistry metricRegistry, HealthCheckRegistry healthCheckRegistry) { MultiThreadedServiceFactory<AuthQueueService> serviceFactory = new PartitionAwareServiceFactory<>( AuthQueueService.class, QueueClientFactory.forClusterAndHttpClient(_configuration.getCluster(), jerseyClient), new TrustedQueueService(queueService), self, healthCheckRegistry, metricRegistry); AuthQueueService client = ServicePoolBuilder.create(AuthQueueService.class) .withHostDiscovery(new ZooKeeperHostDiscovery(curator, serviceFactory.getServiceName(), metricRegistry)) .withServiceFactory(serviceFactory) .withMetricRegistry(metricRegistry) .withCachingPolicy(ServiceCachingPolicyBuilder.getMultiThreadedClientPolicy()) .buildProxy(new ExponentialBackoffRetry(5, 50, 1000, TimeUnit.MILLISECONDS)); _environment.lifecycle().manage(new ManagedServicePoolProxy(client)); return QueueServiceAuthenticator.proxied(client); }
.withServiceFactory(serviceFactory) .withHostDiscovery(new ZooKeeperHostDiscovery(curator, serviceFactory.getServiceName(), metrics)) .withMetricRegistry(metrics) .withCachingPolicy(cachingPolicy) .build();
.withMetricRegistry(metricRegistry) .withHostDiscovery(new FixedHostDiscovery(endPoint)) .withServiceFactory(clientFactory)
.withServiceFactory(serviceFactory) .withHostDiscovery(new ZooKeeperHostDiscovery(curator, serviceFactory.getServiceName(), metrics)) .withMetricRegistry(metrics) .withCachingPolicy(cachingPolicy) .buildProxy(new ExponentialBackoffRetry(5, 50, 1000, TimeUnit.MILLISECONDS));
.withServiceFactory(dataStoreFactory) .withCachingPolicy(ServiceCachingPolicyBuilder.getMultiThreadedClientPolicy()) .withMetricRegistry(metricRegistry) .buildProxy(new ExponentialBackoffRetry(5, 50, 1000, TimeUnit.MILLISECONDS));
@Override public ScanWorkflow get() { QueueClientFactory factory = QueueClientFactory.forClusterAndHttpClient(_cluster, _client); // Don't use the local queue service; create a client to call out to the live EmoDB application. AuthQueueService authService = ServicePoolBuilder.create(AuthQueueService.class) .withServiceFactory(factory) .withHostDiscovery(new ZooKeeperHostDiscovery(_curator, factory.getServiceName(), _metricRegistry)) .withMetricRegistry(_metricRegistry) .buildProxy(new ExponentialBackoffRetry(5, 50, 1000, TimeUnit.MILLISECONDS)); _environment.lifecycle().manage(new ManagedServicePoolProxy(authService)); QueueService service = QueueServiceAuthenticator.proxied(authService) .usingCredentials(_apiKey); return new QueueScanWorkflow(service, _pendingScanRangeQueueName, _completeScanRangeQueueName); } }
@Override public ScanWorkflow get() { QueueClientFactory factory = QueueClientFactory.forClusterAndHttpClient(_cluster, _client); // Don't use the local queue service; create a client to call out to the live EmoDB application. AuthQueueService authService = ServicePoolBuilder.create(AuthQueueService.class) .withServiceFactory(factory) .withHostDiscovery(new ZooKeeperHostDiscovery(_curator, factory.getServiceName(), _metricRegistry)) .withMetricRegistry(_metricRegistry) .buildProxy(new ExponentialBackoffRetry(5, 50, 1000, TimeUnit.MILLISECONDS)); _environment.lifecycle().manage(new ManagedServicePoolProxy(authService)); QueueService service = QueueServiceAuthenticator.proxied(authService) .usingCredentials(_apiKey); return new QueueScanWorkflow(service, _pendingScanRangeQueueName, _completeScanRangeQueueName); } }
.withServiceFactory(dataStoreFactory) .withCachingPolicy(ServiceCachingPolicyBuilder.getMultiThreadedClientPolicy()) .withMetricRegistry(metricRegistry) .buildProxy(new ExponentialBackoffRetry(5, 50, 1000, TimeUnit.MILLISECONDS));
.withServiceFactory(serviceFactory) .withHostDiscovery(new ZooKeeperHostDiscovery(curator, serviceFactory.getServiceName(), metrics)) .withMetricRegistry(metrics) .withCachingPolicy(cachingPolicy) .buildProxy(new ExponentialBackoffRetry(5, 50, 1000, TimeUnit.MILLISECONDS));
/** Creates a ReplicationSource proxy to the remote data center. */ private ReplicationSource newRemoteReplicationSource(DataCenter dataCenter) { MultiThreadedServiceFactory<ReplicationSource> clientFactory = new ReplicationClientFactory(_jerseyClient) .usingApiKey(_replicationApiKey); ServiceEndPoint endPoint = new ServiceEndPointBuilder() .withServiceName(clientFactory.getServiceName()) .withId(dataCenter.getName()) .withPayload(new PayloadBuilder() .withUrl(dataCenter.getServiceUri().resolve(ReplicationClient.SERVICE_PATH)) .withAdminUrl(dataCenter.getAdminUri()) .toString()) .build(); return ServicePoolBuilder.create(ReplicationSource.class) .withHostDiscovery(new FixedHostDiscovery(endPoint)) .withServiceFactory(clientFactory) .withCachingPolicy(ServiceCachingPolicyBuilder.getMultiThreadedClientPolicy()) .withHealthCheckExecutor(_healthCheckExecutor) .withMetricRegistry(_metrics) .buildProxy(new ExponentialBackoffRetry(30, 1, 10, TimeUnit.SECONDS)); } }
/** Creates a ReplicationSource proxy to the remote data center. */ private ReplicationSource newRemoteReplicationSource(DataCenter dataCenter) { MultiThreadedServiceFactory<ReplicationSource> clientFactory = new ReplicationClientFactory(_jerseyClient) .usingApiKey(_replicationApiKey); ServiceEndPoint endPoint = new ServiceEndPointBuilder() .withServiceName(clientFactory.getServiceName()) .withId(dataCenter.getName()) .withPayload(new PayloadBuilder() .withUrl(dataCenter.getServiceUri().resolve(ReplicationClient.SERVICE_PATH)) .withAdminUrl(dataCenter.getAdminUri()) .toString()) .build(); return ServicePoolBuilder.create(ReplicationSource.class) .withHostDiscovery(new FixedHostDiscovery(endPoint)) .withServiceFactory(clientFactory) .withCachingPolicy(ServiceCachingPolicyBuilder.getMultiThreadedClientPolicy()) .withHealthCheckExecutor(_healthCheckExecutor) .withMetricRegistry(_metrics) .buildProxy(new ExponentialBackoffRetry(30, 1, 10, TimeUnit.SECONDS)); } }