use of co.cask.cdap.common.discovery.RandomEndpointStrategy in project cdap by caskdata.
the class AuthorizationBootstrapperTest method waitForService.
private void waitForService(String discoverableName) throws InterruptedException {
EndpointStrategy endpointStrategy = new RandomEndpointStrategy(discoveryServiceClient.discover(discoverableName));
Preconditions.checkNotNull(endpointStrategy.pick(10, TimeUnit.SECONDS), "%s service is not up after 10 seconds", discoverableName);
}
use of co.cask.cdap.common.discovery.RandomEndpointStrategy in project cdap by caskdata.
the class MetricsSuiteTestBase method startMetricsService.
public static Injector startMetricsService(CConfiguration conf) {
Injector injector = Guice.createInjector(Modules.override(new ConfigModule(conf), new NonCustomLocationUnitTestModule().getModule(), new DiscoveryRuntimeModule().getInMemoryModules(), new MetricsHandlerModule(), new MetricsClientRuntimeModule().getInMemoryModules(), new DataFabricModules().getInMemoryModules(), new DataSetsModules().getStandaloneModules(), new DataSetServiceModules().getInMemoryModules(), new ExploreClientModule(), new NamespaceClientRuntimeModule().getInMemoryModules(), new AuthorizationTestModule(), new AuthorizationEnforcementModule().getInMemoryModules(), new AuthenticationContextModules().getMasterModule()).with(new AbstractModule() {
@Override
protected void configure() {
bind(LogReader.class).to(MockLogReader.class).in(Scopes.SINGLETON);
bind(Store.class).to(DefaultStore.class);
bind(UGIProvider.class).to(UnsupportedUGIProvider.class);
bind(OwnerAdmin.class).to(NoOpOwnerAdmin.class);
}
}));
transactionManager = injector.getInstance(TransactionManager.class);
transactionManager.startAndWait();
dsOpService = injector.getInstance(DatasetOpExecutor.class);
dsOpService.startAndWait();
datasetService = injector.getInstance(DatasetService.class);
datasetService.startAndWait();
metrics = injector.getInstance(MetricsQueryService.class);
metrics.startAndWait();
collectionService = injector.getInstance(MetricsCollectionService.class);
collectionService.startAndWait();
logReader = injector.getInstance(LogReader.class);
// initialize the dataset instantiator
DiscoveryServiceClient discoveryClient = injector.getInstance(DiscoveryServiceClient.class);
EndpointStrategy metricsEndPoints = new RandomEndpointStrategy(discoveryClient.discover(Constants.Service.METRICS));
Discoverable discoverable = metricsEndPoints.pick(1L, TimeUnit.SECONDS);
Assert.assertNotNull("Could not discover metrics service", discoverable);
port = discoverable.getSocketAddress().getPort();
return injector;
}
use of co.cask.cdap.common.discovery.RandomEndpointStrategy in project cdap by caskdata.
the class AppFabricServerTest method startStopServer.
@Test
public void startStopServer() throws Exception {
Injector injector = AppFabricTestHelper.getInjector();
AppFabricServer server = injector.getInstance(AppFabricServer.class);
DiscoveryServiceClient discoveryServiceClient = injector.getInstance(DiscoveryServiceClient.class);
Service.State state = server.startAndWait();
Assert.assertTrue(state == Service.State.RUNNING);
final EndpointStrategy endpointStrategy = new RandomEndpointStrategy(discoveryServiceClient.discover(Constants.Service.APP_FABRIC_HTTP));
Assert.assertNotNull(endpointStrategy.pick(5, TimeUnit.SECONDS));
state = server.stopAndWait();
Assert.assertTrue(state == Service.State.TERMINATED);
Tasks.waitFor(true, new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
return endpointStrategy.pick() == null;
}
}, 5, TimeUnit.SECONDS, 100, TimeUnit.MILLISECONDS);
}
use of co.cask.cdap.common.discovery.RandomEndpointStrategy in project cdap by caskdata.
the class RemoteNamespaceQueryTest method waitForService.
private static void waitForService(DiscoveryServiceClient discoveryService, String discoverableName) throws InterruptedException {
EndpointStrategy endpointStrategy = new RandomEndpointStrategy(discoveryService.discover(discoverableName));
Preconditions.checkNotNull(endpointStrategy.pick(5, TimeUnit.SECONDS), "%s service is not up after 5 seconds", discoverableName);
}
use of co.cask.cdap.common.discovery.RandomEndpointStrategy in project cdap by caskdata.
the class RemotePrivilegesTest method waitForService.
private static void waitForService(String name) throws InterruptedException {
EndpointStrategy endpointStrategy = new RandomEndpointStrategy(discoveryService.discover(name));
Preconditions.checkNotNull(endpointStrategy.pick(5, TimeUnit.SECONDS), "%s service is not up after 5 seconds", name);
}
Aggregations