Search in sources :

Example 1 with MetricsQueryService

use of io.cdap.cdap.metrics.query.MetricsQueryService in project cdap by caskdata.

the class GatewayTestBase method startGateway.

public static Injector startGateway(final CConfiguration conf) throws Exception {
    // Set up our Guice injections
    injector = Guice.createInjector(Modules.override(new AbstractModule() {

        @Override
        protected void configure() {
        }

        @SuppressWarnings("unused")
        @Provides
        @Named(Constants.Router.ADDRESS)
        public final InetAddress providesHostname(CConfiguration cConf) {
            return Networks.resolve(cConf.get(Constants.Router.ADDRESS), new InetSocketAddress("localhost", 0).getAddress());
        }
    }, new CoreSecurityRuntimeModule().getInMemoryModules(), new ExternalAuthenticationModule(), new AppFabricTestModule(conf)).with(new AbstractModule() {

        @Override
        protected void configure() {
            // It's a bit hacky to add it here. Need to refactor these
            // bindings out as it overlaps with
            // AppFabricServiceModule
            bind(LogReader.class).to(MockLogReader.class).in(Scopes.SINGLETON);
            bind(PermissionManager.class).to(NoOpAccessController.class);
            bind(OwnerAdmin.class).to(DefaultOwnerAdmin.class);
        }
    }));
    messagingService = injector.getInstance(MessagingService.class);
    if (messagingService instanceof Service) {
        ((Service) messagingService).startAndWait();
    }
    txService = injector.getInstance(TransactionManager.class);
    txService.startAndWait();
    // Define all StructuredTable before starting any services that need StructuredTable
    StoreDefinition.createAllTables(injector.getInstance(StructuredTableAdmin.class));
    metadataStorage = injector.getInstance(MetadataStorage.class);
    metadataStorage.createIndex();
    metadataService = injector.getInstance(MetadataService.class);
    metadataService.startAndWait();
    dsOpService = injector.getInstance(DatasetOpExecutorService.class);
    dsOpService.startAndWait();
    datasetService = injector.getInstance(DatasetService.class);
    datasetService.startAndWait();
    appFabricServer = injector.getInstance(AppFabricServer.class);
    appFabricServer.startAndWait();
    logQueryService = injector.getInstance(LogQueryService.class);
    logQueryService.startAndWait();
    metricsQueryService = injector.getInstance(MetricsQueryService.class);
    metricsQueryService.startAndWait();
    metricsCollectionService = injector.getInstance(MetricsCollectionService.class);
    metricsCollectionService.startAndWait();
    namespaceAdmin = injector.getInstance(NamespaceAdmin.class);
    namespaceAdmin.create(TEST_NAMESPACE_META1);
    namespaceAdmin.create(TEST_NAMESPACE_META2);
    // Restart handlers to check if they are resilient across restarts.
    router = injector.getInstance(NettyRouter.class);
    router.startAndWait();
    port = router.getBoundAddress().orElseThrow(IllegalStateException::new).getPort();
    return injector;
}
Also used : InetSocketAddress(java.net.InetSocketAddress) StructuredTableAdmin(io.cdap.cdap.spi.data.StructuredTableAdmin) AppFabricServer(io.cdap.cdap.internal.app.services.AppFabricServer) DatasetService(io.cdap.cdap.data2.datafabric.dataset.service.DatasetService) MetadataService(io.cdap.cdap.metadata.MetadataService) LogQueryService(io.cdap.cdap.logging.service.LogQueryService) CoreSecurityRuntimeModule(io.cdap.cdap.security.guice.CoreSecurityRuntimeModule) NoOpAccessController(io.cdap.cdap.security.spi.authorization.NoOpAccessController) MetricsQueryService(io.cdap.cdap.metrics.query.MetricsQueryService) ExternalAuthenticationModule(io.cdap.cdap.security.guice.ExternalAuthenticationModule) MetricsCollectionService(io.cdap.cdap.api.metrics.MetricsCollectionService) NamespaceAdmin(io.cdap.cdap.common.namespace.NamespaceAdmin) MetricsQueryService(io.cdap.cdap.metrics.query.MetricsQueryService) MessagingService(io.cdap.cdap.messaging.MessagingService) DatasetService(io.cdap.cdap.data2.datafabric.dataset.service.DatasetService) LogQueryService(io.cdap.cdap.logging.service.LogQueryService) DatasetOpExecutorService(io.cdap.cdap.data2.datafabric.dataset.service.executor.DatasetOpExecutorService) Service(com.google.common.util.concurrent.Service) MetricsCollectionService(io.cdap.cdap.api.metrics.MetricsCollectionService) MetadataService(io.cdap.cdap.metadata.MetadataService) DefaultOwnerAdmin(io.cdap.cdap.security.impersonation.DefaultOwnerAdmin) CConfiguration(io.cdap.cdap.common.conf.CConfiguration) NettyRouter(io.cdap.cdap.gateway.router.NettyRouter) AbstractModule(com.google.inject.AbstractModule) MessagingService(io.cdap.cdap.messaging.MessagingService) TransactionManager(org.apache.tephra.TransactionManager) DatasetOpExecutorService(io.cdap.cdap.data2.datafabric.dataset.service.executor.DatasetOpExecutorService) MockLogReader(io.cdap.cdap.gateway.handlers.log.MockLogReader) LogReader(io.cdap.cdap.logging.read.LogReader) MetadataStorage(io.cdap.cdap.spi.metadata.MetadataStorage) AppFabricTestModule(io.cdap.cdap.internal.guice.AppFabricTestModule)

