Search in sources :

Example 61 with ConfigModule

use of co.cask.cdap.common.guice.ConfigModule in project cdap by caskdata.

the class RemoteDatasetFrameworkTest method before.

@Before
public void before() throws Exception {
    cConf.set(Constants.Service.MASTER_SERVICES_BIND_ADDRESS, "localhost");
    cConf.setBoolean(Constants.Dangerous.UNRECOVERABLE_RESET, true);
    Configuration txConf = HBaseConfiguration.create();
    CConfigurationUtil.copyTxProperties(cConf, txConf);
    // ok to pass null, since the impersonator won't actually be called, if kerberos security is not enabled
    Impersonator impersonator = new DefaultImpersonator(cConf, null);
    // TODO: Refactor to use injector for everything
    Injector injector = Guice.createInjector(new ConfigModule(cConf, txConf), new DiscoveryRuntimeModule().getInMemoryModules(), new AuthorizationTestModule(), new AuthorizationEnforcementModule().getInMemoryModules(), new AuthenticationContextModules().getMasterModule(), new TransactionInMemoryModule(), new AbstractModule() {

        @Override
        protected void configure() {
            bind(MetricsCollectionService.class).to(NoOpMetricsCollectionService.class).in(Singleton.class);
            install(new FactoryModuleBuilder().implement(DatasetDefinitionRegistry.class, DefaultDatasetDefinitionRegistry.class).build(DatasetDefinitionRegistryFactory.class));
            // through the injector, we only need RemoteDatasetFramework in these tests
            bind(RemoteDatasetFramework.class);
        }
    });
    // Tx Manager to support working with datasets
    txManager = new TransactionManager(txConf);
    txManager.startAndWait();
    InMemoryTxSystemClient txSystemClient = new InMemoryTxSystemClient(txManager);
    TransactionSystemClientService txSystemClientService = new DelegatingTransactionSystemClientService(txSystemClient);
    DiscoveryService discoveryService = injector.getInstance(DiscoveryService.class);
    DiscoveryServiceClient discoveryServiceClient = injector.getInstance(DiscoveryServiceClient.class);
    MetricsCollectionService metricsCollectionService = injector.getInstance(MetricsCollectionService.class);
    AuthenticationContext authenticationContext = injector.getInstance(AuthenticationContext.class);
    framework = new RemoteDatasetFramework(cConf, discoveryServiceClient, registryFactory, authenticationContext);
    SystemDatasetInstantiatorFactory datasetInstantiatorFactory = new SystemDatasetInstantiatorFactory(locationFactory, framework, cConf);
    DatasetAdminService datasetAdminService = new DatasetAdminService(framework, cConf, locationFactory, datasetInstantiatorFactory, new NoOpMetadataStore(), impersonator);
    ImmutableSet<HttpHandler> handlers = ImmutableSet.<HttpHandler>of(new DatasetAdminOpHTTPHandler(datasetAdminService));
    opExecutorService = new DatasetOpExecutorService(cConf, discoveryService, metricsCollectionService, handlers);
    opExecutorService.startAndWait();
    ImmutableMap<String, DatasetModule> modules = ImmutableMap.<String, DatasetModule>builder().put("memoryTable", new InMemoryTableModule()).put("core", new CoreDatasetsModule()).putAll(DatasetMetaTableUtil.getModules()).build();
    InMemoryDatasetFramework mdsFramework = new InMemoryDatasetFramework(registryFactory, modules);
    DiscoveryExploreClient exploreClient = new DiscoveryExploreClient(discoveryServiceClient, authenticationContext);
    ExploreFacade exploreFacade = new ExploreFacade(exploreClient, cConf);
    TransactionExecutorFactory txExecutorFactory = new DynamicTransactionExecutorFactory(txSystemClient);
    AuthorizationEnforcer authorizationEnforcer = injector.getInstance(AuthorizationEnforcer.class);
    DatasetTypeManager typeManager = new DatasetTypeManager(cConf, locationFactory, txSystemClientService, txExecutorFactory, mdsFramework, impersonator);
    DatasetInstanceManager instanceManager = new DatasetInstanceManager(txSystemClientService, txExecutorFactory, mdsFramework);
    PrivilegesManager privilegesManager = injector.getInstance(PrivilegesManager.class);
    DatasetTypeService typeService = new DatasetTypeService(typeManager, namespaceQueryAdmin, namespacedLocationFactory, authorizationEnforcer, privilegesManager, authenticationContext, cConf, impersonator, txSystemClientService, mdsFramework, txExecutorFactory, DEFAULT_MODULES);
    DatasetOpExecutor opExecutor = new LocalDatasetOpExecutor(cConf, discoveryServiceClient, opExecutorService, authenticationContext);
    DatasetInstanceService instanceService = new DatasetInstanceService(typeService, instanceManager, opExecutor, exploreFacade, namespaceQueryAdmin, ownerAdmin, authorizationEnforcer, privilegesManager, authenticationContext);
    instanceService.setAuditPublisher(inMemoryAuditPublisher);
    service = new DatasetService(cConf, discoveryService, discoveryServiceClient, metricsCollectionService, new InMemoryDatasetOpExecutor(framework), new HashSet<DatasetMetricsReporter>(), typeService, instanceService);
    // Start dataset service, wait for it to be discoverable
    service.startAndWait();
    EndpointStrategy endpointStrategy = new RandomEndpointStrategy(discoveryServiceClient.discover(Constants.Service.DATASET_MANAGER));
    Preconditions.checkNotNull(endpointStrategy.pick(5, TimeUnit.SECONDS), "%s service is not up after 5 seconds", service);
    createNamespace(NamespaceId.SYSTEM);
    createNamespace(NAMESPACE_ID);
}
Also used : InMemoryDatasetOpExecutor(co.cask.cdap.data2.datafabric.dataset.service.executor.InMemoryDatasetOpExecutor) DiscoveryServiceClient(org.apache.twill.discovery.DiscoveryServiceClient) AuthenticationContext(co.cask.cdap.security.spi.authentication.AuthenticationContext) DatasetAdminOpHTTPHandler(co.cask.cdap.data2.datafabric.dataset.service.executor.DatasetAdminOpHTTPHandler) Configuration(org.apache.hadoop.conf.Configuration) HBaseConfiguration(org.apache.hadoop.hbase.HBaseConfiguration) TransactionInMemoryModule(org.apache.tephra.runtime.TransactionInMemoryModule) DatasetService(co.cask.cdap.data2.datafabric.dataset.service.DatasetService) AuthorizationEnforcer(co.cask.cdap.security.spi.authorization.AuthorizationEnforcer) DatasetTypeService(co.cask.cdap.data2.datafabric.dataset.service.DatasetTypeService) ExploreFacade(co.cask.cdap.explore.client.ExploreFacade) DynamicTransactionExecutorFactory(co.cask.cdap.data.runtime.DynamicTransactionExecutorFactory) TransactionExecutorFactory(co.cask.cdap.data2.transaction.TransactionExecutorFactory) NoOpMetadataStore(co.cask.cdap.data2.metadata.store.NoOpMetadataStore) EndpointStrategy(co.cask.cdap.common.discovery.EndpointStrategy) RandomEndpointStrategy(co.cask.cdap.common.discovery.RandomEndpointStrategy) Injector(com.google.inject.Injector) DiscoveryRuntimeModule(co.cask.cdap.common.guice.DiscoveryRuntimeModule) InMemoryDatasetFramework(co.cask.cdap.data2.dataset2.InMemoryDatasetFramework) HashSet(java.util.HashSet) HttpHandler(co.cask.http.HttpHandler) DatasetInstanceManager(co.cask.cdap.data2.datafabric.dataset.instance.DatasetInstanceManager) MetricsCollectionService(co.cask.cdap.api.metrics.MetricsCollectionService) NoOpMetricsCollectionService(co.cask.cdap.common.metrics.NoOpMetricsCollectionService) AuthenticationContextModules(co.cask.cdap.security.auth.context.AuthenticationContextModules) PrivilegesManager(co.cask.cdap.security.spi.authorization.PrivilegesManager) DefaultDatasetDefinitionRegistry(co.cask.cdap.data2.dataset2.DefaultDatasetDefinitionRegistry) DatasetDefinitionRegistry(co.cask.cdap.api.dataset.module.DatasetDefinitionRegistry) InMemoryTxSystemClient(org.apache.tephra.inmemory.InMemoryTxSystemClient) DatasetTypeManager(co.cask.cdap.data2.datafabric.dataset.type.DatasetTypeManager) InMemoryTableModule(co.cask.cdap.data2.dataset2.module.lib.inmemory.InMemoryTableModule) Singleton(com.google.inject.Singleton) TransactionManager(org.apache.tephra.TransactionManager) LocalDatasetOpExecutor(co.cask.cdap.data2.datafabric.dataset.service.executor.LocalDatasetOpExecutor) AuthorizationEnforcementModule(co.cask.cdap.security.authorization.AuthorizationEnforcementModule) DelegatingTransactionSystemClientService(co.cask.cdap.data2.transaction.DelegatingTransactionSystemClientService) ConfigModule(co.cask.cdap.common.guice.ConfigModule) FactoryModuleBuilder(com.google.inject.assistedinject.FactoryModuleBuilder) DynamicTransactionExecutorFactory(co.cask.cdap.data.runtime.DynamicTransactionExecutorFactory) DatasetModule(co.cask.cdap.api.dataset.module.DatasetModule) DiscoveryExploreClient(co.cask.cdap.explore.client.DiscoveryExploreClient) SystemDatasetInstantiatorFactory(co.cask.cdap.data.dataset.SystemDatasetInstantiatorFactory) DefaultDatasetDefinitionRegistry(co.cask.cdap.data2.dataset2.DefaultDatasetDefinitionRegistry) CoreDatasetsModule(co.cask.cdap.data2.dataset2.lib.table.CoreDatasetsModule) DatasetInstanceService(co.cask.cdap.data2.datafabric.dataset.service.DatasetInstanceService) TransactionSystemClientService(co.cask.cdap.data2.transaction.TransactionSystemClientService) DelegatingTransactionSystemClientService(co.cask.cdap.data2.transaction.DelegatingTransactionSystemClientService) DiscoveryService(org.apache.twill.discovery.DiscoveryService) DatasetAdminService(co.cask.cdap.data2.datafabric.dataset.service.executor.DatasetAdminService) LocalDatasetOpExecutor(co.cask.cdap.data2.datafabric.dataset.service.executor.LocalDatasetOpExecutor) DatasetOpExecutor(co.cask.cdap.data2.datafabric.dataset.service.executor.DatasetOpExecutor) InMemoryDatasetOpExecutor(co.cask.cdap.data2.datafabric.dataset.service.executor.InMemoryDatasetOpExecutor) DefaultImpersonator(co.cask.cdap.security.impersonation.DefaultImpersonator) Impersonator(co.cask.cdap.security.impersonation.Impersonator) DefaultImpersonator(co.cask.cdap.security.impersonation.DefaultImpersonator) AuthorizationTestModule(co.cask.cdap.security.authorization.AuthorizationTestModule) AbstractModule(com.google.inject.AbstractModule) DatasetOpExecutorService(co.cask.cdap.data2.datafabric.dataset.service.executor.DatasetOpExecutorService) RandomEndpointStrategy(co.cask.cdap.common.discovery.RandomEndpointStrategy) Before(org.junit.Before)

