Search in sources :

Example 1 with MarathonException

use of mesosphere.marathon.client.MarathonException in project pravega by pravega.

the class BookkeeperService method start.

@Override
public void start(final boolean wait) {
    deleteApp("/pravega/bookkeeper");
    log.info("Starting Bookkeeper Service: {}", getID());
    try {
        marathonClient.createApp(createBookieApp());
        if (wait) {
            waitUntilServiceRunning().get(5, TimeUnit.MINUTES);
        }
    } catch (MarathonException e) {
        handleMarathonException(e);
    } catch (InterruptedException | ExecutionException | TimeoutException ex) {
        throw new TestFrameworkException(InternalError, "Exception while " + "starting Bookkeeper Service", ex);
    }
}
Also used : TestFrameworkException(io.pravega.test.system.framework.TestFrameworkException) MarathonException(mesosphere.marathon.client.MarathonException) ExecutionException(java.util.concurrent.ExecutionException) TimeoutException(java.util.concurrent.TimeoutException)

Example 2 with MarathonException

use of mesosphere.marathon.client.MarathonException 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 MarathonException

use of mesosphere.marathon.client.MarathonException 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 MarathonException

use of mesosphere.marathon.client.MarathonException in project pravega by pravega.

the class PravegaControllerService method start.

/**
 * Start the controller service.
 *
 * @param wait boolean to wait until service is running
 */
@Override
public void start(final boolean wait) {
    deleteApp("/pravega/controller");
    log.debug("Starting service: {}", getID());
    try {
        marathonClient.createApp(createPravegaControllerApp());
        if (wait) {
            waitUntilServiceRunning().get(10, TimeUnit.MINUTES);
        }
    } catch (MarathonException e) {
        handleMarathonException(e);
    } catch (InterruptedException | ExecutionException | TimeoutException ex) {
        throw new TestFrameworkException(InternalError, "Exception while " + "starting Pravega Controller Service", ex);
    }
}
Also used : TestFrameworkException(io.pravega.test.system.framework.TestFrameworkException) MarathonException(mesosphere.marathon.client.MarathonException) ExecutionException(java.util.concurrent.ExecutionException) TimeoutException(java.util.concurrent.TimeoutException)

Example 5 with MarathonException

use of mesosphere.marathon.client.MarathonException 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)

Aggregations

TestFrameworkException (io.pravega.test.system.framework.TestFrameworkException)7 MarathonException (mesosphere.marathon.client.MarathonException)7 ExecutionException (java.util.concurrent.ExecutionException)5 TimeoutException (java.util.concurrent.TimeoutException)4 App (mesosphere.marathon.client.model.v2.App)1 GetAppResponse (mesosphere.marathon.client.model.v2.GetAppResponse)1 Result (mesosphere.marathon.client.model.v2.Result)1