Search in sources :

Example 1 with LocationFactory

use of org.apache.twill.filesystem.LocationFactory in project cdap by caskdata.

the class RemotePrivilegesTest method setup.

@BeforeClass
public static void setup() throws IOException, InterruptedException {
    CConfiguration cConf = CConfiguration.create();
    cConf.set(Constants.CFG_LOCAL_DATA_DIR, TEMPORARY_FOLDER.newFolder().getAbsolutePath());
    cConf.setBoolean(Constants.Security.ENABLED, true);
    cConf.setBoolean(Constants.Security.KERBEROS_ENABLED, false);
    cConf.setBoolean(Constants.Security.Authorization.ENABLED, true);
    cConf.setInt(Constants.Security.Authorization.CACHE_MAX_ENTRIES, 10000);
    cConf.setInt(Constants.Security.Authorization.CACHE_TTL_SECS, CACHE_TIMEOUT);
    Manifest manifest = new Manifest();
    manifest.getMainAttributes().put(Attributes.Name.MAIN_CLASS, InMemoryAuthorizer.class.getName());
    LocationFactory locationFactory = new LocalLocationFactory(TEMPORARY_FOLDER.newFolder());
    Location externalAuthJar = AppJarHelper.createDeploymentJar(locationFactory, InMemoryAuthorizer.class, manifest);
    cConf.set(Constants.Security.Authorization.EXTENSION_JAR_PATH, externalAuthJar.toString());
    Injector injector = AppFabricTestHelper.getInjector(cConf);
    discoveryService = injector.getInstance(DiscoveryServiceClient.class);
    appFabricServer = injector.getInstance(AppFabricServer.class);
    appFabricServer.startAndWait();
    waitForService(Constants.Service.APP_FABRIC_HTTP);
    authorizationEnforcer = injector.getInstance(RemoteAuthorizationEnforcer.class);
    privilegesManager = injector.getInstance(PrivilegesManager.class);
}
Also used : DiscoveryServiceClient(org.apache.twill.discovery.DiscoveryServiceClient) RemoteAuthorizationEnforcer(co.cask.cdap.security.authorization.RemoteAuthorizationEnforcer) InMemoryAuthorizer(co.cask.cdap.security.authorization.InMemoryAuthorizer) Injector(com.google.inject.Injector) AppFabricServer(co.cask.cdap.internal.app.services.AppFabricServer) PrivilegesManager(co.cask.cdap.security.spi.authorization.PrivilegesManager) Manifest(java.util.jar.Manifest) CConfiguration(co.cask.cdap.common.conf.CConfiguration) LocalLocationFactory(org.apache.twill.filesystem.LocalLocationFactory) LocalLocationFactory(org.apache.twill.filesystem.LocalLocationFactory) LocationFactory(org.apache.twill.filesystem.LocationFactory) Location(org.apache.twill.filesystem.Location) BeforeClass(org.junit.BeforeClass)

Example 2 with LocationFactory

use of org.apache.twill.filesystem.LocationFactory in project cdap by caskdata.

the class LocationsTest method absolutePathTests.

@Test
public void absolutePathTests() throws IOException {
    // Test HDFS:
    Configuration conf = new Configuration();
    conf.set("fs.defaultFS", "hdfs://1.2.3.4:8020/");
    LocationFactory locationFactory = new FileContextLocationFactory(conf, TEST_BASE_PATH);
    Location location1 = locationFactory.create(TEST_PATH);
    Location location2 = Locations.getLocationFromAbsolutePath(locationFactory, location1.toURI().getPath());
    Assert.assertEquals(location1.toURI(), location2.toURI());
    // Test file:
    conf = new Configuration();
    conf.set("fs.defaultFS", "file:///");
    locationFactory = new FileContextLocationFactory(conf, TEST_BASE_PATH);
    location1 = locationFactory.create(TEST_PATH);
    location2 = Locations.getLocationFromAbsolutePath(locationFactory, location1.toURI().getPath());
    Assert.assertEquals(location1.toURI(), location2.toURI());
    // Test LocalLocation
    locationFactory = new LocalLocationFactory(new File(TEST_BASE_PATH));
    location1 = locationFactory.create(TEST_PATH);
    location2 = Locations.getLocationFromAbsolutePath(locationFactory, location1.toURI().getPath());
    Assert.assertEquals(location1.toURI(), location2.toURI());
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) FileContextLocationFactory(org.apache.twill.filesystem.FileContextLocationFactory) LocalLocationFactory(org.apache.twill.filesystem.LocalLocationFactory) File(java.io.File) LocalLocationFactory(org.apache.twill.filesystem.LocalLocationFactory) FileContextLocationFactory(org.apache.twill.filesystem.FileContextLocationFactory) LocationFactory(org.apache.twill.filesystem.LocationFactory) Location(org.apache.twill.filesystem.Location) Test(org.junit.Test)

