當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。