Search in sources :

Example 11 with InMemoryDiscoveryModule

use of io.cdap.cdap.common.guice.InMemoryDiscoveryModule in project cdap by caskdata.

the class TetheringRuntimeJobManagerTest method setUp.

@BeforeClass
public static void setUp() throws IOException, TopicAlreadyExistsException, PeerAlreadyExistsException {
    CConfiguration cConf = CConfiguration.create();
    cConf.set(Constants.Tethering.TOPIC_PREFIX, "prefix-");
    cConf.set(Constants.CFG_LOCAL_DATA_DIR, TEMP_FOLDER.newFolder().getAbsolutePath());
    Injector injector = Guice.createInjector(new ConfigModule(cConf), new InMemoryDiscoveryModule(), new LocalLocationModule(), new AuthorizationEnforcementModule().getNoOpModules(), new MessagingServerRuntimeModule().getInMemoryModules(), new SystemDatasetRuntimeModule().getInMemoryModules(), new TransactionModules().getInMemoryModules(), new StorageModule(), new AbstractModule() {

        @Override
        protected void configure() {
            bind(MetricsCollectionService.class).to(NoOpMetricsCollectionService.class).in(Scopes.SINGLETON);
        }
    });
    // Define all StructuredTable before starting any services that need StructuredTable
    StoreDefinition.createAllTables(injector.getInstance(StructuredTableAdmin.class));
    messagingService = injector.getInstance(MessagingService.class);
    if (messagingService instanceof Service) {
        ((Service) messagingService).startAndWait();
    }
    txManager = injector.getInstance(TransactionManager.class);
    txManager.startAndWait();
    tetheringStore = injector.getInstance(TetheringStore.class);
    PeerMetadata metadata = new PeerMetadata(Collections.singletonList(new NamespaceAllocation(TETHERED_NAMESPACE_NAME, null, null)), Collections.emptyMap(), null);
    PeerInfo peerInfo = new PeerInfo(TETHERED_INSTANCE_NAME, null, TetheringStatus.ACCEPTED, metadata, System.currentTimeMillis());
    tetheringStore.addPeer(peerInfo);
    TetheringConf conf = TetheringConf.fromProperties(PROPERTIES);
    topicId = new TopicId(NamespaceId.SYSTEM.getNamespace(), cConf.get(Constants.Tethering.TOPIC_PREFIX) + TETHERED_INSTANCE_NAME);
    messagingService.createTopic(new TopicMetadata(topicId, Collections.emptyMap()));
    messageFetcher = new MultiThreadMessagingContext(messagingService).getMessageFetcher();
    runtimeJobManager = new TetheringRuntimeJobManager(conf, cConf, messagingService);
    tetheringProvisioner = injector.getInstance(TetheringProvisioner.class);
}
Also used : InMemoryDiscoveryModule(io.cdap.cdap.common.guice.InMemoryDiscoveryModule) StorageModule(io.cdap.cdap.data.runtime.StorageModule) ConfigModule(io.cdap.cdap.common.guice.ConfigModule) StructuredTableAdmin(io.cdap.cdap.spi.data.StructuredTableAdmin) MessagingServerRuntimeModule(io.cdap.cdap.messaging.guice.MessagingServerRuntimeModule) MultiThreadMessagingContext(io.cdap.cdap.messaging.context.MultiThreadMessagingContext) TetheringProvisioner(io.cdap.cdap.internal.tethering.runtime.spi.provisioner.TetheringProvisioner) LocalLocationModule(io.cdap.cdap.common.guice.LocalLocationModule) Injector(com.google.inject.Injector) TopicId(io.cdap.cdap.proto.id.TopicId) SystemDatasetRuntimeModule(io.cdap.cdap.data.runtime.SystemDatasetRuntimeModule) NoOpMetricsCollectionService(io.cdap.cdap.common.metrics.NoOpMetricsCollectionService) MetricsCollectionService(io.cdap.cdap.api.metrics.MetricsCollectionService) PeerInfo(io.cdap.cdap.internal.tethering.PeerInfo) PeerMetadata(io.cdap.cdap.internal.tethering.PeerMetadata) NoOpMetricsCollectionService(io.cdap.cdap.common.metrics.NoOpMetricsCollectionService) MessagingService(io.cdap.cdap.messaging.MessagingService) Service(com.google.common.util.concurrent.Service) MetricsCollectionService(io.cdap.cdap.api.metrics.MetricsCollectionService) NamespaceAllocation(io.cdap.cdap.internal.tethering.NamespaceAllocation) CConfiguration(io.cdap.cdap.common.conf.CConfiguration) AbstractModule(com.google.inject.AbstractModule) MessagingService(io.cdap.cdap.messaging.MessagingService) TopicMetadata(io.cdap.cdap.messaging.TopicMetadata) TransactionModules(org.apache.tephra.runtime.TransactionModules) TetheringConf(io.cdap.cdap.internal.tethering.runtime.spi.provisioner.TetheringConf) TransactionManager(org.apache.tephra.TransactionManager) TetheringStore(io.cdap.cdap.internal.tethering.TetheringStore) AuthorizationEnforcementModule(io.cdap.cdap.security.authorization.AuthorizationEnforcementModule) BeforeClass(org.junit.BeforeClass)

