Search in sources :

Example 1 with NamespaceStore

use of co.cask.cdap.store.NamespaceStore in project cdap by caskdata.

the class LocalStreamFileJanitorTest method init.

@BeforeClass
public static void init() throws IOException {
    cConf.set(Constants.CFG_LOCAL_DATA_DIR, tmpFolder.newFolder().getAbsolutePath());
    setupAuthzConfig();
    Injector injector = Guice.createInjector(new ConfigModule(cConf), new NonCustomLocationUnitTestModule().getModule(), new SystemDatasetRuntimeModule().getInMemoryModules(), Modules.override(new DataSetsModules().getInMemoryModules()).with(new AbstractModule() {

        @Override
        protected void configure() {
            // bind to an in mem implementation for this test since the DefaultOwnerStore uses transaction and in this
            // test we are not starting a transaction service
            bind(OwnerStore.class).to(InMemoryOwnerStore.class).in(Scopes.SINGLETON);
        }
    }), new TransactionMetricsModule(), new DataFabricLevelDBModule(), new DiscoveryRuntimeModule().getInMemoryModules(), new NamespaceClientRuntimeModule().getInMemoryModules(), new ExploreClientModule(), new ViewAdminModules().getInMemoryModules(), new AuthorizationTestModule(), new AuthorizationEnforcementModule().getInMemoryModules(), new AuthenticationContextModules().getMasterModule(), Modules.override(new StreamAdminModules().getStandaloneModules()).with(new AbstractModule() {

        @Override
        protected void configure() {
            bind(StreamMetaStore.class).to(InMemoryStreamMetaStore.class);
            bind(UGIProvider.class).to(UnsupportedUGIProvider.class);
        }
    }), new AbstractModule() {

        @Override
        protected void configure() {
            // We don't need notification in this test, hence inject an no-op one
            bind(NotificationFeedManager.class).to(NoOpNotificationFeedManager.class);
            bind(NamespaceStore.class).to(InMemoryNamespaceStore.class);
            bind(OwnerAdmin.class).to(DefaultOwnerAdmin.class);
        }
    });
    locationFactory = injector.getInstance(LocationFactory.class);
    namespaceAdmin = injector.getInstance(NamespaceAdmin.class);
    namespacedLocationFactory = injector.getInstance(NamespacedLocationFactory.class);
    namespaceStore = injector.getInstance(NamespaceStore.class);
    streamAdmin = injector.getInstance(StreamAdmin.class);
    janitor = injector.getInstance(StreamFileJanitor.class);
    fileWriterFactory = injector.getInstance(StreamFileWriterFactory.class);
    streamCoordinatorClient = injector.getInstance(StreamCoordinatorClient.class);
    authorizer = injector.getInstance(AuthorizerInstantiator.class).get();
    streamCoordinatorClient.startAndWait();
}
Also used : NamespaceClientRuntimeModule(co.cask.cdap.common.namespace.guice.NamespaceClientRuntimeModule) ConfigModule(co.cask.cdap.common.guice.ConfigModule) UGIProvider(co.cask.cdap.security.impersonation.UGIProvider) UnsupportedUGIProvider(co.cask.cdap.security.impersonation.UnsupportedUGIProvider) NamespacedLocationFactory(co.cask.cdap.common.namespace.NamespacedLocationFactory) TransactionMetricsModule(co.cask.cdap.data.runtime.TransactionMetricsModule) DataFabricLevelDBModule(co.cask.cdap.data.runtime.DataFabricLevelDBModule) ViewAdminModules(co.cask.cdap.data.view.ViewAdminModules) Injector(com.google.inject.Injector) InMemoryStreamMetaStore(co.cask.cdap.data.stream.service.InMemoryStreamMetaStore) StreamMetaStore(co.cask.cdap.data.stream.service.StreamMetaStore) SystemDatasetRuntimeModule(co.cask.cdap.data.runtime.SystemDatasetRuntimeModule) DiscoveryRuntimeModule(co.cask.cdap.common.guice.DiscoveryRuntimeModule) AuthenticationContextModules(co.cask.cdap.security.auth.context.AuthenticationContextModules) DataSetsModules(co.cask.cdap.data.runtime.DataSetsModules) NamespaceStore(co.cask.cdap.store.NamespaceStore) InMemoryNamespaceStore(co.cask.cdap.store.InMemoryNamespaceStore) NamespaceAdmin(co.cask.cdap.common.namespace.NamespaceAdmin) NonCustomLocationUnitTestModule(co.cask.cdap.common.guice.NonCustomLocationUnitTestModule) DefaultOwnerAdmin(co.cask.cdap.security.impersonation.DefaultOwnerAdmin) AuthorizationTestModule(co.cask.cdap.security.authorization.AuthorizationTestModule) InMemoryOwnerStore(co.cask.cdap.security.impersonation.InMemoryOwnerStore) AbstractModule(com.google.inject.AbstractModule) NamespacedLocationFactory(co.cask.cdap.common.namespace.NamespacedLocationFactory) LocationFactory(org.apache.twill.filesystem.LocationFactory) StreamAdmin(co.cask.cdap.data2.transaction.stream.StreamAdmin) ExploreClientModule(co.cask.cdap.explore.guice.ExploreClientModule) NoOpNotificationFeedManager(co.cask.cdap.notifications.feeds.service.NoOpNotificationFeedManager) InMemoryNamespaceStore(co.cask.cdap.store.InMemoryNamespaceStore) AuthorizationEnforcementModule(co.cask.cdap.security.authorization.AuthorizationEnforcementModule) BeforeClass(org.junit.BeforeClass)

