Search in sources :

Example 1 with App

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

the class BookkeeperService method createBookieApp.

private App createBookieApp() {
    App app = new App();
    app.setId(this.id);
    app.setCpus(cpu);
    app.setMem(mem);
    app.setInstances(instances);
    app.setConstraints(setConstraint("hostname", "UNIQUE"));
    app.setContainer(new Container());
    app.getContainer().setType(CONTAINER_TYPE);
    app.getContainer().setDocker(new Docker());
    app.getContainer().getDocker().setImage(IMAGE_PATH + "/nautilus/bookkeeper:" + PRAVEGA_VERSION);
    Collection<Volume> volumeCollection = new ArrayList<>();
    volumeCollection.add(createVolume("/bk", "mnt", "RW"));
    // TODO: add persistent volume  (see issue https://github.com/pravega/pravega/issues/639)
    app.getContainer().setVolumes(volumeCollection);
    app.setPorts(Arrays.asList(BK_PORT));
    app.setRequirePorts(true);
    // set env
    String zk = zkUri.getHost() + ":" + ZKSERVICE_ZKPORT;
    Map<String, Object> map = new HashMap<>();
    map.put("ZK_URL", zk);
    map.put("ZK", zk);
    map.put("bookiePort", String.valueOf(BK_PORT));
    map.put("DLOG_EXTRA_OPTS", "-Xms512m");
    app.setEnv(map);
    // healthchecks
    List<HealthCheck> healthCheckList = new ArrayList<>();
    healthCheckList.add(setHealthCheck(300, "TCP", false, 60, 20, 0, BK_PORT));
    app.setHealthChecks(healthCheckList);
    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) Volume(mesosphere.marathon.client.model.v2.Volume) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) HealthCheck(mesosphere.marathon.client.model.v2.HealthCheck)

Example 2 with App

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

the class MarathonBasedService method isRunning.

@Override
public boolean isRunning() {
    try {
        GetAppResponse app = marathonClient.getApp(this.id);
        log.debug("App Details: {}", app);
        // and the state of application is healthy.
        if ((app.getApp().getTasksRunning().intValue() == app.getApp().getInstances().intValue()) && app.getApp().getTasksRunning().intValue() == app.getApp().getTasksHealthy().intValue()) {
            log.info("App {} is running", this.id);
            return true;
        } else {
            log.info("App {} is not running", this.id);
            return false;
        }
    } catch (MarathonException ex) {
        if (ex.getStatus() == NOT_FOUND.code()) {
            log.info("App is not running : {}", this.id);
            return false;
        }
        throw new TestFrameworkException(RequestFailed, "Marathon Exception while fetching service details", ex);
    }
}
Also used : GetAppResponse(mesosphere.marathon.client.model.v2.GetAppResponse) TestFrameworkException(io.pravega.test.system.framework.TestFrameworkException) MarathonException(mesosphere.marathon.client.MarathonException)

Example 3 with App

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

the class MarathonBasedService method deleteApp.

void deleteApp(final String appID) {
    try {
        Result result = marathonClient.deleteApp(appID);
        log.info("App: {} deleted, Deployment id is: {}", appID, result.getDeploymentId());
        waitUntilDeploymentPresent(result.getDeploymentId()).get();
    } catch (MarathonException e) {
        if (e.getStatus() == NOT_FOUND.code()) {
            log.debug("Application does not exist");
        } else {
            throw new TestFrameworkException(RequestFailed, "Marathon Exception while deleting service", e);
        }
    } catch (InterruptedException | ExecutionException e) {
        throw new TestFrameworkException(InternalError, "Exception during deleteApp", e);
    }
}
Also used : TestFrameworkException(io.pravega.test.system.framework.TestFrameworkException) MarathonException(mesosphere.marathon.client.MarathonException) ExecutionException(java.util.concurrent.ExecutionException) Result(mesosphere.marathon.client.model.v2.Result)

Example 4 with App

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

the class ZookeeperService method createZookeeperApp.

private App createZookeeperApp() {
    App app = new App();
    app.setId(this.id);
    app.setCpus(cpu);
    app.setMem(mem);
    app.setInstances(instances);
    app.setContainer(new Container());
    app.getContainer().setType(CONTAINER_TYPE);
    app.getContainer().setDocker(new Docker());
    app.getContainer().getDocker().setImage(ZK_IMAGE);
    List<HealthCheck> healthCheckList = new ArrayList<>();
    final HealthCheck hc = setHealthCheck(300, "TCP", false, 60, 20, 0, ZKSERVICE_ZKPORT);
    healthCheckList.add(hc);
    app.setHealthChecks(healthCheckList);
    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) HealthCheck(mesosphere.marathon.client.model.v2.HealthCheck) ArrayList(java.util.ArrayList)

Example 5 with App

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

the class PravegaControllerService method createPravegaControllerApp.

/**
 * To configure the controller app.
 *
 * @return App instance of marathon app
 */
private App createPravegaControllerApp() {
    App app = new App();
    app.setId(this.id);
    app.setCpus(cpu);
    app.setMem(mem);
    app.setInstances(instances);
    app.setConstraints(setConstraint("hostname", "UNIQUE"));
    app.setContainer(new Container());
    app.getContainer().setType(CONTAINER_TYPE);
    app.getContainer().setDocker(new Docker());
    app.getContainer().getDocker().setImage(IMAGE_PATH + "/nautilus/pravega:" + PRAVEGA_VERSION);
    String zk = zkUri.getHost() + ":" + ZKSERVICE_ZKPORT;
    // set port
    app.setPortDefinitions(Arrays.asList(createPortDefinition(CONTROLLER_PORT), createPortDefinition(REST_PORT)));
    app.setRequirePorts(true);
    List<HealthCheck> healthCheckList = new ArrayList<HealthCheck>();
    healthCheckList.add(setHealthCheck(300, "TCP", false, 60, 20, 0, CONTROLLER_PORT));
    app.setHealthChecks(healthCheckList);
    // set env
    String controllerSystemProperties = "-Xmx512m" + setSystemProperty("ZK_URL", zk) + setSystemProperty("CONTROLLER_RPC_PUBLISHED_HOST", this.id + ".marathon.mesos") + setSystemProperty("CONTROLLER_RPC_PUBLISHED_PORT", String.valueOf(CONTROLLER_PORT)) + setSystemProperty("CONTROLLER_SERVER_PORT", String.valueOf(CONTROLLER_PORT)) + setSystemProperty("REST_SERVER_PORT", String.valueOf(REST_PORT)) + setSystemProperty("log.level", "DEBUG") + setSystemProperty("log.dir", "$MESOS_SANDBOX/pravegaLogs") + setSystemProperty("curator-default-session-timeout", String.valueOf(10 * 1000)) + setSystemProperty("MAX_LEASE_VALUE", String.valueOf(60 * 1000)) + setSystemProperty("MAX_SCALE_GRACE_PERIOD", String.valueOf(60 * 1000)) + setSystemProperty("RETENTION_FREQUENCY_MINUTES", String.valueOf(2));
    Map<String, Object> map = new HashMap<>();
    map.put("PRAVEGA_CONTROLLER_OPTS", controllerSystemProperties);
    app.setEnv(map);
    app.setArgs(Arrays.asList("controller"));
    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