Example 12 with InMemoryDiscoveryModule

use of io.cdap.cdap.common.guice.InMemoryDiscoveryModule in project cdap by caskdata.

the class AppFabricTestModule method configure.

@Override
protected void configure() {
    install(new DataFabricModules().getInMemoryModules());
    install(new DataSetsModules().getStandaloneModules());
    install(new TransactionExecutorModule());
    install(new DataSetServiceModules().getInMemoryModules());
    install(new ConfigModule(cConf, hConf, sConf));
    install(RemoteAuthenticatorModules.getNoOpModule());
    install(new IOModule());
    install(new InMemoryDiscoveryModule());
    install(new AppFabricServiceRuntimeModule(cConf).getInMemoryModules());
    install(new MonitorHandlerModule(false));
    install(new ProgramRunnerRuntimeModule().getInMemoryModules());
    install(new NonCustomLocationUnitTestModule());
    install(new LocalLogAppenderModule());
    install(new LogReaderRuntimeModules().getInMemoryModules());
    install(new LogQueryRuntimeModule().getInMemoryModules());
    install(new MetricsHandlerModule());
    install(new MetricsClientRuntimeModule().getInMemoryModules());
    install(new ExploreClientModule());
    install(new ConfigStoreModule());
    install(new MetadataServiceModule());
    install(new AuthenticationContextModules().getMasterModule());
    install(new AuthorizationModule());
    install(new AuthorizationEnforcementModule().getStandaloneModules());
    install(new SecureStoreServerModule());
    install(new MetadataReaderWriterModules().getInMemoryModules());
    install(new MessagingServerRuntimeModule().getInMemoryModules());
    install(new MockProvisionerModule());
    // Needed by MonitorHandlerModuler
    bind(TwillRunner.class).to(NoopTwillRunnerService.class);
}
Also used : IOModule(io.cdap.cdap.common.guice.IOModule) DataSetServiceModules(io.cdap.cdap.data.runtime.DataSetServiceModules) InMemoryDiscoveryModule(io.cdap.cdap.common.guice.InMemoryDiscoveryModule) ConfigModule(io.cdap.cdap.common.guice.ConfigModule) TwillRunner(org.apache.twill.api.TwillRunner) MessagingServerRuntimeModule(io.cdap.cdap.messaging.guice.MessagingServerRuntimeModule) MetricsClientRuntimeModule(io.cdap.cdap.metrics.guice.MetricsClientRuntimeModule) MonitorHandlerModule(io.cdap.cdap.app.guice.MonitorHandlerModule) TransactionExecutorModule(io.cdap.cdap.data.runtime.TransactionExecutorModule) MockProvisionerModule(io.cdap.cdap.internal.provision.MockProvisionerModule) ConfigStoreModule(io.cdap.cdap.config.guice.ConfigStoreModule) AuthorizationModule(io.cdap.cdap.app.guice.AuthorizationModule) LogReaderRuntimeModules(io.cdap.cdap.logging.guice.LogReaderRuntimeModules) AuthenticationContextModules(io.cdap.cdap.security.auth.context.AuthenticationContextModules) DataSetsModules(io.cdap.cdap.data.runtime.DataSetsModules) MetadataServiceModule(io.cdap.cdap.metadata.MetadataServiceModule) NonCustomLocationUnitTestModule(io.cdap.cdap.common.guice.NonCustomLocationUnitTestModule) LogQueryRuntimeModule(io.cdap.cdap.logging.guice.LogQueryRuntimeModule) MetadataReaderWriterModules(io.cdap.cdap.metadata.MetadataReaderWriterModules) ProgramRunnerRuntimeModule(io.cdap.cdap.app.guice.ProgramRunnerRuntimeModule) MetricsHandlerModule(io.cdap.cdap.metrics.guice.MetricsHandlerModule) LocalLogAppenderModule(io.cdap.cdap.logging.guice.LocalLogAppenderModule) ExploreClientModule(io.cdap.cdap.explore.guice.ExploreClientModule) DataFabricModules(io.cdap.cdap.data.runtime.DataFabricModules) AppFabricServiceRuntimeModule(io.cdap.cdap.app.guice.AppFabricServiceRuntimeModule) AuthorizationEnforcementModule(io.cdap.cdap.security.authorization.AuthorizationEnforcementModule) SecureStoreServerModule(io.cdap.cdap.security.guice.SecureStoreServerModule)

