本文整理汇总了Java中mesosphere.marathon.client.model.v2.Task类的典型用法代码示例。如果您正苦于以下问题:Java Task类的具体用法?Java Task怎么用?Java Task使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Task类属于mesosphere.marathon.client.model.v2包,在下文中一共展示了Task类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildInstanceStatus
import mesosphere.marathon.client.model.v2.Task; //导入依赖的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);
}
}
示例2: buildAppStatus
import mesosphere.marathon.client.model.v2.Task; //导入依赖的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();
}
示例3: getAppTasks
import mesosphere.marathon.client.model.v2.Task; //导入依赖的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);
}
}
示例4: setup
import mesosphere.marathon.client.model.v2.Task; //导入依赖的package包/类
@Before
public void setup() throws MarathonException {
serverList = new MarathonServerList(
marathonClient,
new MarathonDiscoveryProperties()
);
IClientConfig config = mock(IClientConfig.class);
when(config.getClientName()).thenReturn("service1");
Map<String, Object> properties = new HashMap<>();
properties.put("IgnoreServiceId",false);
when(config.getProperties()).thenReturn(properties);
serverList.initWithNiwsConfig(config);
GetAppResponse appResponse = new GetAppResponse();
when(marathonClient.getApp("/service1"))
.thenReturn(appResponse);
App app = new App();
appResponse.setApp(app);
app.setTasks(IntStream.of(1,2)
.mapToObj(index -> {
Task task = new Task();
task.setHost("host" + index);
task.setPorts(IntStream.of(9090, 9091)
.boxed()
.collect(Collectors.toList()));
task.setHealthCheckResults(Collections.emptyList());
return task;
}).collect(Collectors.toList())
);
Task withNullHealthChecks = new Task();
withNullHealthChecks.setHost("host3");
withNullHealthChecks.setPorts(IntStream.of(9090, 9091)
.boxed()
.collect(Collectors.toList()));
app.getTasks().add(withNullHealthChecks);
}
示例5: setup
import mesosphere.marathon.client.model.v2.Task; //导入依赖的package包/类
@Before
public void setup() throws MarathonException {
serverList = new MarathonServerList(
marathonClient,
new MarathonDiscoveryProperties()
);
IClientConfig config = mock(IClientConfig.class);
when(config.getClientName()).thenReturn("service1");
LinkedHashMap<String, Object> properties = new LinkedHashMap<>();
properties.put("IgnoreServiceId",true);
properties.put("MetaDataFilter.A","A");
properties.put("MetaDataFilter.B","in(V1,V2,V3)");
properties.put("MetaDataFilter.C","!=X");
properties.put("MetaDataFilter.D","==Y");
properties.put("MetaDataFilter.E","notin(1,2,3)");
when(config.getProperties()).thenReturn(properties);
serverList.initWithNiwsConfig(config);
GetAppResponse appResponse = new GetAppResponse();
when(marathonClient.getApp("/service1"))
.thenReturn(appResponse);
GetAppsResponse appsResponse = new GetAppsResponse();
Map<String,String> queryMap = new HashMap<>();
queryMap.put("label","A==A,B in(V1,V2,V3),C!=X,D==Y,E notin(1,2,3)");
when(marathonClient.getApps(queryMap))
.thenReturn(appsResponse);
App app = new App();
appResponse.setApp(app);
app.setId("/service1");
app.setTasks(IntStream.of(1,2)
.mapToObj(index -> {
Task task = new Task();
task.setHost("host" + index);
task.setPorts(IntStream.of(9090, 9091)
.boxed()
.collect(Collectors.toList()));
task.setHealthCheckResults(Collections.emptyList());
return task;
}).collect(Collectors.toList())
);
Task withNullHealthChecks = new Task();
withNullHealthChecks.setHost("host3");
withNullHealthChecks.setPorts(IntStream.of(9090, 9091)
.boxed()
.collect(Collectors.toList()));
app.getTasks().add(withNullHealthChecks);
List<App> apps = new ArrayList<>();
apps.add(app);
appsResponse.setApps(apps);
}
示例6: setup
import mesosphere.marathon.client.model.v2.Task; //导入依赖的package包/类
@Before
public void setup() throws MarathonException {
serverList = new MarathonServerList(
marathonClient,
new MarathonDiscoveryProperties()
);
IClientConfig config = mock(IClientConfig.class);
when(config.getClientName()).thenReturn("service1");
Map<String, Object> properties = new HashMap<>();
properties.put("ZonePattern",".+\\.(.+)");
when(config.getProperties()).thenReturn(properties);
serverList.initWithNiwsConfig(config);
GetAppResponse appResponse = new GetAppResponse();
when(marathonClient.getApp("/service1"))
.thenReturn(appResponse);
GetAppsResponse appsResponse = new GetAppsResponse();
when(marathonClient.getApps())
.thenReturn(appsResponse);
App app = new App();
appResponse.setApp(app);
app.setId("/service1");
app.setTasks(IntStream.of(1,2)
.mapToObj(index -> {
Task task = new Task();
task.setHost("host" + index + ".dc1");
task.setPorts(IntStream.of(9090, 9091)
.boxed()
.collect(Collectors.toList()));
task.setHealthCheckResults(Collections.emptyList());
return task;
}).collect(Collectors.toList())
);
Task withNullHealthChecks = new Task();
withNullHealthChecks.setHost("host1.dc2");
withNullHealthChecks.setPorts(IntStream.of(9090, 9091)
.boxed()
.collect(Collectors.toList()));
app.getTasks().add(withNullHealthChecks);
List<App> apps = new ArrayList<>();
apps.add(app);
appsResponse.setApps(apps);
}
示例7: setup
import mesosphere.marathon.client.model.v2.Task; //导入依赖的package包/类
@Before
public void setup() throws MarathonException {
serverList = new MarathonServerList(
marathonClient,
new MarathonDiscoveryProperties()
);
IClientConfig config = mock(IClientConfig.class);
when(config.getClientName()).thenReturn("service1");
Map<String, Object> properties = new HashMap<>();
properties.put("IgnoreServiceId",true);
when(config.getProperties()).thenReturn(properties);
serverList.initWithNiwsConfig(config);
GetAppResponse appResponse = new GetAppResponse();
when(marathonClient.getApp("/service1"))
.thenReturn(appResponse);
GetAppsResponse appsResponse = new GetAppsResponse();
Map<String,String> queryMap = new HashMap<>();
when(marathonClient.getApps(queryMap))
.thenReturn(appsResponse);
App app = new App();
appResponse.setApp(app);
app.setId("/service1");
app.setTasks(IntStream.of(1,2)
.mapToObj(index -> {
Task task = new Task();
task.setHost("host" + index);
task.setPorts(IntStream.of(9090, 9091)
.boxed()
.collect(Collectors.toList()));
task.setHealthCheckResults(Collections.emptyList());
return task;
}).collect(Collectors.toList())
);
Task withNullHealthChecks = new Task();
withNullHealthChecks.setHost("host3");
withNullHealthChecks.setPorts(IntStream.of(9090, 9091)
.boxed()
.collect(Collectors.toList()));
app.getTasks().add(withNullHealthChecks);
List<App> apps = new ArrayList<>();
apps.add(app);
appsResponse.setApps(apps);
}
开发者ID:aatarasoff,项目名称:spring-cloud-marathon,代码行数:56,代码来源:MarathonServerListIgnoreServiceIdTests.java
示例8: test_list_of_instances
import mesosphere.marathon.client.model.v2.Task; //导入依赖的package包/类
@Test
public void test_list_of_instances() throws MarathonException {
GetAppResponse appResponse = new GetAppResponse();
when(marathonClient.getApp("/app1"))
.thenReturn(appResponse);
appResponse.setApp(new App());
appResponse.getApp().setTasks(new ArrayList<>());
Task taskWithNoHealthChecks = new Task();
taskWithNoHealthChecks.setAppId("/app1");
taskWithNoHealthChecks.setHost("host1");
taskWithNoHealthChecks.setPorts(
IntStream.of(9090)
.boxed()
.collect(Collectors.toList())
);
appResponse.getApp().getTasks().add(taskWithNoHealthChecks);
Task taskWithAllGoodHealthChecks = new Task();
taskWithAllGoodHealthChecks.setAppId("/app1");
taskWithAllGoodHealthChecks.setHost("host2");
taskWithAllGoodHealthChecks.setPorts(
IntStream.of(9090, 9091)
.boxed()
.collect(Collectors.toList())
);
HealthCheckResults healthCheckResult = new HealthCheckResults();
healthCheckResult.setAlive(true);
HealthCheckResults badHealthCheckResult = new HealthCheckResults();
badHealthCheckResult.setAlive(false);
List<HealthCheckResults> healthCheckResults = new ArrayList<>();
healthCheckResults.add(healthCheckResult);
healthCheckResults.add(healthCheckResult);
taskWithAllGoodHealthChecks.setHealthCheckResults(healthCheckResults);
appResponse.getApp().getTasks().add(taskWithAllGoodHealthChecks);
Task taskWithOneBadHealthCheck = new Task();
taskWithOneBadHealthCheck.setAppId("/app1");
taskWithOneBadHealthCheck.setHost("host3");
taskWithOneBadHealthCheck.setPorts(
IntStream.of(9090)
.boxed()
.collect(Collectors.toList())
);
List<HealthCheckResults> withBadHealthCheckResults = new ArrayList<>();
withBadHealthCheckResults.add(healthCheckResult);
withBadHealthCheckResults.add(badHealthCheckResult);
taskWithOneBadHealthCheck.setHealthCheckResults(withBadHealthCheckResults);
appResponse.getApp().getTasks().add(taskWithOneBadHealthCheck);
ReflectionAssert.assertReflectionEquals(
"should be two tasks",
IntStream.of(1,2)
.mapToObj(index ->
new DefaultServiceInstance(
"app1",
"host" + index,
9090,
false
)
).collect(Collectors.toList()),
discoveryClient.getInstances("app1"),
ReflectionComparatorMode.LENIENT_ORDER
);
}
示例9: MarathonAppInstanceStatus
import mesosphere.marathon.client.model.v2.Task; //导入依赖的package包/类
private MarathonAppInstanceStatus(App app, Task task) {
this.app = app;
this.task = task;
}
示例10: up
import mesosphere.marathon.client.model.v2.Task; //导入依赖的package包/类
/**
* Construct a status from a running app task.
*/
static MarathonAppInstanceStatus up(App app, Task task) {
return new MarathonAppInstanceStatus(app, task);
}