Example 2 with NamespaceStore

use of co.cask.cdap.store.NamespaceStore in project cdap by caskdata.

the class DFSStreamFileJanitorTest method init.

@BeforeClass
public static void init() throws IOException {
    cConf.set(Constants.CFG_LOCAL_DATA_DIR, tmpFolder.newFolder().getAbsolutePath());
    setupAuthzConfig();
    Configuration hConf = new Configuration();
    hConf.set(MiniDFSCluster.HDFS_MINIDFS_BASEDIR, tmpFolder.newFolder().getAbsolutePath());
    dfsCluster = new MiniDFSCluster.Builder(hConf).numDataNodes(1).build();
    dfsCluster.waitClusterUp();
    final LocationFactory lf = new FileContextLocationFactory(dfsCluster.getFileSystem().getConf());
    namespaceAdmin = new InMemoryNamespaceClient();
    final NamespacedLocationFactory nlf = new DefaultNamespacedLocationFactory(cConf, lf, namespaceAdmin);
    Injector injector = Guice.createInjector(new ConfigModule(cConf, hConf), new ZKClientModule(), new AbstractModule() {

        @Override
        protected void configure() {
            bind(LocationFactory.class).toInstance(lf);
            bind(NamespacedLocationFactory.class).toInstance(nlf);
            bind(NamespaceAdmin.class).toInstance(namespaceAdmin);
            bind(NamespaceQueryAdmin.class).toInstance(namespaceAdmin);
            bind(UGIProvider.class).to(RemoteUGIProvider.class);
            bind(OwnerAdmin.class).to(DefaultOwnerAdmin.class);
        }
    }, new TransactionMetricsModule(), new DiscoveryRuntimeModule().getInMemoryModules(), new DataFabricModules().getDistributedModules(), Modules.override(new DataSetsModules().getDistributedModules()).with(new AbstractModule() {

        @Override
        protected void configure() {
            bind(MetadataStore.class).to(NoOpMetadataStore.class);
            // bind to an in memory implementation for this test since the DefaultOwnerStore uses transaction and in this
            // test we are not starting a transaction service
            bind(OwnerStore.class).to(InMemoryOwnerStore.class).in(Scopes.SINGLETON);
        }
    }), new ExploreClientModule(), new ViewAdminModules().getInMemoryModules(), Modules.override(new StreamAdminModules().getDistributedModules()).with(new AbstractModule() {

        @Override
        protected void configure() {
            // Tests are running in same process, hence no need to have ZK to coordinate
            bind(StreamCoordinatorClient.class).to(InMemoryStreamCoordinatorClient.class).in(Scopes.SINGLETON);
            bind(StreamMetaStore.class).to(InMemoryStreamMetaStore.class);
        }
    }), new AbstractModule() {

        @Override
        protected void configure() {
            // We don't need notification in this test, hence inject an no-op one
            bind(NotificationFeedManager.class).to(NoOpNotificationFeedManager.class);
            bind(NamespaceStore.class).to(InMemoryNamespaceStore.class);
        }
    }, new AuthorizationTestModule(), new AuthorizationEnforcementModule().getInMemoryModules(), new AuthenticationContextModules().getMasterModule());
    locationFactory = injector.getInstance(LocationFactory.class);
    namespacedLocationFactory = injector.getInstance(NamespacedLocationFactory.class);
    namespaceStore = injector.getInstance(NamespaceStore.class);
    streamAdmin = injector.getInstance(StreamAdmin.class);
    janitor = injector.getInstance(StreamFileJanitor.class);
    fileWriterFactory = injector.getInstance(StreamFileWriterFactory.class);
    streamCoordinatorClient = injector.getInstance(StreamCoordinatorClient.class);
    authorizer = injector.getInstance(AuthorizerInstantiator.class).get();
    streamCoordinatorClient.startAndWait();
}
Also used : CConfiguration(co.cask.cdap.common.conf.CConfiguration) Configuration(org.apache.hadoop.conf.Configuration) ConfigModule(co.cask.cdap.common.guice.ConfigModule) FileContextLocationFactory(org.apache.twill.filesystem.FileContextLocationFactory) InMemoryNamespaceClient(co.cask.cdap.common.namespace.InMemoryNamespaceClient) NamespacedLocationFactory(co.cask.cdap.common.namespace.NamespacedLocationFactory) DefaultNamespacedLocationFactory(co.cask.cdap.common.namespace.DefaultNamespacedLocationFactory) TransactionMetricsModule(co.cask.cdap.data.runtime.TransactionMetricsModule) ViewAdminModules(co.cask.cdap.data.view.ViewAdminModules) ZKClientModule(co.cask.cdap.common.guice.ZKClientModule) Injector(com.google.inject.Injector) StreamMetaStore(co.cask.cdap.data.stream.service.StreamMetaStore) InMemoryStreamMetaStore(co.cask.cdap.data.stream.service.InMemoryStreamMetaStore) DiscoveryRuntimeModule(co.cask.cdap.common.guice.DiscoveryRuntimeModule) MiniDFSCluster(org.apache.hadoop.hdfs.MiniDFSCluster) AuthenticationContextModules(co.cask.cdap.security.auth.context.AuthenticationContextModules) DataSetsModules(co.cask.cdap.data.runtime.DataSetsModules) NamespaceStore(co.cask.cdap.store.NamespaceStore) InMemoryNamespaceStore(co.cask.cdap.store.InMemoryNamespaceStore) DefaultOwnerAdmin(co.cask.cdap.security.impersonation.DefaultOwnerAdmin) AuthorizationTestModule(co.cask.cdap.security.authorization.AuthorizationTestModule) InMemoryOwnerStore(co.cask.cdap.security.impersonation.InMemoryOwnerStore) NamespacedLocationFactory(co.cask.cdap.common.namespace.NamespacedLocationFactory) DefaultNamespacedLocationFactory(co.cask.cdap.common.namespace.DefaultNamespacedLocationFactory) LocationFactory(org.apache.twill.filesystem.LocationFactory) FileContextLocationFactory(org.apache.twill.filesystem.FileContextLocationFactory) AbstractModule(com.google.inject.AbstractModule) MetadataStore(co.cask.cdap.data2.metadata.store.MetadataStore) NoOpMetadataStore(co.cask.cdap.data2.metadata.store.NoOpMetadataStore) StreamAdmin(co.cask.cdap.data2.transaction.stream.StreamAdmin) RemoteUGIProvider(co.cask.cdap.security.impersonation.RemoteUGIProvider) ExploreClientModule(co.cask.cdap.explore.guice.ExploreClientModule) NoOpNotificationFeedManager(co.cask.cdap.notifications.feeds.service.NoOpNotificationFeedManager) DefaultNamespacedLocationFactory(co.cask.cdap.common.namespace.DefaultNamespacedLocationFactory) DataFabricModules(co.cask.cdap.data.runtime.DataFabricModules) InMemoryNamespaceStore(co.cask.cdap.store.InMemoryNamespaceStore) AuthorizationEnforcementModule(co.cask.cdap.security.authorization.AuthorizationEnforcementModule) BeforeClass(org.junit.BeforeClass)

