use of org.apache.heron.spi.common.Config in project heron by twitter.
the class TopologyResource method activate.
@POST
@Path("/{cluster}/{role}/{environment}/{name}/activate")
@Produces(MediaType.APPLICATION_JSON)
@SuppressWarnings("IllegalCatch")
public Response activate(@PathParam("cluster") final String cluster, @PathParam("role") final String role, @PathParam("environment") final String environment, @PathParam("name") final String name) {
try {
final Config config = getConfig(cluster, role, environment, name);
getActionFactory().createRuntimeAction(config, ActionType.ACTIVATE).execute();
return Response.ok().type(MediaType.APPLICATION_JSON).entity(Utils.createMessage(String.format("%s activated", name))).build();
} catch (Exception ex) {
LOG.error("error activating topology {}", name, ex);
return Response.serverError().type(MediaType.APPLICATION_JSON).entity(Utils.createMessage(ex.getMessage())).build();
}
}
use of org.apache.heron.spi.common.Config in project heron by twitter.
the class LocalFileSystemUploaderTest method testUploadPackageWhenTopologyFileAlreadyExists.
@Test
public void testUploadPackageWhenTopologyFileAlreadyExists() {
// identify the location of the test topology tar file
String topologyPackage = Paths.get(testTopologyDirectory, TOPOLOGY_PACKAGE_FILE_NAME).toString();
Config newConfig = Config.newBuilder().putAll(config).put(Key.TOPOLOGY_PACKAGE_FILE, topologyPackage).build();
// create the uploader and load the package
LocalFileSystemUploader uploader = new LocalFileSystemUploader();
uploader.initialize(newConfig);
Assert.assertNotNull(uploader.uploadPackage());
// verify if the file exists
String destFile = uploader.getTopologyFile();
Assert.assertTrue(new File(destFile).isFile());
// load same package again by overriding existing one
Assert.assertNotNull(uploader.uploadPackage());
String destFile2 = uploader.getTopologyFile();
Assert.assertTrue(new File(destFile2).isFile());
// verify that existing file is overridden
Assert.assertEquals(destFile, destFile2);
}
use of org.apache.heron.spi.common.Config in project heron by twitter.
the class LocalFileSystemUploaderTest method testUndo.
@Test
public void testUndo() {
// identify the location of the test topology tar file
String topologyPackage = Paths.get(testTopologyDirectory, TOPOLOGY_PACKAGE_FILE_NAME).toString();
Config newConfig = Config.newBuilder().putAll(config).put(Key.TOPOLOGY_PACKAGE_FILE, topologyPackage).build();
// create the uploader and load the package
LocalFileSystemUploader uploader = new LocalFileSystemUploader();
uploader.initialize(newConfig);
Assert.assertNotNull(uploader.uploadPackage());
// verify if the file exists
String destFile = uploader.getTopologyFile();
Assert.assertTrue(new File(destFile).isFile());
// now undo the file
Assert.assertTrue(uploader.undo());
Assert.assertFalse(new File(destFile).isFile());
}
use of org.apache.heron.spi.common.Config in project heron by twitter.
the class LocalFileSystemUploaderTest method testUploader.
@Test
public void testUploader() {
// identify the location of the test topology tar file
String topologyPackage = Paths.get(testTopologyDirectory, TOPOLOGY_PACKAGE_FILE_NAME).toString();
Config newConfig = Config.newBuilder().putAll(config).put(Key.TOPOLOGY_PACKAGE_FILE, topologyPackage).build();
// create the uploader and load the package
LocalFileSystemUploader uploader = new LocalFileSystemUploader();
uploader.initialize(newConfig);
Assert.assertNotNull(uploader.uploadPackage());
// verify if the file exists
String destFile = uploader.getTopologyFile();
Assert.assertTrue(new File(destFile).isFile());
}
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();
}
Aggregations