Search in sources :

Example 86 with Config

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();
    }
}
Also used : Config(com.twitter.heron.spi.common.Config) IOException(java.io.IOException) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces)

Example 87 with Config

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();
    }
}
Also used : Config(com.twitter.heron.spi.common.Config) IOException(java.io.IOException) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) Produces(javax.ws.rs.Produces)

Example 88 with Config

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);
}
Also used : Config(com.twitter.heron.spi.common.Config) Test(org.junit.Test)

Example 89 with Config

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()));
}
Also used : Config(com.twitter.heron.spi.common.Config) Test(org.junit.Test)

Example 90 with Config

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);
}
Also used : Config(com.twitter.heron.spi.common.Config) Test(org.junit.Test)

Aggregations

Config (com.twitter.heron.spi.common.Config)211 Test (org.junit.Test)125 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)60 PackingPlan (com.twitter.heron.spi.packing.PackingPlan)53 TopologyAPI (com.twitter.heron.api.generated.TopologyAPI)43 SchedulerStateManagerAdaptor (com.twitter.heron.spi.statemgr.SchedulerStateManagerAdaptor)35 LauncherUtils (com.twitter.heron.scheduler.utils.LauncherUtils)19 IStateManager (com.twitter.heron.spi.statemgr.IStateManager)18 IScheduler (com.twitter.heron.spi.scheduler.IScheduler)17 HashMap (java.util.HashMap)16 Before (org.junit.Before)16 ILauncher (com.twitter.heron.spi.scheduler.ILauncher)14 IOException (java.io.IOException)13 Resource (com.twitter.heron.spi.packing.Resource)12 URI (java.net.URI)12 HashSet (java.util.HashSet)11 CommandLine (org.apache.commons.cli.CommandLine)10 ByteAmount (com.twitter.heron.common.basics.ByteAmount)9 ISchedulerClient (com.twitter.heron.scheduler.client.ISchedulerClient)9 File (java.io.File)9