本文整理汇总了Java中mesosphere.marathon.client.model.v2.Task.setPorts方法的典型用法代码示例。如果您正苦于以下问题:Java Task.setPorts方法的具体用法?Java Task.setPorts怎么用?Java Task.setPorts使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mesosphere.marathon.client.model.v2.Task
的用法示例。
在下文中一共展示了Task.setPorts方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: 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);
}
示例3: 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);
}
示例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",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
示例5: 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
);
}