Search in sources :

Example 66 with Config

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

Example 67 with Config

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);
}
Also used : Config(org.apache.heron.spi.common.Config) File(java.io.File) Test(org.junit.Test)

Example 68 with Config

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());
}
Also used : Config(org.apache.heron.spi.common.Config) File(java.io.File) Test(org.junit.Test)

Example 69 with Config

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());
}
Also used : Config(org.apache.heron.spi.common.Config) File(java.io.File) Test(org.junit.Test)

Example 70 with Config

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

Aggregations

Config (org.apache.heron.spi.common.Config)140 Test (org.junit.Test)75 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)29 PackingPlan (org.apache.heron.spi.packing.PackingPlan)22 HashMap (java.util.HashMap)18 SchedulerStateManagerAdaptor (org.apache.heron.spi.statemgr.SchedulerStateManagerAdaptor)18 Pair (org.apache.heron.common.basics.Pair)16 TopologyAPI (org.apache.heron.api.generated.TopologyAPI)15 IOException (java.io.IOException)11 LauncherUtils (org.apache.heron.scheduler.utils.LauncherUtils)11 Map (java.util.Map)10 V1Volume (io.kubernetes.client.openapi.models.V1Volume)9 URI (java.net.URI)9 IScheduler (org.apache.heron.spi.scheduler.IScheduler)9 IStateManager (org.apache.heron.spi.statemgr.IStateManager)9 Before (org.junit.Before)9 File (java.io.File)7 LinkedList (java.util.LinkedList)7 Resource (org.apache.heron.spi.packing.Resource)7 CommandLine (org.apache.commons.cli.CommandLine)6