use of io.cdap.cdap.data2.metrics.DatasetMetricsReporter in project cdap by caskdata.
the class DatasetService method shutDown.
@Override
protected void shutDown() throws Exception {
LOG.info("Stopping DatasetService...");
for (DatasetMetricsReporter metricsReporter : metricReporters) {
metricsReporter.stop();
}
if (opExecutorServiceWatch != null) {
opExecutorServiceWatch.cancel();
}
typeService.stopAndWait();
if (cancelDiscovery != null) {
cancelDiscovery.cancel();
}
// Wait for a few seconds for requests to stop
try {
TimeUnit.SECONDS.sleep(3);
} catch (InterruptedException e) {
LOG.error("Interrupted while waiting...", e);
}
httpService.stop();
opExecutorClient.stopAndWait();
}
use of io.cdap.cdap.data2.metrics.DatasetMetricsReporter in project cdap by caskdata.
the class DatasetService method startUp.
@Override
protected void startUp() throws Exception {
LOG.info("Starting DatasetService...");
typeService.startAndWait();
opExecutorClient.startAndWait();
httpService.start();
// setting watch for ops executor service that we need to be running to operate correctly
ServiceDiscovered discover = discoveryServiceClient.discover(Constants.Service.DATASET_EXECUTOR);
opExecutorDiscovered = SettableFuture.create();
opExecutorServiceWatch = discover.watchChanges(new ServiceDiscovered.ChangeListener() {
@Override
public void onChange(ServiceDiscovered serviceDiscovered) {
if (!Iterables.isEmpty(serviceDiscovered)) {
LOG.info("Discovered {} service", Constants.Service.DATASET_EXECUTOR);
opExecutorDiscovered.set(serviceDiscovered);
}
}
}, MoreExecutors.sameThreadExecutor());
for (DatasetMetricsReporter metricsReporter : metricReporters) {
metricsReporter.start();
}
}
use of io.cdap.cdap.data2.metrics.DatasetMetricsReporter in project cdap by caskdata.
the class DatasetService method doShutdown.
private void doShutdown() throws Exception {
LOG.info("Stopping DatasetService...");
if (cancelDiscovery != null) {
cancelDiscovery.cancel();
}
for (DatasetMetricsReporter metricsReporter : metricReporters) {
metricsReporter.stop();
}
if (opExecutorServiceWatch != null) {
opExecutorServiceWatch.cancel();
}
typeService.stopAndWait();
// Wait for a few seconds for requests to stop
httpService.stop();
LOG.info("DatasetService stopped");
}
use of io.cdap.cdap.data2.metrics.DatasetMetricsReporter in project cdap by caskdata.
the class DatasetService method startUp.
/**
* Starts this service by starting all dependencies and wait for operation executor to be ready.
*/
private void startUp() {
try {
LOG.info("Starting DatasetService...");
typeService.startAndWait();
httpService.start();
// setting watch for ops executor service that we need to be running to operate correctly
ServiceDiscovered discover = discoveryServiceClient.discover(Constants.Service.DATASET_EXECUTOR);
opExecutorDiscovered = SettableFuture.create();
opExecutorServiceWatch = discover.watchChanges(serviceDiscovered -> {
if (!Iterables.isEmpty(serviceDiscovered)) {
LOG.info("Discovered {} service", Constants.Service.DATASET_EXECUTOR);
opExecutorDiscovered.set(serviceDiscovered);
}
}, MoreExecutors.sameThreadExecutor());
for (DatasetMetricsReporter metricsReporter : metricReporters) {
metricsReporter.start();
}
} catch (Throwable t) {
notifyFailed(t);
return;
}
// Notify that the Service has been started to unblock all startAndWait call on this service
notifyStarted();
try {
waitForOpExecutorToStart();
String announceAddress = cConf.get(Constants.Service.MASTER_SERVICES_ANNOUNCE_ADDRESS, httpService.getBindAddress().getHostName());
int announcePort = cConf.getInt(Constants.Dataset.Manager.ANNOUNCE_PORT, httpService.getBindAddress().getPort());
InetSocketAddress socketAddress = new InetSocketAddress(announceAddress, announcePort);
URIScheme scheme = httpService.isSSLEnabled() ? URIScheme.HTTPS : URIScheme.HTTP;
LOG.info("Announcing DatasetService for discovery...");
// Register the service
cancelDiscovery = discoveryService.register(ResolvingDiscoverable.of(scheme.createDiscoverable(Constants.Service.DATASET_MANAGER, socketAddress)));
LOG.info("DatasetService started successfully on {}", socketAddress);
} catch (Throwable t) {
try {
doShutdown();
} catch (Throwable shutdownError) {
t.addSuppressed(shutdownError);
}
notifyFailed(t);
}
}
Aggregations