Search in sources :

Example 1 with StreamService

use of co.cask.cdap.data.stream.service.StreamService 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 SecurityModules().getInMemoryModules(), new NotificationServiceRuntimeModule().getInMemoryModules(), new AppFabricTestModule(conf)).with(new AbstractModule() {

        @Override
        protected void configure() {
            install(new StreamServiceRuntimeModule().getStandaloneModules());
            // 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(StreamConsumerStateStoreFactory.class).to(LevelDBStreamConsumerStateStoreFactory.class).in(Singleton.class);
            bind(StreamAdmin.class).to(FileStreamAdmin.class).in(Singleton.class);
            bind(StreamConsumerFactory.class).to(LevelDBStreamFileConsumerFactory.class).in(Singleton.class);
            bind(StreamFileWriterFactory.class).to(LocationStreamFileWriterFactory.class).in(Singleton.class);
            bind(PrivilegesManager.class).to(NoOpAuthorizer.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();
    dsOpService = injector.getInstance(DatasetOpExecutor.class);
    dsOpService.startAndWait();
    datasetService = injector.getInstance(DatasetService.class);
    datasetService.startAndWait();
    appFabricServer = injector.getInstance(AppFabricServer.class);
    appFabricServer.startAndWait();
    metricsQueryService = injector.getInstance(MetricsQueryService.class);
    metricsQueryService.startAndWait();
    metricsCollectionService = injector.getInstance(MetricsCollectionService.class);
    metricsCollectionService.startAndWait();
    notificationService = injector.getInstance(NotificationService.class);
    notificationService.startAndWait();
    streamService = injector.getInstance(StreamService.class);
    streamService.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();
    Map<String, Integer> serviceMap = Maps.newHashMap();
    for (Map.Entry<Integer, String> entry : router.getServiceLookup().getServiceMap().entrySet()) {
        serviceMap.put(entry.getValue(), entry.getKey());
    }
    port = serviceMap.get(Constants.Service.GATEWAY);
    return injector;
}
Also used : InetSocketAddress(java.net.InetSocketAddress) AppFabricServer(co.cask.cdap.internal.app.services.AppFabricServer) NoOpAuthorizer(co.cask.cdap.security.spi.authorization.NoOpAuthorizer) DatasetService(co.cask.cdap.data2.datafabric.dataset.service.DatasetService) NotificationServiceRuntimeModule(co.cask.cdap.notifications.guice.NotificationServiceRuntimeModule) StreamConsumerFactory(co.cask.cdap.data2.transaction.stream.StreamConsumerFactory) SecurityModules(co.cask.cdap.security.guice.SecurityModules) StreamServiceRuntimeModule(co.cask.cdap.data.stream.service.StreamServiceRuntimeModule) StreamService(co.cask.cdap.data.stream.service.StreamService) MetricsQueryService(co.cask.cdap.metrics.query.MetricsQueryService) MetricsCollectionService(co.cask.cdap.api.metrics.MetricsCollectionService) NamespaceAdmin(co.cask.cdap.common.namespace.NamespaceAdmin) MessagingService(co.cask.cdap.messaging.MessagingService) MetricsCollectionService(co.cask.cdap.api.metrics.MetricsCollectionService) MetricsQueryService(co.cask.cdap.metrics.query.MetricsQueryService) StreamService(co.cask.cdap.data.stream.service.StreamService) NotificationService(co.cask.cdap.notifications.service.NotificationService) DatasetService(co.cask.cdap.data2.datafabric.dataset.service.DatasetService) Service(com.google.common.util.concurrent.Service) NotificationService(co.cask.cdap.notifications.service.NotificationService) DatasetOpExecutor(co.cask.cdap.data2.datafabric.dataset.service.executor.DatasetOpExecutor) DefaultOwnerAdmin(co.cask.cdap.security.impersonation.DefaultOwnerAdmin) CConfiguration(co.cask.cdap.common.conf.CConfiguration) NettyRouter(co.cask.cdap.gateway.router.NettyRouter) AbstractModule(com.google.inject.AbstractModule) MessagingService(co.cask.cdap.messaging.MessagingService) StreamAdmin(co.cask.cdap.data2.transaction.stream.StreamAdmin) FileStreamAdmin(co.cask.cdap.data2.transaction.stream.FileStreamAdmin) StreamFileWriterFactory(co.cask.cdap.data.stream.StreamFileWriterFactory) LocationStreamFileWriterFactory(co.cask.cdap.data.runtime.LocationStreamFileWriterFactory) Singleton(com.google.inject.Singleton) TransactionManager(org.apache.tephra.TransactionManager) MockLogReader(co.cask.cdap.gateway.handlers.log.MockLogReader) LogReader(co.cask.cdap.logging.read.LogReader) AppFabricTestModule(co.cask.cdap.internal.guice.AppFabricTestModule) Map(java.util.Map) StreamConsumerStateStoreFactory(co.cask.cdap.data2.transaction.stream.StreamConsumerStateStoreFactory) LevelDBStreamConsumerStateStoreFactory(co.cask.cdap.data2.transaction.stream.leveldb.LevelDBStreamConsumerStateStoreFactory)

Example 2 with StreamService

use of co.cask.cdap.data.stream.service.StreamService in project cdap by caskdata.

the class AppFabricTestBase method initializeAndStartServices.

protected static void initializeAndStartServices(CConfiguration cConf, @Nullable SConfiguration sConf) throws Exception {
    injector = Guice.createInjector(Modules.override(new AppFabricTestModule(cConf, sConf)).with(new AbstractModule() {

        @Override
        protected void configure() {
            // needed because we set Kerberos to true in DefaultNamespaceAdminTest
            bind(UGIProvider.class).to(CurrentUGIProvider.class);
        }
    }));
    messagingService = injector.getInstance(MessagingService.class);
    if (messagingService instanceof Service) {
        ((Service) messagingService).startAndWait();
    }
    txManager = injector.getInstance(TransactionManager.class);
    txManager.startAndWait();
    dsOpService = injector.getInstance(DatasetOpExecutor.class);
    dsOpService.startAndWait();
    remoteSysOpService = injector.getInstance(RemoteSystemOperationsService.class);
    remoteSysOpService.startAndWait();
    datasetService = injector.getInstance(DatasetService.class);
    datasetService.startAndWait();
    appFabricServer = injector.getInstance(AppFabricServer.class);
    appFabricServer.startAndWait();
    DiscoveryServiceClient discoveryClient = injector.getInstance(DiscoveryServiceClient.class);
    ServiceDiscovered appFabricHttpDiscovered = discoveryClient.discover(Constants.Service.APP_FABRIC_HTTP);
    EndpointStrategy endpointStrategy = new RandomEndpointStrategy(appFabricHttpDiscovered);
    port = endpointStrategy.pick(1, TimeUnit.SECONDS).getSocketAddress().getPort();
    txClient = injector.getInstance(TransactionSystemClient.class);
    metricsCollectionService = injector.getInstance(MetricsCollectionService.class);
    metricsCollectionService.startAndWait();
    metricsService = injector.getInstance(MetricsQueryService.class);
    metricsService.startAndWait();
    streamService = injector.getInstance(StreamService.class);
    streamService.startAndWait();
    serviceStore = injector.getInstance(ServiceStore.class);
    serviceStore.startAndWait();
    metadataService = injector.getInstance(MetadataService.class);
    metadataService.startAndWait();
    locationFactory = getInjector().getInstance(LocationFactory.class);
    streamClient = new StreamClient(getClientConfig(discoveryClient, Constants.Service.STREAMS));
    datasetClient = new DatasetClient(getClientConfig(discoveryClient, Constants.Service.DATASET_MANAGER));
    createNamespaces();
}
Also used : StreamService(co.cask.cdap.data.stream.service.StreamService) DiscoveryServiceClient(org.apache.twill.discovery.DiscoveryServiceClient) MetricsQueryService(co.cask.cdap.metrics.query.MetricsQueryService) MetricsCollectionService(co.cask.cdap.api.metrics.MetricsCollectionService) AppFabricServer(co.cask.cdap.internal.app.services.AppFabricServer) MetricsCollectionService(co.cask.cdap.api.metrics.MetricsCollectionService) MetadataService(co.cask.cdap.metadata.MetadataService) Service(com.google.common.util.concurrent.Service) MessagingService(co.cask.cdap.messaging.MessagingService) MetricsQueryService(co.cask.cdap.metrics.query.MetricsQueryService) StreamService(co.cask.cdap.data.stream.service.StreamService) RemoteSystemOperationsService(co.cask.cdap.gateway.handlers.meta.RemoteSystemOperationsService) DatasetService(co.cask.cdap.data2.datafabric.dataset.service.DatasetService) DatasetService(co.cask.cdap.data2.datafabric.dataset.service.DatasetService) DatasetOpExecutor(co.cask.cdap.data2.datafabric.dataset.service.executor.DatasetOpExecutor) RemoteSystemOperationsService(co.cask.cdap.gateway.handlers.meta.RemoteSystemOperationsService) ServiceDiscovered(org.apache.twill.discovery.ServiceDiscovered) MetadataService(co.cask.cdap.metadata.MetadataService) AbstractModule(com.google.inject.AbstractModule) MessagingService(co.cask.cdap.messaging.MessagingService) LocationFactory(org.apache.twill.filesystem.LocationFactory) TransactionSystemClient(org.apache.tephra.TransactionSystemClient) DatasetClient(co.cask.cdap.client.DatasetClient) ServiceStore(co.cask.cdap.app.store.ServiceStore) RandomEndpointStrategy(co.cask.cdap.common.discovery.RandomEndpointStrategy) EndpointStrategy(co.cask.cdap.common.discovery.EndpointStrategy) StreamClient(co.cask.cdap.client.StreamClient) TransactionManager(org.apache.tephra.TransactionManager) CurrentUGIProvider(co.cask.cdap.security.impersonation.CurrentUGIProvider) AppFabricTestModule(co.cask.cdap.internal.guice.AppFabricTestModule) RandomEndpointStrategy(co.cask.cdap.common.discovery.RandomEndpointStrategy)

Example 3 with StreamService

use of co.cask.cdap.data.stream.service.StreamService in project cdap by caskdata.

the class BaseHiveExploreServiceTest method initialize.

protected static void initialize(CConfiguration cConf, TemporaryFolder tmpFolder, boolean useStandalone, boolean enableAuthorization) throws Exception {
    if (!runBefore) {
        return;
    }
    Configuration hConf = new Configuration();
    if (enableAuthorization) {
        LocationFactory locationFactory = new LocalLocationFactory(tmpFolder.newFolder());
        Location authExtensionJar = AppJarHelper.createDeploymentJar(locationFactory, InMemoryAuthorizer.class);
        cConf.setBoolean(Constants.Security.ENABLED, true);
        cConf.setBoolean(Constants.Security.Authorization.ENABLED, true);
        cConf.set(Constants.Security.Authorization.EXTENSION_JAR_PATH, authExtensionJar.toURI().getPath());
        cConf.setBoolean(Constants.Security.KERBEROS_ENABLED, false);
        cConf.setInt(Constants.Security.Authorization.CACHE_MAX_ENTRIES, 0);
    }
    List<Module> modules = useStandalone ? createStandaloneModules(cConf, hConf, tmpFolder) : createInMemoryModules(cConf, hConf, tmpFolder);
    injector = Guice.createInjector(modules);
    transactionManager = injector.getInstance(TransactionManager.class);
    transactionManager.startAndWait();
    transactionSystemClient = injector.getInstance(TransactionSystemClient.class);
    dsOpService = injector.getInstance(DatasetOpExecutor.class);
    dsOpService.startAndWait();
    datasetService = injector.getInstance(DatasetService.class);
    datasetService.startAndWait();
    exploreExecutorService = injector.getInstance(ExploreExecutorService.class);
    exploreExecutorService.startAndWait();
    datasetFramework = injector.getInstance(DatasetFramework.class);
    exploreClient = injector.getInstance(DiscoveryExploreClient.class);
    exploreService = injector.getInstance(ExploreService.class);
    exploreClient.ping();
    notificationService = injector.getInstance(NotificationService.class);
    notificationService.startAndWait();
    streamService = injector.getInstance(StreamService.class);
    streamService.startAndWait();
    streamHttpService = injector.getInstance(StreamHttpService.class);
    streamHttpService.startAndWait();
    exploreTableManager = injector.getInstance(ExploreTableManager.class);
    streamAdmin = injector.getInstance(StreamAdmin.class);
    streamMetaStore = injector.getInstance(StreamMetaStore.class);
    namespaceAdmin = injector.getInstance(NamespaceAdmin.class);
    namespacedLocationFactory = injector.getInstance(NamespacedLocationFactory.class);
    // create namespaces
    // This happens when you create a namespace via REST APIs. However, since we do not start AppFabricServer in
    // Explore tests, simulating that scenario by explicitly calling DatasetFramework APIs.
    createNamespace(NamespaceId.DEFAULT);
    createNamespace(NAMESPACE_ID);
    createNamespace(OTHER_NAMESPACE_ID);
}
Also used : StreamService(co.cask.cdap.data.stream.service.StreamService) CConfiguration(co.cask.cdap.common.conf.CConfiguration) Configuration(org.apache.hadoop.conf.Configuration) NamespaceAdmin(co.cask.cdap.common.namespace.NamespaceAdmin) DatasetService(co.cask.cdap.data2.datafabric.dataset.service.DatasetService) NotificationService(co.cask.cdap.notifications.service.NotificationService) DatasetOpExecutor(co.cask.cdap.data2.datafabric.dataset.service.executor.DatasetOpExecutor) StreamHttpService(co.cask.cdap.data.stream.service.StreamHttpService) NamespacedLocationFactory(co.cask.cdap.common.namespace.NamespacedLocationFactory) NamespacedLocationFactory(co.cask.cdap.common.namespace.NamespacedLocationFactory) LocalLocationFactory(org.apache.twill.filesystem.LocalLocationFactory) LocationFactory(org.apache.twill.filesystem.LocationFactory) DatasetFramework(co.cask.cdap.data2.dataset2.DatasetFramework) TransactionSystemClient(org.apache.tephra.TransactionSystemClient) DiscoveryExploreClient(co.cask.cdap.explore.client.DiscoveryExploreClient) StreamAdmin(co.cask.cdap.data2.transaction.stream.StreamAdmin) TransactionManager(org.apache.tephra.TransactionManager) ExploreExecutorService(co.cask.cdap.explore.executor.ExploreExecutorService) StreamMetaStore(co.cask.cdap.data.stream.service.StreamMetaStore) AuthorizationEnforcementModule(co.cask.cdap.security.authorization.AuthorizationEnforcementModule) NonCustomLocationUnitTestModule(co.cask.cdap.common.guice.NonCustomLocationUnitTestModule) ExploreRuntimeModule(co.cask.cdap.explore.guice.ExploreRuntimeModule) ExploreClientModule(co.cask.cdap.explore.guice.ExploreClientModule) MetricsClientRuntimeModule(co.cask.cdap.metrics.guice.MetricsClientRuntimeModule) NamespaceClientRuntimeModule(co.cask.cdap.common.namespace.guice.NamespaceClientRuntimeModule) ConfigModule(co.cask.cdap.common.guice.ConfigModule) AbstractModule(com.google.inject.AbstractModule) Module(com.google.inject.Module) NotificationServiceRuntimeModule(co.cask.cdap.notifications.guice.NotificationServiceRuntimeModule) DiscoveryRuntimeModule(co.cask.cdap.common.guice.DiscoveryRuntimeModule) NamespaceClientUnitTestModule(co.cask.cdap.common.guice.NamespaceClientUnitTestModule) StreamServiceRuntimeModule(co.cask.cdap.data.stream.service.StreamServiceRuntimeModule) AuthorizationTestModule(co.cask.cdap.security.authorization.AuthorizationTestModule) IOModule(co.cask.cdap.common.guice.IOModule) LocalLocationFactory(org.apache.twill.filesystem.LocalLocationFactory) Location(org.apache.twill.filesystem.Location)

Aggregations

StreamService (co.cask.cdap.data.stream.service.StreamService)3 DatasetService (co.cask.cdap.data2.datafabric.dataset.service.DatasetService)3 DatasetOpExecutor (co.cask.cdap.data2.datafabric.dataset.service.executor.DatasetOpExecutor)3 AbstractModule (com.google.inject.AbstractModule)3 TransactionManager (org.apache.tephra.TransactionManager)3 MetricsCollectionService (co.cask.cdap.api.metrics.MetricsCollectionService)2 CConfiguration (co.cask.cdap.common.conf.CConfiguration)2 NamespaceAdmin (co.cask.cdap.common.namespace.NamespaceAdmin)2 StreamServiceRuntimeModule (co.cask.cdap.data.stream.service.StreamServiceRuntimeModule)2 StreamAdmin (co.cask.cdap.data2.transaction.stream.StreamAdmin)2 AppFabricServer (co.cask.cdap.internal.app.services.AppFabricServer)2 AppFabricTestModule (co.cask.cdap.internal.guice.AppFabricTestModule)2 MessagingService (co.cask.cdap.messaging.MessagingService)2 MetricsQueryService (co.cask.cdap.metrics.query.MetricsQueryService)2 NotificationServiceRuntimeModule (co.cask.cdap.notifications.guice.NotificationServiceRuntimeModule)2 NotificationService (co.cask.cdap.notifications.service.NotificationService)2 Service (com.google.common.util.concurrent.Service)2 ServiceStore (co.cask.cdap.app.store.ServiceStore)1 DatasetClient (co.cask.cdap.client.DatasetClient)1 StreamClient (co.cask.cdap.client.StreamClient)1