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);
}
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());
}
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;
}
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();
}
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);
}
Aggregations