mesosphere.marathon.client.utils.MarathonException Java Examples
The following examples show how to use
mesosphere.marathon.client.utils.MarathonException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MarathonAppDeployer.java From spring-cloud-deployer-mesos with Apache License 2.0 | 6 votes |
private void deleteAppsForGroupDeployment(String groupId) throws MarathonException { Group group = marathon.getGroup(groupId); for (App app : group.getApps()) { logger.debug(String.format("Deleting application %s in group %s", app.getId(), groupId)); marathon.deleteApp(app.getId()); } group = marathon.getGroup(groupId); if (logger.isDebugEnabled()) { logger.debug(String.format("Group %s has %d applications and %d groups", group.getId(), group.getApps().size(), group.getGroups().size())); } if (group.getApps().size() == 0 && group.getGroups().size() == 0) { logger.info(String.format("Deleting group: %s", groupId)); marathon.deleteGroup(groupId); } deleteTopLevelGroupForDeployment(groupId); }
Example #2
Source File: MarathonAppDeployer.java From spring-cloud-deployer-mesos with Apache License 2.0 | 6 votes |
@Override public RuntimeEnvironmentInfo environmentInfo() { String apiVersion = "v1"; String hostVersion = "unknown"; String frameworkId = "unknown"; String leader = "unknown"; try { GetServerInfoResponse serverInfo = marathon.getServerInfo(); hostVersion = serverInfo.getVersion(); frameworkId = serverInfo.getFrameworkId(); leader = serverInfo.getLeader(); } catch (MarathonException ignore) {} return new RuntimeEnvironmentInfo.Builder() .spiClass(AppDeployer.class) .implementationName(this.getClass().getSimpleName()) .implementationVersion(RuntimeVersionUtils.getVersion(this.getClass())) .platformType("Mesos") .platformApiVersion(apiVersion) .platformClientVersion(RuntimeVersionUtils.getVersion(marathon.getClass())) .platformHostVersion(hostVersion) .addPlatformSpecificInfo("leader", leader) .addPlatformSpecificInfo("frameworkId", frameworkId) .build(); }
Example #3
Source File: MarathonAppDeployer.java From spring-cloud-deployer-mesos with Apache License 2.0 | 6 votes |
private AppInstanceStatus buildInstanceStatus(String id) throws MarathonException { App appInstance = marathon.getApp(id).getApp(); logger.debug("Deployment " + id + " has " + appInstance.getTasksRunning() + "/" + appInstance.getInstances() + " tasks running"); if (appInstance.getTasks() != null) { // there should only be one task for this type of deployment MarathonAppInstanceStatus status = null; for (Task task : appInstance.getTasks()) { if (status == null) { status = MarathonAppInstanceStatus.up(appInstance, task); } } if (status == null) { status = MarathonAppInstanceStatus.down(appInstance); } return status; } else { return MarathonAppInstanceStatus.down(appInstance); } }
Example #4
Source File: MarathonAppDeployer.java From spring-cloud-deployer-mesos with Apache License 2.0 | 5 votes |
private void deleteTopLevelGroupForDeployment(String id) throws MarathonException { String topLevelGroupId = extractGroupId(id); if (topLevelGroupId != null) { Group topGroup = marathon.getGroup(topLevelGroupId); if (logger.isDebugEnabled()) { logger.debug(String.format("Top level group %s has %d applications and %d groups", topGroup.getId(), topGroup.getApps().size(), topGroup.getGroups().size())); } if (topGroup.getApps().size() == 0 && topGroup.getGroups().size() == 0) { logger.info(String.format("Deleting group: %s", topLevelGroupId)); marathon.deleteGroup(topLevelGroupId); } } }
Example #5
Source File: MarathonContainer.java From minimesos with Apache License 2.0 | 5 votes |
/** * Deploys a Marathon app by JSON string * * @param marathonJson JSON string */ @Override public void deployApp(String marathonJson) { mesosphere.marathon.client.Marathon marathon = MarathonClient.getInstance(getMarathonEndpoint()); try { marathon.createApp(constructApp(marathonJson)); } catch (MarathonException e) { throw new MinimesosException("Marathon did not accept the app, error: " + e.toString()); } LOGGER.debug(format("Installed app at '%s'", getMarathonEndpoint())); }
Example #6
Source File: MarathonContainer.java From minimesos with Apache License 2.0 | 5 votes |
@Override public Result deleteApp(String appId) { mesosphere.marathon.client.Marathon marathon = MarathonClient.getInstance(getMarathonEndpoint()); try { Result result = marathon.deleteApp(appId); LOGGER.debug(format("Deleted app '%s' at '%s'", appId, getMarathonEndpoint())); return result; } catch (MarathonException e) { throw new MinimesosException("Could not delete app '" + appId + "'. " + e.getMessage()); } }
Example #7
Source File: MarathonContainer.java From minimesos with Apache License 2.0 | 5 votes |
@Override public Result deleteGroup(String groupId) { mesosphere.marathon.client.Marathon marathon = MarathonClient.getInstance(getMarathonEndpoint()); try { Result result = marathon.deleteGroup(groupId); LOGGER.debug(format("Deleted app '%s' at '%s'", groupId, getMarathonEndpoint())); return result; } catch (MarathonException e) { throw new MinimesosException("Could not delete group '" + groupId + "'. " + e.getMessage()); } }
Example #8
Source File: MarathonContainer.java From minimesos with Apache License 2.0 | 5 votes |
/** * Updates a Marathon app by JSON string * * @param marathonJson JSON string */ @Override public void updateApp(String marathonJson) { mesosphere.marathon.client.Marathon marathon = MarathonClient.getInstance(getMarathonEndpoint()); try { App app = constructApp(marathonJson); marathon.updateApp(app.getId(), app, true); } catch (MarathonException e) { throw new MinimesosException("Marathon could not update the app, error: " + e.toString()); } LOGGER.debug(format("Installing an app on marathon %s", getMarathonEndpoint())); }
Example #9
Source File: MarathonAppDeployer.java From spring-cloud-deployer-mesos with Apache License 2.0 | 4 votes |
private void createAppDeployment(AppDeploymentRequest request, String deploymentId, Container container, Integer index) { App app = new App(); app.setContainer(container); app.setId(deploymentId); Map<String, String> env = new HashMap<>(); env.putAll(request.getDefinition().getProperties()); for (String envVar : properties.getEnvironmentVariables()) { String[] strings = envVar.split("=", 2); Assert.isTrue(strings.length == 2, "Invalid environment variable declared: " + envVar); env.put(strings[0], strings[1]); } if (index != null) { env.put(INSTANCE_INDEX_PROPERTY_KEY, index.toString()); } app.setEnv(env); Collection<String> uris = deduceUris(request); app.setUris(uris); Collection<Constraint> constraints = deduceConstraints(request); app.setConstraints(constraints.stream().map(Constraint::toStringList).collect(Collectors.toList())); Double cpus = deduceCpus(request); Double memory = deduceMemory(request); Integer instances = index == null ? deduceInstances(request) : 1; app.setCpus(cpus); app.setMem(memory); app.setInstances(instances); HealthCheck healthCheck = new HealthCheck(); healthCheck.setPath("/health"); healthCheck.setGracePeriodSeconds(300); app.setHealthChecks(Arrays.asList(healthCheck)); logger.debug("Creating app with definition:\n" + app.toString()); try { marathon.createApp(app); } catch (MarathonException e) { throw new RuntimeException(e); } }
Example #10
Source File: MarathonClient.java From marathon-client with Apache License 2.0 | 4 votes |
@Override public Exception decode(String methodKey, Response response) { return new MarathonException(response.status(), response.reason()); }
Example #11
Source File: Marathon.java From marathon-client with Apache License 2.0 | 4 votes |
@RequestLine("GET /v2/apps/{id}") GetAppResponse getApp(@Named("id") String id) throws MarathonException;
Example #12
Source File: Marathon.java From marathon-client with Apache License 2.0 | 4 votes |
@RequestLine("POST /v2/apps") App createApp(App app) throws MarathonException;
Example #13
Source File: Marathon.java From marathon-client with Apache License 2.0 | 4 votes |
@RequestLine("DELETE /v2/apps/{id}") Result deleteApp(@Named("id") String id) throws MarathonException;
Example #14
Source File: Marathon.java From marathon-client with Apache License 2.0 | 4 votes |
@RequestLine("POST /v2/groups") Result createGroup(Group group) throws MarathonException;
Example #15
Source File: Marathon.java From marathon-client with Apache License 2.0 | 4 votes |
@RequestLine("DELETE /v2/groups/{id}") Result deleteGroup(@Named("id") String id) throws MarathonException;
Example #16
Source File: Marathon.java From marathon-client with Apache License 2.0 | 4 votes |
@RequestLine("GET /v2/groups/{id}") Group getGroup(@Named("id") String id) throws MarathonException;