本文整理汇总了Java中mesosphere.marathon.client.model.v2.App类的典型用法代码示例。如果您正苦于以下问题:Java App类的具体用法?Java App怎么用?Java App使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
App类属于mesosphere.marathon.client.model.v2包,在下文中一共展示了App类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getGoAgents
import mesosphere.marathon.client.model.v2.App; //导入依赖的package包/类
public List<MarathonInstance> getGoAgents(PluginSettings settings) {
List<MarathonInstance> appList = new ArrayList<>();
try {
for (App app: marathon.getGroup(getPrefix()).getApps()) {
app.setTasks(marathon.getAppTasks(app.getId()).getTasks());
try {
appList.add(MarathonInstance.instanceFromApp(app, settings));
} catch (Exception f) {
LOG.error("instanceFromApp failed: " + f.toString(), f);
}
}
} catch (Exception e) {
LOG.error("GetGroup Failed: " + e.toString(), e);
}
return appList;
}
示例2: extractServiceInstances
import mesosphere.marathon.client.model.v2.App; //导入依赖的package包/类
/**
* Extract instances of a service for a specific marathon application
*
* @param app
* @return
*/
private List<MarathonServer> extractServiceInstances(App app) {
log.debug("Discovered service [{}]", app.getId());
if (app.getTasks().isEmpty())
return Collections.emptyList();
return app.getTasks()
.stream()
.map(task -> {
Collection<HealthCheckResults> healthChecks =
null != task.getHealthCheckResults()
? task.getHealthCheckResults()
: new ArrayList<>();
return new MarathonServer(
task.getHost(),
task.getPorts().stream().findFirst().orElse(0),
healthChecks
).withZone(extractZoneFromHostname(task.getHost()));
})
.collect(Collectors.toList());
}
示例3: getInstances
import mesosphere.marathon.client.model.v2.App; //导入依赖的package包/类
private List<ServiceInstance> getInstances(Map<String, String> queryMap) throws MarathonException {
List<ServiceInstance> instances = new ArrayList<>();
GetAppsResponse appsResponse = queryMap == null ? client.getApps() : client.getApps(queryMap);
if (appsResponse != null && appsResponse.getApps() != null) {
List<App> apps = appsResponse.getApps();
log.debug("Discovered {} service{}{}", apps.size(), apps.size() == 1 ? "" : "s", queryMap == null ? "" : String.format(" with ids that contain [%s]", queryMap.get("id")));
for (App app : apps) {
// Fetch data for this specific service id, to collect task information
GetAppResponse response = client.getApp(app.getId());
if (response != null && response.getApp() != null) {
instances.addAll(extractServiceInstances(response.getApp()));
}
}
}
return instances;
}
示例4: doHealthCheck
import mesosphere.marathon.client.model.v2.App; //导入依赖的package包/类
@Override
protected void doHealthCheck(Health.Builder builder) throws Exception {
try {
GetServerInfoResponse serverInfo = client.getServerInfo();
List<App> apps = client.getApps().getApps();
builder.up()
.withDetail("services", apps)
.withDetail("name", serverInfo.getName())
.withDetail("leader", serverInfo.getLeader())
.withDetail("http_port", serverInfo.getHttp_config().getHttp_port())
.withDetail("https_port", serverInfo.getHttp_config().getHttps_port())
.withDetail("hostname", serverInfo.getMarathon_config().getHostname())
.withDetail("local_port_min", serverInfo.getMarathon_config().getLocal_port_min())
.withDetail("local_port_max", serverInfo.getMarathon_config().getLocal_port_max());
}
catch (Exception e) {
builder.down(e);
}
}
示例5: deleteAppsForGroupDeployment
import mesosphere.marathon.client.model.v2.App; //导入依赖的package包/类
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);
}
示例6: buildInstanceStatus
import mesosphere.marathon.client.model.v2.App; //导入依赖的package包/类
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);
}
}
示例7: buildAppStatus
import mesosphere.marathon.client.model.v2.App; //导入依赖的package包/类
private AppStatus buildAppStatus(String id, App app) {
logger.debug("Deployment " + id + " has " + app.getTasksRunning() + "/" + app.getInstances() + " tasks running");
AppStatus.Builder result = AppStatus.of(id);
int requestedInstances = app.getInstances();
int actualInstances = 0;
if (app.getTasks() != null) {
for (Task task : app.getTasks()) {
result.with(MarathonAppInstanceStatus.up(app, task));
actualInstances++;
}
}
for (int i = actualInstances; i < requestedInstances; i++) {
result.with(MarathonAppInstanceStatus.down(app));
}
return result.build();
}
示例8: createZookeeperApp
import mesosphere.marathon.client.model.v2.App; //导入依赖的package包/类
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;
}
示例9: getAppTasks
import mesosphere.marathon.client.model.v2.App; //导入依赖的package包/类
private void getAppTasks(Marathon marathon, App app) throws MojoExecutionException {
try {
final GetAppTasksResponse getAppTasksResponse = marathon.getAppTasks(app.getId());
int taskCount = 0;
for (final Task task : getAppTasksResponse.getTasks()) {
final String hostPropertyName = propertyPrefix + "host" + taskCount;
project.getProperties().put(hostPropertyName, task.getHost());
getLog().info("Setting " + hostPropertyName + " = " + task.getHost());
int portCount = 0;
for (final Integer port : task.getPorts()) {
final String portPropertyName = propertyPrefix + "port"
+ taskCount + "-" + portCount;
project.getProperties().put(portPropertyName, String.valueOf(port));
getLog().info("Setting " + portPropertyName + " = " + port);
portCount++;
}
taskCount++;
}
} catch (Exception deleteAppException) {
throw new MojoExecutionException("Failed to get tasks for Marathon instance "
+ marathonHost, deleteAppException);
}
}
示例10: execute
import mesosphere.marathon.client.model.v2.App; //导入依赖的package包/类
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
final Marathon marathon = MarathonClient.getInstance(marathonHost);
App app = readApp(finalMarathonConfigFile);
getLog().info("deploying Marathon config for " + app.getId()
+ " from " + finalMarathonConfigFile + " to " + marathonHost);
if (appExists(marathon, app.getId())) {
getLog().info(app.getId() + " already exists - will be updated");
updateApp(marathon, app);
} else {
getLog().info(app.getId() + " does not exist yet - will be created");
app = createApp(marathon, app);
}
if (waitForDeploymentFinished) {
try {
waitForApp(marathon, app);
} catch (MarathonException e) {
throw new MojoExecutionException("error waiting for app", e);
}
}
}
示例11: testSuccessfulDeployAppNotCreatedYet
import mesosphere.marathon.client.model.v2.App; //导入依赖的package包/类
@Test
public void testSuccessfulDeployAppNotCreatedYet() throws Exception {
server.enqueue(new MockResponse().setResponseCode(404));
server.enqueue(new MockResponse().setResponseCode(200));
final DeployMojo mojo = lookupDeployMojo();
assertNotNull(mojo);
mojo.execute();
assertEquals(2, server.getRequestCount());
RecordedRequest getAppRequest = server.takeRequest();
assertEquals(MARATHON_PATH + APP_ID, getAppRequest.getPath());
assertEquals("GET", getAppRequest.getMethod());
RecordedRequest createAppRequest = server.takeRequest();
assertEquals(MARATHON_PATH, createAppRequest.getPath());
assertEquals("POST", createAppRequest.getMethod());
App requestApp = ModelUtils.GSON.fromJson(createAppRequest.getBody().readUtf8(), App.class);
assertNotNull(requestApp);
assertEquals(APP_ID, requestApp.getId());
}
示例12: testSuccessfulDeployAppAlreadyExists
import mesosphere.marathon.client.model.v2.App; //导入依赖的package包/类
@Test
public void testSuccessfulDeployAppAlreadyExists() throws Exception {
server.enqueue(new MockResponse().setResponseCode(200));
server.enqueue(new MockResponse().setResponseCode(200));
final DeployMojo mojo = lookupDeployMojo();
assertNotNull(mojo);
mojo.execute();
assertEquals(2, server.getRequestCount());
RecordedRequest getAppRequest = server.takeRequest();
assertEquals(MARATHON_PATH + APP_ID, getAppRequest.getPath());
assertEquals("GET", getAppRequest.getMethod());
RecordedRequest updateAppRequest = server.takeRequest();
assertEquals(MARATHON_PATH + APP_ID+ "?force=false", updateAppRequest.getPath());
assertEquals("PUT", updateAppRequest.getMethod());
App requestApp = ModelUtils.GSON.fromJson(updateAppRequest.getBody().readUtf8(), App.class);
assertNotNull(requestApp);
assertEquals(APP_ID, requestApp.getId());
}
示例13: mergeApp
import mesosphere.marathon.client.model.v2.App; //导入依赖的package包/类
private void mergeApp(Customer customer, App newApp, App oldApp)
{
// add customer id as service tag
Map<String, String> envVariables = newApp.getEnv();
if (envVariables.containsKey("SERVICE_TAGS")) {
envVariables.put("SERVICE_TAGS", envVariables.get("SERVICE_TAGS") + ",customer-" + customer.getId());
} else {
envVariables.put("SERVICE_TAGS", "customer-" + customer.getId());
}
if (null == oldApp) {
return;
}
// only merge settings for scaled applications
if (null != newApp.getLabels() && newApp.getLabels().containsKey(MarathonMonitor.LABEL_SCALING_STRATEGY)) {
return;
}
newApp.setInstances(oldApp.getInstances());
newApp.setCpus(oldApp.getCpus());
newApp.setMem(oldApp.getMem());
}
示例14: testScaleUpByCPU
import mesosphere.marathon.client.model.v2.App; //导入依赖的package包/类
@Test
public void testScaleUpByCPU()
{
App app = createApp(1, 3);
AppStatistics statistics = createStatistics(1, 100);
// 100% across one instance => add one more
horizontal.scale(app, statistics);
assertSame(2, app.getInstances());
// 100% across two instance (50%) => do nothing
horizontal.scale(app, statistics);
assertSame(2, app.getInstances());
// 200% across two instances => add one more
statistics.setCpu(Optional.of(2f));
horizontal.scale(app, statistics);
assertSame(3, app.getInstances());
// 300% across 3 instances => do nothing, already max instances
statistics.setCpu(Optional.of(3f));
horizontal.scale(app, statistics);
assertSame(3, app.getInstances());
}
示例15: testScaleDownByCPU
import mesosphere.marathon.client.model.v2.App; //导入依赖的package包/类
@Test
public void testScaleDownByCPU()
{
App app = createApp(2, 4);
AppStatistics statistics = createStatistics(0, 32);
app.setInstances(4);
// 0% across 4 instances => scale down by one
horizontal.scale(app, statistics);
assertSame(3, app.getInstances());
// 0% across 3 instances => scale down by one
horizontal.scale(app, statistics);
assertSame(2, app.getInstances());
// 0% across 2 instances => do nothing, already min instances
horizontal.scale(app, statistics);
assertSame(2, app.getInstances());
}