Example 13 with InMemoryDiscoveryModule

use of io.cdap.cdap.common.guice.InMemoryDiscoveryModule in project cdap by caskdata.

the class SystemWorkerServiceTest method beforeTest.

@Before
public void beforeTest() throws IOException {
    File keyDir = TEMP_FOLDER.newFolder();
    File keyFile = new File(keyDir, "key");
    CConfiguration cConf = createCConf();
    cConf.set(Constants.Security.CFG_FILE_BASED_KEYFILE_PATH, keyFile.getAbsolutePath());
    Injector injector = Guice.createInjector(new IOModule(), new ConfigModule(cConf), new FileBasedCoreSecurityModule(), new InMemoryDiscoveryModule());
    SConfiguration sConf = createSConf();
    SystemWorkerService service = new SystemWorkerService(cConf, sConf, new InMemoryDiscoveryService(), metricsCollectionService, new CommonNettyHttpServiceFactory(cConf, metricsCollectionService), injector.getInstance(FileBasedKeyManager.class), new NoopTwillRunnerService(), getInjector().getInstance(ProvisioningService.class), Guice.createInjector(new RunnableTaskModule(cConf)));
    service.startAndWait();
    this.systemWorkerService = service;
}
Also used : IOModule(io.cdap.cdap.common.guice.IOModule) InMemoryDiscoveryModule(io.cdap.cdap.common.guice.InMemoryDiscoveryModule) ConfigModule(io.cdap.cdap.common.guice.ConfigModule) RunnableTaskModule(io.cdap.cdap.internal.app.worker.RunnableTaskModule) CConfiguration(io.cdap.cdap.common.conf.CConfiguration) NoopTwillRunnerService(io.cdap.cdap.common.twill.NoopTwillRunnerService) Injector(com.google.inject.Injector) ProvisioningService(io.cdap.cdap.internal.provision.ProvisioningService) SConfiguration(io.cdap.cdap.common.conf.SConfiguration) CommonNettyHttpServiceFactory(io.cdap.cdap.common.http.CommonNettyHttpServiceFactory) FileBasedKeyManager(io.cdap.cdap.security.auth.FileBasedKeyManager) File(java.io.File) InMemoryDiscoveryService(org.apache.twill.discovery.InMemoryDiscoveryService) FileBasedCoreSecurityModule(io.cdap.cdap.security.guice.FileBasedCoreSecurityModule) Before(org.junit.Before)

Example 14 with InMemoryDiscoveryModule

use of io.cdap.cdap.common.guice.InMemoryDiscoveryModule in project cdap by caskdata.

the class ExternalAuthenticationServerTestBase method setup.

