Search in sources :

Example 6 with App

use of mesosphere.marathon.client.model.v2.App in project pravega by pravega.

the class MarathonBasedService method scaleService.

@Override
public CompletableFuture<Void> scaleService(final int instanceCount) {
    Preconditions.checkArgument(instanceCount >= 0, "negative value: %s", instanceCount);
    try {
        App updatedConfig = new App();
        updatedConfig.setInstances(instanceCount);
        marathonClient.updateApp(getID(), updatedConfig, true);
        // wait until scale operation is complete.
        return waitUntilServiceRunning();
    } catch (MarathonException ex) {
        if (ex.getStatus() == CONFLICT.code()) {
            log.error("Scaling operation failed as the application is locked by an ongoing deployment", ex);
            throw new TestFrameworkException(RequestFailed, "Scaling operation failed", ex);
        }
        handleMarathonException(ex);
    }
    return null;
}
Also used : App(mesosphere.marathon.client.model.v2.App) TestFrameworkException(io.pravega.test.system.framework.TestFrameworkException) MarathonException(mesosphere.marathon.client.MarathonException)

Example 7 with App

use of mesosphere.marathon.client.model.v2.App in project pravega by pravega.

the class PravegaSegmentStoreService method createPravegaSegmentStoreApp.

private App createPravegaSegmentStoreApp() {
    App app = new App();
    app.setId(this.id);
    app.setCpus(cpu);
    app.setMem(mem);
    app.setInstances(instances);
    // set constraints
    app.setConstraints(setConstraint("hostname", "UNIQUE"));
    // docker container
    app.setContainer(new Container());
    app.getContainer().setType(CONTAINER_TYPE);
    app.getContainer().setDocker(new Docker());
    // set the image and network
    app.getContainer().getDocker().setImage(IMAGE_PATH + "/nautilus/pravega:" + PRAVEGA_VERSION);
    // set port
    app.setPortDefinitions(Arrays.asList(createPortDefinition(SEGMENTSTORE_PORT)));
    app.setRequirePorts(true);
    // healthchecks
    List<HealthCheck> healthCheckList = new ArrayList<HealthCheck>();
    healthCheckList.add(setHealthCheck(300, "TCP", false, 60, 20, 0, SEGMENTSTORE_PORT));
    app.setHealthChecks(healthCheckList);
    // set env
    String zk = zkUri.getHost() + ":" + ZKSERVICE_ZKPORT;
    // Environment variables to configure SS service.
    Map<String, Object> map = new HashMap<>();
    map.put("ZK_URL", zk);
    map.put("BK_ZK_URL", zk);
    map.put("CONTROLLER_URL", conUri.toString());
    getCustomEnvVars(map, SEGMENTSTORE_EXTRA_ENV);
    // Properties set to override defaults for system tests
    String hostSystemProperties = "-Xmx1024m" + setSystemProperty("autoScale.muteInSeconds", "120") + setSystemProperty("autoScale.cooldownInSeconds", "120") + setSystemProperty("autoScale.cacheExpiryInSeconds", "120") + setSystemProperty("autoScale.cacheCleanUpInSeconds", "120") + setSystemProperty("log.level", "DEBUG") + setSystemProperty("log.dir", "$MESOS_SANDBOX/pravegaLogs") + setSystemProperty("curator-default-session-timeout", String.valueOf(30 * 1000)) + setSystemProperty("hdfs.replaceDataNodesOnFailure", "false");
    map.put("PRAVEGA_SEGMENTSTORE_OPTS", hostSystemProperties);
    app.setEnv(map);
    app.setArgs(Arrays.asList("segmentstore"));
    return app;
}
Also used : App(mesosphere.marathon.client.model.v2.App) Container(mesosphere.marathon.client.model.v2.Container) Docker(mesosphere.marathon.client.model.v2.Docker) HashMap(java.util.HashMap) HealthCheck(mesosphere.marathon.client.model.v2.HealthCheck) ArrayList(java.util.ArrayList)

Aggregations

App (mesosphere.marathon.client.model.v2.App)5 ArrayList (java.util.ArrayList)4 Container (mesosphere.marathon.client.model.v2.Container)4 Docker (mesosphere.marathon.client.model.v2.Docker)4 HealthCheck (mesosphere.marathon.client.model.v2.HealthCheck)4 TestFrameworkException (io.pravega.test.system.framework.TestFrameworkException)3 HashMap (java.util.HashMap)3 MarathonException (mesosphere.marathon.client.MarathonException)3 ExecutionException (java.util.concurrent.ExecutionException)1 GetAppResponse (mesosphere.marathon.client.model.v2.GetAppResponse)1 Result (mesosphere.marathon.client.model.v2.Result)1 Volume (mesosphere.marathon.client.model.v2.Volume)1