use of org.apache.heron.spi.common.Config in project heron by twitter.
the class LocalFileSystemUploaderTest method testUploadPackageWhenFileSystemDirectoryIsInvalid.
@Test(expected = IllegalArgumentException.class)
public void testUploadPackageWhenFileSystemDirectoryIsInvalid() {
// identify the location of the test topology tar file
String topologyPackage = Paths.get(testTopologyDirectory, TOPOLOGY_PACKAGE_FILE_NAME).toString();
String invalidFileSystemDirectory = "invalid%path";
// set invalid file system directory
Config newConfig = Config.newBuilder().putAll(config).put(Key.TOPOLOGY_PACKAGE_FILE, topologyPackage).put(LocalFileSystemKey.FILE_SYSTEM_DIRECTORY.value(), invalidFileSystemDirectory).build();
// create the uploader and load the package
LocalFileSystemUploader uploader = new LocalFileSystemUploader();
uploader.initialize(newConfig);
uploader.uploadPackage();
}
use of org.apache.heron.spi.common.Config in project heron by twitter.
the class LocalFileSystemConfigTest method testOverrideConfig.
@Test
public void testOverrideConfig() throws Exception {
String overrideDirectory = "/users/twitter";
Config config = Config.toLocalMode(Config.newBuilder().putAll(getDefaultConfig()).put(LocalFileSystemKey.FILE_SYSTEM_DIRECTORY.value(), overrideDirectory).build());
Assert.assertEquals(LocalFileSystemContext.getFileSystemDirectory(config), overrideDirectory);
}
use of org.apache.heron.spi.common.Config in project heron by twitter.
the class LocalFileSystemConfigTest method testTopologyFile.
@Test
public void testTopologyFile() throws Exception {
Config config = Config.toLocalMode(getDefaultConfig());
LocalFileSystemUploader uploader = new LocalFileSystemUploader();
uploader.initialize(config);
Assert.assertEquals(Paths.get(uploader.getTopologyFile()).getParent().toString(), LocalFileSystemContext.getFileSystemDirectory(config));
}
use of org.apache.heron.spi.common.Config in project heron by twitter.
the class LocalFileSystemContextTest method testGetFileSystemDirectory.
@Test
public void testGetFileSystemDirectory() {
String fileSystemDirectory = "${HOME}/.herondata/topologies/${CLUSTER}";
Config config = Config.newBuilder().put(Key.CLUSTER, "cluster").put(Key.ROLE, "role").put(LocalFileSystemKey.FILE_SYSTEM_DIRECTORY.value(), fileSystemDirectory).build();
// get actual file system directory set by the user
String actualFileSystemDirectory = LocalFileSystemContext.getFileSystemDirectory(config);
String expectedFileSystemDirectory = Paths.get("${HOME}", ".herondata", "topologies", "${CLUSTER}").toString();
Assert.assertEquals(expectedFileSystemDirectory, actualFileSystemDirectory);
}
use of org.apache.heron.spi.common.Config in project heron by twitter.
the class RegistryTest method testGetDownloader.
@Test
public void testGetDownloader() throws Exception {
Map<String, String> protocols = new HashMap<>();
protocols.put("http", "org.apache.heron.downloader.HttpDownloader");
protocols.put("https", "org.apache.heron.downloader.HttpDownloader");
protocols.put("distributedlog", "org.apache.heron.downloader.DLDownloader");
protocols.put("file", "org.apache.heron.downloader.FileDownloader");
Config config = Config.newBuilder().put("heron.downloader.registry", protocols).build();
Map<String, Class<? extends Downloader>> downloaders = new HashMap<>();
downloaders.put("http", HttpDownloader.class);
downloaders.put("https", HttpDownloader.class);
downloaders.put("distributedlog", DLDownloader.class);
downloaders.put("file", FileDownloader.class);
URI httpUri = URI.create("http://127.0.0.1/test/http");
Class<? extends Downloader> clazz = Registry.UriToClass(config, httpUri);
Downloader downloader = Registry.getDownloader(clazz, httpUri);
assertTrue(downloader instanceof HttpDownloader);
URI httpsUri = URI.create("https://127.0.0.1/test/http");
clazz = Registry.UriToClass(config, httpsUri);
downloader = Registry.getDownloader(clazz, httpsUri);
assertTrue(downloader instanceof HttpDownloader);
URI dlUri = URI.create("distributedlog://127.0.0.1/test/distributedlog");
clazz = Registry.UriToClass(config, dlUri);
downloader = Registry.getDownloader(clazz, dlUri);
assertTrue(downloader instanceof DLDownloader);
}
Aggregations