Example 62 with ConfigModule

use of co.cask.cdap.common.guice.ConfigModule in project cdap by caskdata.

the class AuthenticationServerMain method init.

@Override
public void init(String[] args) {
    Injector injector = Guice.createInjector(new ConfigModule(), new IOModule(), new SecurityModules().getDistributedModules(), new DiscoveryRuntimeModule().getDistributedModules(), new ZKClientModule());
    configuration = injector.getInstance(CConfiguration.class);
    if (configuration.getBoolean(Constants.Security.ENABLED)) {
        this.zkClientService = injector.getInstance(ZKClientService.class);
        this.authServer = injector.getInstance(ExternalAuthenticationServer.class);
    }
}
Also used : IOModule(co.cask.cdap.common.guice.IOModule) ZKClientModule(co.cask.cdap.common.guice.ZKClientModule) ZKClientService(org.apache.twill.zookeeper.ZKClientService) ExternalAuthenticationServer(co.cask.cdap.security.server.ExternalAuthenticationServer) Injector(com.google.inject.Injector) ConfigModule(co.cask.cdap.common.guice.ConfigModule) DiscoveryRuntimeModule(co.cask.cdap.common.guice.DiscoveryRuntimeModule) CConfiguration(co.cask.cdap.common.conf.CConfiguration) SecurityModules(co.cask.cdap.security.guice.SecurityModules)

