当前位置: 首页>>代码示例>>Java>>正文


Java Task.setHost方法代码示例

本文整理汇总了Java中mesosphere.marathon.client.model.v2.Task.setHost方法的典型用法代码示例。如果您正苦于以下问题:Java Task.setHost方法的具体用法?Java Task.setHost怎么用?Java Task.setHost使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mesosphere.marathon.client.model.v2.Task的用法示例。


在下文中一共展示了Task.setHost方法的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);
}
 
开发者ID:aatarasoff,项目名称:spring-cloud-marathon,代码行数:44,代码来源:MarathonServerListTests.java

示例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);

}
 
开发者ID:aatarasoff,项目名称:spring-cloud-marathon,代码行数:62,代码来源:MarathonServerListByLabelTests.java

示例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);

}
 
开发者ID:aatarasoff,项目名称:spring-cloud-marathon,代码行数:55,代码来源:MarathonServerListFetchZoneTests.java

示例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
    );
}
 
开发者ID:aatarasoff,项目名称:spring-cloud-marathon,代码行数:77,代码来源:MarathonDiscoveryClientTests.java


注:本文中的mesosphere.marathon.client.model.v2.Task.setHost方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。