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


Java Task类代码示例

本文整理汇总了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);
	}
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-deployer-mesos,代码行数:21,代码来源:MarathonAppDeployer.java

示例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();
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-deployer-mesos,代码行数:17,代码来源:MarathonAppDeployer.java

示例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);
    }
}
 
开发者ID:holidaycheck,项目名称:marathon-maven-plugin,代码行数:24,代码来源:AppTasksMojo.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",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

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

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

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

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

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

示例9: MarathonAppInstanceStatus

import mesosphere.marathon.client.model.v2.Task; //导入依赖的package包/类
private MarathonAppInstanceStatus(App app, Task task) {
	this.app = app;
	this.task = task;
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-deployer-mesos,代码行数:5,代码来源:MarathonAppInstanceStatus.java

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


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