Example 2 with MetricsQueryService

use of io.cdap.cdap.metrics.query.MetricsQueryService in project cdap by caskdata.

the class MetricsAdminSubscriberServiceTest method init.

@BeforeClass
public static void init() throws IOException {
    CConfiguration cConf = CConfiguration.create();
    cConf.set(Constants.CFG_LOCAL_DATA_DIR, TEMP_FOLDER.newFolder().getAbsolutePath());
    // Shorten delay to speed up test
    cConf.setLong(Constants.Metrics.ADMIN_POLL_DELAY_MILLIS, 100L);
    injector = Guice.createInjector(new ConfigModule(cConf), new IOModule(), new InMemoryDiscoveryModule(), new MessagingServerRuntimeModule().getStandaloneModules(), new SystemDatasetRuntimeModule().getStandaloneModules(), // distributed mode. It requires bindings that are too cumbersome to construct them one by one.
    new PrivateModule() {

        @Override
        protected void configure() {
            install(new MetricsHandlerModule());
            expose(MetricsQueryService.class);
            install(new MetricsStoreModule());
            bind(MetricsCollectionService.class).to(LocalMetricsCollectionService.class).in(Scopes.SINGLETON);
            expose(MetricsCollectionService.class);
            // Bind the RemoteMetricsSystemClient for testing.
            bind(MetricsSystemClient.class).to(DirectMetricsSystemClient.class);
            expose(MetricsSystemClient.class);
            // Bind the admin subscriber
            bind(MetricsAdminSubscriberService.class).in(Scopes.SINGLETON);
            expose(MetricsAdminSubscriberService.class);
        }
    });
    messagingService = injector.getInstance(MessagingService.class);
    metricsCollectionService = injector.getInstance(MetricsCollectionService.class);
    metricsQueryService = injector.getInstance(MetricsQueryService.class);
    if (messagingService instanceof Service) {
        ((Service) messagingService).startAndWait();
    }
    metricsCollectionService.startAndWait();
    metricsQueryService.startAndWait();
}
Also used : IOModule(io.cdap.cdap.common.guice.IOModule) LocalMetricsCollectionService(io.cdap.cdap.metrics.collect.LocalMetricsCollectionService) InMemoryDiscoveryModule(io.cdap.cdap.common.guice.InMemoryDiscoveryModule) MetricsStoreModule(io.cdap.cdap.metrics.guice.MetricsStoreModule) MetricsQueryService(io.cdap.cdap.metrics.query.MetricsQueryService) LocalMetricsCollectionService(io.cdap.cdap.metrics.collect.LocalMetricsCollectionService) MetricsCollectionService(io.cdap.cdap.api.metrics.MetricsCollectionService) ConfigModule(io.cdap.cdap.common.guice.ConfigModule) LocalMetricsCollectionService(io.cdap.cdap.metrics.collect.LocalMetricsCollectionService) MetricsQueryService(io.cdap.cdap.metrics.query.MetricsQueryService) MessagingService(io.cdap.cdap.messaging.MessagingService) Service(com.google.common.util.concurrent.Service) MetricsCollectionService(io.cdap.cdap.api.metrics.MetricsCollectionService) MessagingServerRuntimeModule(io.cdap.cdap.messaging.guice.MessagingServerRuntimeModule) CConfiguration(io.cdap.cdap.common.conf.CConfiguration) MessagingService(io.cdap.cdap.messaging.MessagingService) MetricsHandlerModule(io.cdap.cdap.metrics.guice.MetricsHandlerModule) SystemDatasetRuntimeModule(io.cdap.cdap.data.runtime.SystemDatasetRuntimeModule) MetricsSystemClient(io.cdap.cdap.api.metrics.MetricsSystemClient) PrivateModule(com.google.inject.PrivateModule) BeforeClass(org.junit.BeforeClass)

Aggregations

Service (com.google.common.util.concurrent.Service)2 MetricsCollectionService (io.cdap.cdap.api.metrics.MetricsCollectionService)2 CConfiguration (io.cdap.cdap.common.conf.CConfiguration)2 MessagingService (io.cdap.cdap.messaging.MessagingService)2 MetricsQueryService (io.cdap.cdap.metrics.query.MetricsQueryService)2 AbstractModule (com.google.inject.AbstractModule)1 PrivateModule (com.google.inject.PrivateModule)1 MetricsSystemClient (io.cdap.cdap.api.metrics.MetricsSystemClient)1 ConfigModule (io.cdap.cdap.common.guice.ConfigModule)1 IOModule (io.cdap.cdap.common.guice.IOModule)1 InMemoryDiscoveryModule (io.cdap.cdap.common.guice.InMemoryDiscoveryModule)1 NamespaceAdmin (io.cdap.cdap.common.namespace.NamespaceAdmin)1 SystemDatasetRuntimeModule (io.cdap.cdap.data.runtime.SystemDatasetRuntimeModule)1 DatasetService (io.cdap.cdap.data2.datafabric.dataset.service.DatasetService)1 DatasetOpExecutorService (io.cdap.cdap.data2.datafabric.dataset.service.executor.DatasetOpExecutorService)1 MockLogReader (io.cdap.cdap.gateway.handlers.log.MockLogReader)1 NettyRouter (io.cdap.cdap.gateway.router.NettyRouter)1 AppFabricServer (io.cdap.cdap.internal.app.services.AppFabricServer)1 AppFabricTestModule (io.cdap.cdap.internal.guice.AppFabricTestModule)1 LogReader (io.cdap.cdap.logging.read.LogReader)1