use of com.twitter.heron.spi.common.Config in project incubator-heron by apache.
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 com.twitter.heron.spi.common.Config in project incubator-heron by apache.
the class TopologyResource method kill.
@DELETE
@Path("/{cluster}/{role}/{environment}/{name}")
@Produces(MediaType.APPLICATION_JSON)
@SuppressWarnings("IllegalCatch")
public Response kill(@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.KILL).execute();
return Response.ok().type(MediaType.APPLICATION_JSON).entity(Utils.createMessage(String.format("%s killed", name))).build();
} catch (Exception ex) {
LOG.error("error killing topology {}", name, ex);
final String message = ex.getMessage();
final Response.Status status = message != null && message.contains("does not exist") ? Response.Status.NOT_FOUND : Response.Status.INTERNAL_SERVER_ERROR;
return Response.status(status).type(MediaType.APPLICATION_JSON).entity(Utils.createMessage(message)).build();
}
}
use of com.twitter.heron.spi.common.Config in project incubator-heron by apache.
the class LocalFileSystemConfigTest method testOverrideTopologyFile.
@Test
public void testOverrideTopologyFile() throws Exception {
LocalFileSystemUploader uploader = new LocalFileSystemUploader();
String overrideDirectory = "/users/twitter";
Config config = Config.toLocalMode(Config.newBuilder().putAll(getDefaultConfig()).put(LocalFileSystemKey.FILE_SYSTEM_DIRECTORY.value(), overrideDirectory).build());
uploader.initialize(config);
Assert.assertEquals(Paths.get(uploader.getTopologyFile()).getParent().toString(), overrideDirectory);
}
use of com.twitter.heron.spi.common.Config in project incubator-heron by apache.
the class LocalFileSystemConfigTest method testTopologyDirectory.
@Test
public void testTopologyDirectory() throws Exception {
Config config = Config.toLocalMode(getDefaultConfig());
LocalFileSystemUploader uploader = new LocalFileSystemUploader();
uploader.initialize(config);
Assert.assertEquals(uploader.getTopologyDirectory(), TokenSub.substitute(config, LocalFileSystemKey.FILE_SYSTEM_DIRECTORY.getDefaultString()));
}
use of com.twitter.heron.spi.common.Config in project incubator-heron by apache.
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);
}
Aggregations