use of org.apache.twill.filesystem.LocalLocationFactory 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.LocalLocationFactory in project cdap by caskdata.
the class StreamAdminTest method addCConfProperties.
protected static void addCConfProperties(CConfiguration cConf) throws IOException {
File rootLocationFactoryPath = TEMPORARY_FOLDER.newFolder();
cConf.setBoolean(Constants.Security.ENABLED, true);
cConf.setBoolean(Constants.Security.Authorization.ENABLED, true);
cConf.setBoolean(Constants.Security.KERBEROS_ENABLED, false);
cConf.setInt(Constants.Security.Authorization.CACHE_MAX_ENTRIES, 0);
LocationFactory locationFactory = new LocalLocationFactory(rootLocationFactoryPath);
Location authorizerJar = AppJarHelper.createDeploymentJar(locationFactory, InMemoryAuthorizer.class);
cConf.set(Constants.Security.Authorization.EXTENSION_JAR_PATH, authorizerJar.toURI().getPath());
}
use of org.apache.twill.filesystem.LocalLocationFactory in project cdap by caskdata.
the class LocalConcurrentStreamWriterTest method init.
@BeforeClass
public static void init() throws IOException {
LocationFactory locationFactory = new LocalLocationFactory(TMP_FOLDER.newFolder());
namespacedLocationFactory = new NamespacedLocationFactoryTestClient(CConfiguration.create(), locationFactory);
}
use of org.apache.twill.filesystem.LocalLocationFactory in project cdap by caskdata.
the class ServePathGeneratorTest method testGetServePath.
@Test
public void testGetServePath() throws Exception {
URL jarUrl = getClass().getResource("/CountRandomWebapp-localhost.jar");
Assert.assertNotNull(jarUrl);
final JarResources jarResources = new JarResources(new LocalLocationFactory().create(jarUrl.toURI()));
Predicate<String> fileExists = new Predicate<String>() {
@Override
public boolean apply(@Nullable String file) {
return file != null && jarResources.getResource(file) != null;
}
};
ServePathGenerator servePathGenerator = new ServePathGenerator(Constants.Webapp.WEBAPP_DIR, fileExists);
Assert.assertEquals("/webapp/127.0.0.1:20000/netlens/src/index.html", servePathGenerator.getServePath("127.0.0.1:20000", "/netlens"));
Assert.assertEquals("/webapp/127.0.0.1:20000/netlens/src/index.html", servePathGenerator.getServePath("127.0.0.1:20000", "/netlens/index.html"));
Assert.assertEquals("/webapp/127.0.0.1:20000/netlens/src/index.html", servePathGenerator.getServePath("127.0.0.1:20000", "/netlens/"));
Assert.assertEquals("/webapp/127.0.0.1:20000/netlens/src/index.html", servePathGenerator.getServePath("127.0.0.1:20000", "/netlens/"));
Assert.assertEquals("/webapp/default/src/index.html", servePathGenerator.getServePath("127.0.0.1:30000", "/"));
Assert.assertEquals("/webapp/default/src/index.html", servePathGenerator.getServePath("127.0.0.1:30000", "/index.html"));
Assert.assertEquals("/webapp/127.0.0.1:20000/src/netlens/2.txt", servePathGenerator.getServePath("127.0.0.1:20000", "netlens/2.txt"));
Assert.assertEquals("/webapp/default/netlens/src/1.txt", servePathGenerator.getServePath("127.0.0.1:80", "/netlens/1.txt?count=100"));
Assert.assertEquals("/webapp/default/netlens/src/data/data.txt", servePathGenerator.getServePath("127.0.0.1:30000", "/netlens/data/data.txt"));
Assert.assertEquals("/v3/apps?count=10", servePathGenerator.getServePath("127.0.0.1:30000", "/netlens/v3/apps?count=10"));
Assert.assertEquals("/v3/apps?count=10", servePathGenerator.getServePath("127.0.0.1:30000", "/v3/apps?count=10"));
Assert.assertEquals("/status", servePathGenerator.getServePath("127.0.0.1:30000", "/netlens/status"));
Assert.assertEquals("/status", servePathGenerator.getServePath("127.0.0.1:30000", "/status"));
servePathGenerator = new ServePathGenerator(Constants.Webapp.WEBAPP_DIR + "/", fileExists);
Assert.assertEquals("/webapp/www.abc.com:80/geo/src/data/data.txt", servePathGenerator.getServePath("www.abc.com", "/geo/data/data.txt"));
Assert.assertEquals("/webapp/www.abc.com:80/geo/src/data/data.txt", servePathGenerator.getServePath("www.abc.com:80", "/geo/data/data.txt"));
Assert.assertEquals("/webapp/default/netlens/src/data/data.txt", servePathGenerator.getServePath("www.abc.com:30000", "/netlens/data/data.txt"));
Assert.assertEquals("/geo/data/data.txt", servePathGenerator.getServePath("www.abc.com:30000", "/geo/data/data.txt"));
}
use of org.apache.twill.filesystem.LocalLocationFactory in project cdap by caskdata.
the class MetadataAdminAuthorizationTest method createCConf.
private static CConfiguration createCConf() throws IOException {
CConfiguration cConf = CConfiguration.create();
cConf.setBoolean(Constants.Security.ENABLED, true);
cConf.setBoolean(Constants.Security.Authorization.ENABLED, true);
// we only want to test authorization, but we don't specify principal/keytab, so disable kerberos
cConf.setBoolean(Constants.Security.KERBEROS_ENABLED, false);
cConf.setInt(Constants.Security.Authorization.CACHE_MAX_ENTRIES, 0);
LocationFactory locationFactory = new LocalLocationFactory(new File(TEMPORARY_FOLDER.newFolder().toURI()));
Location authorizerJar = AppJarHelper.createDeploymentJar(locationFactory, InMemoryAuthorizer.class);
cConf.set(Constants.Security.Authorization.EXTENSION_JAR_PATH, authorizerJar.toURI().getPath());
return cConf;
}
Aggregations