Example 3 with NamespaceStore

use of co.cask.cdap.store.NamespaceStore in project cdap by caskdata.

the class StorageProviderNamespaceAdminTest method setup.

@BeforeClass
public static void setup() throws IOException {
    CConfiguration cConf = CConfiguration.create();
    cConf.set(Constants.CFG_LOCAL_DATA_DIR, TEMP_FOLDER.newFolder().getAbsolutePath());
    cConf.setBoolean(Constants.Explore.EXPLORE_ENABLED, true);
    Injector injector = Guice.createInjector(Modules.override(new AppFabricTestModule(cConf)).with(new AbstractModule() {

        @Override
        protected void configure() {
            // use the DefaultNamespacedLocationFactory here to test proper namespace creation in storage handler and
            // not the NamespacedLocationFactoryTestClient
            bind(NamespacedLocationFactory.class).to(DefaultNamespacedLocationFactory.class);
        }
    }));
    namespacedLocationFactory = injector.getInstance(NamespacedLocationFactory.class);
    storageProviderNamespaceAdmin = injector.getInstance(StorageProviderNamespaceAdmin.class);
    // start the dataset service for namespace store to work
    transactionManager = injector.getInstance(TransactionManager.class);
    transactionManager.startAndWait();
    datasetService = injector.getInstance(DatasetService.class);
    datasetService.startAndWait();
    // we don't use namespace admin here but the store because namespaceadmin will try to create the
    // home directory for namespace which we don't want. We just want to store the namespace meta in store
    // to look up during the delete.
    namespaceStore = injector.getInstance(NamespaceStore.class);
}
Also used : Injector(com.google.inject.Injector) TransactionManager(org.apache.tephra.TransactionManager) NamespaceStore(co.cask.cdap.store.NamespaceStore) AppFabricTestModule(co.cask.cdap.internal.guice.AppFabricTestModule) DatasetService(co.cask.cdap.data2.datafabric.dataset.service.DatasetService) NamespacedLocationFactory(co.cask.cdap.common.namespace.NamespacedLocationFactory) DefaultNamespacedLocationFactory(co.cask.cdap.common.namespace.DefaultNamespacedLocationFactory) CConfiguration(co.cask.cdap.common.conf.CConfiguration) AbstractModule(com.google.inject.AbstractModule) BeforeClass(org.junit.BeforeClass)