Example 3 with LocationFactory

use of org.apache.twill.filesystem.LocationFactory in project cdap by caskdata.

the class GatewayFastTestsSuite method buildAppArtifact.

private static File buildAppArtifact(Class<?> cls, String name, File tmpFolder) throws IOException {
    if (!name.endsWith(".jar")) {
        name += ".jar";
    }
    LocationFactory locationFactory = new LocalLocationFactory(tmpFolder);
    Location appJar = AppJarHelper.createDeploymentJar(locationFactory, cls);
    File destination = new File(DirUtils.createTempDir(tmpFolder), name);
    Files.copy(Locations.newInputSupplier(appJar), destination);
    return destination;
}
Also used : LocalLocationFactory(org.apache.twill.filesystem.LocalLocationFactory) File(java.io.File) LocalLocationFactory(org.apache.twill.filesystem.LocalLocationFactory) LocationFactory(org.apache.twill.filesystem.LocationFactory) Location(org.apache.twill.filesystem.Location)

Example 4 with LocationFactory

use of org.apache.twill.filesystem.LocationFactory 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 5 with LocationFactory

use of org.apache.twill.filesystem.LocationFactory in project cdap by caskdata.

the class DFSConcurrentStreamWriterTest method init.

@BeforeClass
public static void init() throws IOException {
    Configuration hConf = new Configuration();
    hConf.set(MiniDFSCluster.HDFS_MINIDFS_BASEDIR, TMP_FOLDER.newFolder().getAbsolutePath());
    dfsCluster = new MiniDFSCluster.Builder(hConf).numDataNodes(1).build();
    dfsCluster.waitClusterUp();
    LocationFactory locationFactory = new FileContextLocationFactory(dfsCluster.getFileSystem().getConf());
    namespacedLocationFactory = new NamespacedLocationFactoryTestClient(CConfiguration.create(), locationFactory);
}
Also used : MiniDFSCluster(org.apache.hadoop.hdfs.MiniDFSCluster) CConfiguration(co.cask.cdap.common.conf.CConfiguration) Configuration(org.apache.hadoop.conf.Configuration) NamespacedLocationFactoryTestClient(co.cask.cdap.common.namespace.NamespacedLocationFactoryTestClient) FileContextLocationFactory(org.apache.twill.filesystem.FileContextLocationFactory) NamespacedLocationFactory(co.cask.cdap.common.namespace.NamespacedLocationFactory) FileContextLocationFactory(org.apache.twill.filesystem.FileContextLocationFactory) LocationFactory(org.apache.twill.filesystem.LocationFactory) BeforeClass(org.junit.BeforeClass)

Aggregations

LocationFactory (org.apache.twill.filesystem.LocationFactory)46 Location (org.apache.twill.filesystem.Location)28 LocalLocationFactory (org.apache.twill.filesystem.LocalLocationFactory)25 BeforeClass (org.junit.BeforeClass)13 File (java.io.File)12 Test (org.junit.Test)12 CConfiguration (co.cask.cdap.common.conf.CConfiguration)11 NamespacedLocationFactory (co.cask.cdap.common.namespace.NamespacedLocationFactory)11 FileContextLocationFactory (org.apache.twill.filesystem.FileContextLocationFactory)9 Injector (com.google.inject.Injector)8 Configuration (org.apache.hadoop.conf.Configuration)8 TransactionSystemClient (org.apache.tephra.TransactionSystemClient)8 Transactional (co.cask.cdap.api.Transactional)6 DatasetManager (co.cask.cdap.api.dataset.DatasetManager)6 ConfigModule (co.cask.cdap.common.guice.ConfigModule)6 DatasetFramework (co.cask.cdap.data2.dataset2.DatasetFramework)6 SystemDatasetInstantiator (co.cask.cdap.data.dataset.SystemDatasetInstantiator)5 DefaultDatasetManager (co.cask.cdap.data2.datafabric.dataset.DefaultDatasetManager)5 MultiThreadDatasetCache (co.cask.cdap.data2.dataset2.MultiThreadDatasetCache)5 HBaseTableUtilFactory (co.cask.cdap.data2.util.hbase.HBaseTableUtilFactory)5