protected void setup() throws Exception {
    Assert.assertNotNull("CConfiguration needs to be set by derived classes", configuration);
    // Intentionally set "security.auth.server.announce.urls" to invalid
    // values verify that they are not used by external authentication server
    configuration.set(Constants.Security.AUTH_SERVER_ANNOUNCE_URLS, "invalid.urls");
    Module externalAuthenticationModule = Modules.override(new ExternalAuthenticationModule()).with(new AbstractModule() {

        @Override
        protected void configure() {
            bind(AuditLogHandler.class).annotatedWith(Names.named(ExternalAuthenticationServer.NAMED_EXTERNAL_AUTH)).toInstance(new AuditLogHandler(TEST_AUDIT_LOGGER));
        }
    });
    Injector injector = Guice.createInjector(new IOModule(), externalAuthenticationModule, new CoreSecurityRuntimeModule().getInMemoryModules(), new ConfigModule(getConfiguration(configuration), HBaseConfiguration.create(), sConfiguration), new InMemoryDiscoveryModule());
    server = injector.getInstance(ExternalAuthenticationServer.class);
    tokenCodec = injector.getInstance(AccessTokenCodec.class);
    discoveryServiceClient = injector.getInstance(DiscoveryServiceClient.class);
    startExternalAuthenticationServer();
    server.startAndWait();
    LOG.info("Auth server running on address {}", server.getSocketAddress());
    TimeUnit.SECONDS.sleep(3);
}
Also used : IOModule(io.cdap.cdap.common.guice.IOModule) InMemoryDiscoveryModule(io.cdap.cdap.common.guice.InMemoryDiscoveryModule) DiscoveryServiceClient(org.apache.twill.discovery.DiscoveryServiceClient) ExternalAuthenticationModule(io.cdap.cdap.security.guice.ExternalAuthenticationModule) ConfigModule(io.cdap.cdap.common.guice.ConfigModule) AbstractModule(com.google.inject.AbstractModule) AccessTokenCodec(io.cdap.cdap.security.auth.AccessTokenCodec) CoreSecurityRuntimeModule(io.cdap.cdap.security.guice.CoreSecurityRuntimeModule) Injector(com.google.inject.Injector) Module(com.google.inject.Module) ConfigModule(io.cdap.cdap.common.guice.ConfigModule) CoreSecurityRuntimeModule(io.cdap.cdap.security.guice.CoreSecurityRuntimeModule) ExternalAuthenticationModule(io.cdap.cdap.security.guice.ExternalAuthenticationModule) IOModule(io.cdap.cdap.common.guice.IOModule) InMemoryDiscoveryModule(io.cdap.cdap.common.guice.InMemoryDiscoveryModule) AbstractModule(com.google.inject.AbstractModule)

Example 15 with InMemoryDiscoveryModule

use of io.cdap.cdap.common.guice.InMemoryDiscoveryModule in project cdap by caskdata.

the class TestInMemoryTokenManager method getTokenManagerAndCodec.

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

Aggregations

InMemoryDiscoveryModule (io.cdap.cdap.common.guice.InMemoryDiscoveryModule)86 ConfigModule (io.cdap.cdap.common.guice.ConfigModule)82 AuthorizationEnforcementModule (io.cdap.cdap.security.authorization.AuthorizationEnforcementModule)56 AuthenticationContextModules (io.cdap.cdap.security.auth.context.AuthenticationContextModules)52 Injector (com.google.inject.Injector)50 CConfiguration (io.cdap.cdap.common.conf.CConfiguration)50 AbstractModule (com.google.inject.AbstractModule)46 IOModule (io.cdap.cdap.common.guice.IOModule)38 AuthorizationTestModule (io.cdap.cdap.security.authorization.AuthorizationTestModule)34 BeforeClass (org.junit.BeforeClass)34 NonCustomLocationUnitTestModule (io.cdap.cdap.common.guice.NonCustomLocationUnitTestModule)32 NoOpMetricsCollectionService (io.cdap.cdap.common.metrics.NoOpMetricsCollectionService)30 DataSetsModules (io.cdap.cdap.data.runtime.DataSetsModules)30 MessagingServerRuntimeModule (io.cdap.cdap.messaging.guice.MessagingServerRuntimeModule)30 DataFabricModules (io.cdap.cdap.data.runtime.DataFabricModules)24 DataSetServiceModules (io.cdap.cdap.data.runtime.DataSetServiceModules)24 ExploreClientModule (io.cdap.cdap.explore.guice.ExploreClientModule)24 TransactionManager (org.apache.tephra.TransactionManager)24 NamespaceAdminTestModule (io.cdap.cdap.common.guice.NamespaceAdminTestModule)22 SystemDatasetRuntimeModule (io.cdap.cdap.data.runtime.SystemDatasetRuntimeModule)22