Example 63 with ConfigModule

use of co.cask.cdap.common.guice.ConfigModule in project cdap by caskdata.

the class DistributedKeyManagerTest method setup.

@BeforeClass
public static void setup() throws Exception {
    HBaseTestingUtility testUtil = new HBaseTestingUtility();
    zkCluster = testUtil.startMiniZKCluster();
    String zkConnectString = testUtil.getConfiguration().get(HConstants.ZOOKEEPER_QUORUM) + ":" + zkCluster.getClientPort();
    LOG.info("Running ZK cluster at " + zkConnectString);
    CConfiguration cConf1 = CConfiguration.create();
    cConf1.set(Constants.Zookeeper.QUORUM, zkConnectString);
    CConfiguration cConf2 = CConfiguration.create();
    cConf2.set(Constants.Zookeeper.QUORUM, zkConnectString);
    injector1 = Guice.createInjector(new ConfigModule(cConf1, testUtil.getConfiguration()), new IOModule(), new SecurityModules().getDistributedModules(), new ZKClientModule(), new DiscoveryRuntimeModule().getDistributedModules());
    injector2 = Guice.createInjector(new ConfigModule(cConf2, testUtil.getConfiguration()), new IOModule(), new SecurityModules().getDistributedModules(), new ZKClientModule(), new DiscoveryRuntimeModule().getDistributedModules());
}
Also used : IOModule(co.cask.cdap.common.guice.IOModule) ZKClientModule(co.cask.cdap.common.guice.ZKClientModule) HBaseTestingUtility(org.apache.hadoop.hbase.HBaseTestingUtility) ConfigModule(co.cask.cdap.common.guice.ConfigModule) CConfiguration(co.cask.cdap.common.conf.CConfiguration) DiscoveryRuntimeModule(co.cask.cdap.common.guice.DiscoveryRuntimeModule) SecurityModules(co.cask.cdap.security.guice.SecurityModules) BeforeClass(org.junit.BeforeClass)