Example 4 with NamespaceStore

use of co.cask.cdap.store.NamespaceStore in project cdap by caskdata.

the class EntityExistenceTest method setup.

@BeforeClass
public static void setup() throws Exception {
    CConfiguration cConf = CConfiguration.create();
    cConf.set(Constants.INSTANCE_NAME, EXISTS);
    Injector injector = AppFabricTestHelper.getInjector(cConf);
    NamespaceStore nsStore = injector.getInstance(NamespaceStore.class);
    ArtifactRepository artifactRepository = injector.getInstance(ArtifactRepository.class);
    cConf = injector.getInstance(CConfiguration.class);
    nsStore.create(new NamespaceMeta.Builder().setName(EXISTS).build());
    existenceVerifier = injector.getInstance(EntityExistenceVerifier.class);
    LocalLocationFactory lf = new LocalLocationFactory(TEMPORARY_FOLDER.newFolder());
    File artifactFile = new File(AppJarHelper.createDeploymentJar(lf, AllProgramsApp.class).toURI());
    artifactRepository.addArtifact(Id.Artifact.fromEntityId(ARTIFACT), artifactFile);
    AppFabricTestHelper.deployApplication(Id.Namespace.fromEntityId(NAMESPACE), AllProgramsApp.class, null, cConf);
    StreamAdmin streamAdmin = injector.getInstance(StreamAdmin.class);
    streamAdmin.createOrUpdateView(VIEW, new ViewSpecification(new FormatSpecification("csv", null)));
}
Also used : StreamAdmin(co.cask.cdap.data2.transaction.stream.StreamAdmin) EntityExistenceVerifier(co.cask.cdap.common.entity.EntityExistenceVerifier) Injector(com.google.inject.Injector) NamespaceMeta(co.cask.cdap.proto.NamespaceMeta) NamespaceStore(co.cask.cdap.store.NamespaceStore) FormatSpecification(co.cask.cdap.api.data.format.FormatSpecification) ViewSpecification(co.cask.cdap.proto.ViewSpecification) ArtifactRepository(co.cask.cdap.internal.app.runtime.artifact.ArtifactRepository) CConfiguration(co.cask.cdap.common.conf.CConfiguration) LocalLocationFactory(org.apache.twill.filesystem.LocalLocationFactory) File(java.io.File) BeforeClass(org.junit.BeforeClass)

Aggregations

NamespaceStore (co.cask.cdap.store.NamespaceStore)4 Injector (com.google.inject.Injector)4 BeforeClass (org.junit.BeforeClass)4 CConfiguration (co.cask.cdap.common.conf.CConfiguration)3 NamespacedLocationFactory (co.cask.cdap.common.namespace.NamespacedLocationFactory)3 StreamAdmin (co.cask.cdap.data2.transaction.stream.StreamAdmin)3 AbstractModule (com.google.inject.AbstractModule)3 ConfigModule (co.cask.cdap.common.guice.ConfigModule)2 DiscoveryRuntimeModule (co.cask.cdap.common.guice.DiscoveryRuntimeModule)2 DefaultNamespacedLocationFactory (co.cask.cdap.common.namespace.DefaultNamespacedLocationFactory)2 DataSetsModules (co.cask.cdap.data.runtime.DataSetsModules)2 TransactionMetricsModule (co.cask.cdap.data.runtime.TransactionMetricsModule)2 InMemoryStreamMetaStore (co.cask.cdap.data.stream.service.InMemoryStreamMetaStore)2 StreamMetaStore (co.cask.cdap.data.stream.service.StreamMetaStore)2 ViewAdminModules (co.cask.cdap.data.view.ViewAdminModules)2 ExploreClientModule (co.cask.cdap.explore.guice.ExploreClientModule)2 NoOpNotificationFeedManager (co.cask.cdap.notifications.feeds.service.NoOpNotificationFeedManager)2 AuthenticationContextModules (co.cask.cdap.security.auth.context.AuthenticationContextModules)2 AuthorizationEnforcementModule (co.cask.cdap.security.authorization.AuthorizationEnforcementModule)2 AuthorizationTestModule (co.cask.cdap.security.authorization.AuthorizationTestModule)2