Search in sources :

Example 1 with DatasetMetricsReporter

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();
}
Also used : DatasetMetricsReporter(co.cask.cdap.data2.metrics.DatasetMetricsReporter)

Example 2 with DatasetMetricsReporter

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();
    }
}
Also used : DatasetMetricsReporter(co.cask.cdap.data2.metrics.DatasetMetricsReporter) ServiceDiscovered(org.apache.twill.discovery.ServiceDiscovered)

Example 3 with DatasetMetricsReporter

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");
}
Also used : DatasetMetricsReporter(io.cdap.cdap.data2.metrics.DatasetMetricsReporter)

Example 4 with DatasetMetricsReporter

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);
    }
}
Also used : Iterables(com.google.common.collect.Iterables) MoreExecutors(com.google.common.util.concurrent.MoreExecutors) HttpsEnabler(io.cdap.cdap.common.security.HttpsEnabler) ResolvingDiscoverable(io.cdap.cdap.common.discovery.ResolvingDiscoverable) ChannelPipelineModifier(io.cdap.http.ChannelPipelineModifier) Inject(com.google.inject.Inject) MetricsReporterHook(io.cdap.cdap.common.metrics.MetricsReporterHook) ChannelInboundHandlerAdapter(io.netty.channel.ChannelInboundHandlerAdapter) DatasetMetricsReporter(io.cdap.cdap.data2.metrics.DatasetMetricsReporter) LoggerFactory(org.slf4j.LoggerFactory) TimeoutException(java.util.concurrent.TimeoutException) ServiceDiscovered(org.apache.twill.discovery.ServiceDiscovered) SettableFuture(com.google.common.util.concurrent.SettableFuture) ChannelHandlerContext(io.netty.channel.ChannelHandlerContext) DiscoveryServiceClient(org.apache.twill.discovery.DiscoveryServiceClient) NettyHttpService(io.cdap.http.NettyHttpService) AbstractService(com.google.common.util.concurrent.AbstractService) Cancellable(org.apache.twill.common.Cancellable) Objects(com.google.common.base.Objects) DiscoveryService(org.apache.twill.discovery.DiscoveryService) HttpRequest(io.netty.handler.codec.http.HttpRequest) Logger(org.slf4j.Logger) URIScheme(io.cdap.cdap.common.discovery.URIScheme) Set(java.util.Set) ChannelPipeline(io.netty.channel.ChannelPipeline) InetSocketAddress(java.net.InetSocketAddress) MetricsCollectionService(io.cdap.cdap.api.metrics.MetricsCollectionService) ExecutionException(java.util.concurrent.ExecutionException) TimeUnit(java.util.concurrent.TimeUnit) CommonNettyHttpServiceBuilder(io.cdap.cdap.common.http.CommonNettyHttpServiceBuilder) CConfiguration(io.cdap.cdap.common.conf.CConfiguration) Constants(io.cdap.cdap.common.conf.Constants) Collections(java.util.Collections) SConfiguration(io.cdap.cdap.common.conf.SConfiguration) InetSocketAddress(java.net.InetSocketAddress) URIScheme(io.cdap.cdap.common.discovery.URIScheme) DatasetMetricsReporter(io.cdap.cdap.data2.metrics.DatasetMetricsReporter) ServiceDiscovered(org.apache.twill.discovery.ServiceDiscovered)

Aggregations

DatasetMetricsReporter (co.cask.cdap.data2.metrics.DatasetMetricsReporter)2 DatasetMetricsReporter (io.cdap.cdap.data2.metrics.DatasetMetricsReporter)2 ServiceDiscovered (org.apache.twill.discovery.ServiceDiscovered)2 Objects (com.google.common.base.Objects)1 Iterables (com.google.common.collect.Iterables)1 AbstractService (com.google.common.util.concurrent.AbstractService)1 MoreExecutors (com.google.common.util.concurrent.MoreExecutors)1 SettableFuture (com.google.common.util.concurrent.SettableFuture)1 Inject (com.google.inject.Inject)1 MetricsCollectionService (io.cdap.cdap.api.metrics.MetricsCollectionService)1 CConfiguration (io.cdap.cdap.common.conf.CConfiguration)1 Constants (io.cdap.cdap.common.conf.Constants)1 SConfiguration (io.cdap.cdap.common.conf.SConfiguration)1 ResolvingDiscoverable (io.cdap.cdap.common.discovery.ResolvingDiscoverable)1 URIScheme (io.cdap.cdap.common.discovery.URIScheme)1 CommonNettyHttpServiceBuilder (io.cdap.cdap.common.http.CommonNettyHttpServiceBuilder)1 MetricsReporterHook (io.cdap.cdap.common.metrics.MetricsReporterHook)1 HttpsEnabler (io.cdap.cdap.common.security.HttpsEnabler)1 ChannelPipelineModifier (io.cdap.http.ChannelPipelineModifier)1 NettyHttpService (io.cdap.http.NettyHttpService)1