Example 64 with ConfigModule

use of co.cask.cdap.common.guice.ConfigModule in project cdap by caskdata.

the class TestFileBasedTokenManager method getTokenManagerAndCodec.

@Override
protected ImmutablePair<TokenManager, Codec<AccessToken>> getTokenManagerAndCodec() throws IOException {
    CConfiguration cConf = CConfiguration.create();
    cConf.set(Constants.CFG_LOCAL_DATA_DIR, TEMP_FOLDER.newFolder().getAbsolutePath());
    Injector injector = Guice.createInjector(new IOModule(), new ConfigModule(cConf), new FileBasedSecurityModule(), new DiscoveryRuntimeModule().getInMemoryModules());
    TokenManager tokenManager = injector.getInstance(TokenManager.class);
    tokenManager.startAndWait();
    Codec<AccessToken> tokenCodec = injector.getInstance(AccessTokenCodec.class);
    return new ImmutablePair<>(tokenManager, tokenCodec);
}
Also used : IOModule(co.cask.cdap.common.guice.IOModule) FileBasedSecurityModule(co.cask.cdap.security.guice.FileBasedSecurityModule) ImmutablePair(co.cask.cdap.common.utils.ImmutablePair) Injector(com.google.inject.Injector) ConfigModule(co.cask.cdap.common.guice.ConfigModule) CConfiguration(co.cask.cdap.common.conf.CConfiguration) DiscoveryRuntimeModule(co.cask.cdap.common.guice.DiscoveryRuntimeModule)

