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);
}
}
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);
}
}
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);
}
}
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);
}
}
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;
}
Aggregations