use of com.google.common.util.concurrent.Service in project cdap by caskdata.
the class TestBase method finish.
@AfterClass
public static void finish() throws Exception {
if (--nestedStartCount != 0) {
return;
}
if (cConf.getBoolean(Constants.Security.Authorization.ENABLED)) {
InstanceId instance = new InstanceId(cConf.get(Constants.INSTANCE_NAME));
Principal principal = new Principal(System.getProperty("user.name"), Principal.PrincipalType.USER);
authorizerInstantiator.get().grant(instance, principal, ImmutableSet.of(Action.ADMIN));
authorizerInstantiator.get().grant(NamespaceId.DEFAULT, principal, ImmutableSet.of(Action.ADMIN));
}
namespaceAdmin.delete(NamespaceId.DEFAULT);
authorizerInstantiator.close();
if (programScheduler instanceof Service) {
((Service) programScheduler).stopAndWait();
}
streamCoordinatorClient.stopAndWait();
metricsQueryService.stopAndWait();
metricsCollectionService.stopAndWait();
if (scheduler instanceof Service) {
((Service) scheduler).stopAndWait();
}
if (exploreClient != null) {
Closeables.closeQuietly(exploreClient);
}
if (exploreExecutorService != null) {
exploreExecutorService.stopAndWait();
}
datasetService.stopAndWait();
dsOpService.stopAndWait();
txService.stopAndWait();
if (messagingService instanceof Service) {
((Service) messagingService).stopAndWait();
}
}
use of com.google.common.util.concurrent.Service in project cdap by caskdata.
the class MetricsTestBase method init.
@Before
public void init() throws IOException, UnsupportedTypeException {
cConf = CConfiguration.create();
cConf.set(Constants.CFG_LOCAL_DATA_DIR, TEMP_FOLDER.newFolder().getAbsolutePath());
injector = Guice.createInjector(getModules());
messagingService = injector.getInstance(MessagingService.class);
if (messagingService instanceof Service) {
((Service) messagingService).startAndWait();
}
metricValueType = TypeToken.of(MetricValues.class);
schema = new ReflectionSchemaGenerator().generate(metricValueType.getType());
recordWriter = new ASMDatumWriterFactory(new ASMFieldAccessorFactory()).create(metricValueType, schema);
}
use of com.google.common.util.concurrent.Service in project cdap by caskdata.
the class MessagingServiceTwillRunnable method addServices.
@Override
protected void addServices(List<? super Service> services) {
MessagingService messagingService = injector.getInstance(MessagingService.class);
if (messagingService instanceof Service) {
services.add((Service) messagingService);
}
services.add(injector.getInstance(MessagingHttpService.class));
}
use of com.google.common.util.concurrent.Service in project cdap by caskdata.
the class StandaloneMain method startUp.
/**
* Start the service.
*/
public void startUp() throws Exception {
// Workaround for release of file descriptors opened by URLClassLoader - https://issues.cask.co/browse/CDAP-2841
URLConnections.setDefaultUseCaches(false);
cleanupTempDir();
ConfigurationLogger.logImportantConfig(cConf);
if (messagingService instanceof Service) {
((Service) messagingService).startAndWait();
}
// TODO: CDAP-7688, remove next line after the issue is resolved
injector.getInstance(MessagingHttpService.class).startAndWait();
// Authorization bootstrapping is a blocking call, because CDAP will not start successfully if it does not
// succeed on an authorization-enabled cluster
authorizationBootstrapper.run();
txService.startAndWait();
metricsCollectionService.startAndWait();
datasetService.startAndWait();
serviceStore.startAndWait();
streamService.startAndWait();
// Validate the logging pipeline configuration.
// Do it explicitly as Standalone doesn't have a separate master check phase as the distributed does.
new LogPipelineLoader(cConf).validate();
// It is recommended to initialize log appender after datasetService is started,
// since log appender instantiates a dataset.
logAppenderInitializer.initialize();
Service.State state = appFabricServer.startAndWait();
if (state != Service.State.RUNNING) {
throw new Exception("Failed to start Application Fabric");
}
metricsQueryService.startAndWait();
router.startAndWait();
if (userInterfaceService != null) {
userInterfaceService.startAndWait();
}
if (securityEnabled) {
externalAuthenticationServer.startAndWait();
}
if (exploreExecutorService != null) {
exploreExecutorService.startAndWait();
}
metadataService.startAndWait();
if (trackerAppCreationService != null) {
trackerAppCreationService.startAndWait();
}
wranglerAppCreationService.startAndWait();
remoteSystemOperationsService.startAndWait();
operationalStatsService.startAndWait();
String protocol = sslEnabled ? "https" : "http";
int dashboardPort = sslEnabled ? cConf.getInt(Constants.Dashboard.SSL_BIND_PORT) : cConf.getInt(Constants.Dashboard.BIND_PORT);
System.out.println("CDAP Sandbox started successfully.");
System.out.printf("Connect to the CDAP UI at %s://%s:%d\n", protocol, "localhost", dashboardPort);
}
use of com.google.common.util.concurrent.Service in project cdap by caskdata.
the class RetryOnStartFailureServiceTest method testRetryFail.
@Test
public void testRetryFail() throws InterruptedException {
CountDownLatch startLatch = new CountDownLatch(1);
Service service = new RetryOnStartFailureService(createServiceSupplier(1000, startLatch, new CountDownLatch(1), false), RetryStrategies.limit(10, RetryStrategies.fixDelay(10, TimeUnit.MILLISECONDS)));
final CountDownLatch failureLatch = new CountDownLatch(1);
service.addListener(new ServiceListenerAdapter() {
@Override
public void failed(Service.State from, Throwable failure) {
failureLatch.countDown();
}
}, Threads.SAME_THREAD_EXECUTOR);
service.start();
Assert.assertTrue(failureLatch.await(1, TimeUnit.SECONDS));
Assert.assertFalse(startLatch.await(100, TimeUnit.MILLISECONDS));
}
Aggregations