Example 65 with ConfigModule

use of co.cask.cdap.common.guice.ConfigModule in project cdap by caskdata.

the class TestInMemoryTokenManager method getTokenManagerAndCodec.

@Override
protected ImmutablePair<TokenManager, Codec<AccessToken>> getTokenManagerAndCodec() {
    Injector injector = Guice.createInjector(new IOModule(), new SecurityModules().getInMemoryModules(), new ConfigModule(), new DiscoveryRuntimeModule().getInMemoryModules());
    TokenManager tokenManager = injector.getInstance(TokenManager.class);
    tokenManager.startAndWait();
    Codec<AccessToken> tokenCodec = injector.getInstance(AccessTokenCodec.class);
    return new ImmutablePair<>(tokenManager, tokenCodec);
}
Also used : IOModule(co.cask.cdap.common.guice.IOModule) ImmutablePair(co.cask.cdap.common.utils.ImmutablePair) Injector(com.google.inject.Injector) ConfigModule(co.cask.cdap.common.guice.ConfigModule) DiscoveryRuntimeModule(co.cask.cdap.common.guice.DiscoveryRuntimeModule) SecurityModules(co.cask.cdap.security.guice.SecurityModules)

Aggregations

ConfigModule (co.cask.cdap.common.guice.ConfigModule)77 AuthorizationEnforcementModule (co.cask.cdap.security.authorization.AuthorizationEnforcementModule)56 DiscoveryRuntimeModule (co.cask.cdap.common.guice.DiscoveryRuntimeModule)55 DataSetsModules (co.cask.cdap.data.runtime.DataSetsModules)53 AbstractModule (com.google.inject.AbstractModule)53 AuthenticationContextModules (co.cask.cdap.security.auth.context.AuthenticationContextModules)51 AuthorizationTestModule (co.cask.cdap.security.authorization.AuthorizationTestModule)48 CConfiguration (co.cask.cdap.common.conf.CConfiguration)46 BeforeClass (org.junit.BeforeClass)45 Injector (com.google.inject.Injector)44 NonCustomLocationUnitTestModule (co.cask.cdap.common.guice.NonCustomLocationUnitTestModule)41 UnsupportedUGIProvider (co.cask.cdap.security.impersonation.UnsupportedUGIProvider)35 DefaultOwnerAdmin (co.cask.cdap.security.impersonation.DefaultOwnerAdmin)34 DataFabricModules (co.cask.cdap.data.runtime.DataFabricModules)33 ExploreClientModule (co.cask.cdap.explore.guice.ExploreClientModule)31 SystemDatasetRuntimeModule (co.cask.cdap.data.runtime.SystemDatasetRuntimeModule)30 TransactionManager (org.apache.tephra.TransactionManager)27 TransactionMetricsModule (co.cask.cdap.data.runtime.TransactionMetricsModule)25 Configuration (org.apache.hadoop.conf.Configuration)25 ViewAdminModules (co.cask.cdap.data.view.ViewAdminModules)24