本文整理汇总了Java中mesosphere.marathon.client.model.v2.App.setId方法的典型用法代码示例。如果您正苦于以下问题:Java App.setId方法的具体用法?Java App.setId怎么用?Java App.setId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mesosphere.marathon.client.model.v2.App
的用法示例。
在下文中一共展示了App.setId方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createZookeeperApp
import mesosphere.marathon.client.model.v2.App; //导入方法依赖的package包/类
private App createZookeeperApp() {
App app = new App();
app.setId(this.id);
app.setCpus(cpu);
app.setMem(mem);
app.setInstances(instances);
app.setContainer(new Container());
app.getContainer().setType(CONTAINER_TYPE);
app.getContainer().setDocker(new Docker());
app.getContainer().getDocker().setImage(ZK_IMAGE);
List<HealthCheck> healthCheckList = new ArrayList<>();
final HealthCheck hc = setHealthCheck(300, "TCP", false, 60, 20, 0, ZKSERVICE_ZKPORT);
healthCheckList.add(hc);
app.setHealthChecks(healthCheckList);
return app;
}
示例2: generateExternalTaskRepresentation
import mesosphere.marathon.client.model.v2.App; //导入方法依赖的package包/类
@Override
protected App generateExternalTaskRepresentation(MarathonApp marathonTask) {
App app = new App();
String id = marathonTask.getId();
if (!APP_NAME_VALIDATOR.matcher(id).matches()) {
throw new IllegalArgumentException(String.format(
"Illegal name for TOSCA node <%s>: "
+ "name for nodes of type %s must fully match regular expression %s",
id, marathonTask.getToscaNodeName(), APP_NAME_VALIDATOR.pattern()));
}
app.setId(id);
app.setCmd(marathonTask.getCmd());
app.setConstraints(marathonTask.getConstraints());
app.setCpus(marathonTask.getCpus());
app.setMem(marathonTask.getMemSize());
app.setUris(marathonTask.getUris());
app.setLabels(marathonTask.getLabels());
app.setEnv(new HashMap<>(marathonTask.getEnv()));
app.setInstances(marathonTask.getInstances());
marathonTask
.getContainer()
.ifPresent(mesosContainer -> app.setContainer(generateContainer(mesosContainer)));
return app;
}
示例3: marathonClient
import mesosphere.marathon.client.model.v2.App; //导入方法依赖的package包/类
@Bean
public Marathon marathonClient(MarathonProperties properties) throws MarathonException {
Marathon client = mock(Marathon.class);
when(client.getServerInfo()).thenReturn(new GetServerInfoResponse());
GetAppsResponse appsResponse = new GetAppsResponse();
App app = new App();
app.setId("test-app");
appsResponse.setApps(Collections.singletonList(app));
when(client.getApps()).thenReturn(appsResponse);
return client;
}
示例4: createPravegaControllerApp
import mesosphere.marathon.client.model.v2.App; //导入方法依赖的package包/类
/**
* To configure the controller app.
*
* @return App instance of marathon app
*/
private App createPravegaControllerApp() {
App app = new App();
app.setId(this.id);
app.setCpus(cpu);
app.setMem(mem);
app.setInstances(instances);
app.setConstraints(setConstraint("hostname", "UNIQUE"));
app.setContainer(new Container());
app.getContainer().setType(CONTAINER_TYPE);
app.getContainer().setDocker(new Docker());
app.getContainer().getDocker().setImage(IMAGE_PATH + "/nautilus/pravega:" + PRAVEGA_VERSION);
String zk = zkUri.getHost() + ":" + ZKSERVICE_ZKPORT;
//set port
app.setPortDefinitions(Arrays.asList(createPortDefinition(CONTROLLER_PORT), createPortDefinition(REST_PORT)));
app.setRequirePorts(true);
List<HealthCheck> healthCheckList = new ArrayList<HealthCheck>();
healthCheckList.add(setHealthCheck(300, "TCP", false, 60, 20, 0, CONTROLLER_PORT));
app.setHealthChecks(healthCheckList);
//set env
String controllerSystemProperties = "-Xmx512m" +
setSystemProperty("ZK_URL", zk) +
setSystemProperty("CONTROLLER_RPC_PUBLISHED_HOST", this.id + ".marathon.mesos") +
setSystemProperty("CONTROLLER_RPC_PUBLISHED_PORT", String.valueOf(CONTROLLER_PORT)) +
setSystemProperty("CONTROLLER_SERVER_PORT", String.valueOf(CONTROLLER_PORT)) +
setSystemProperty("REST_SERVER_PORT", String.valueOf(REST_PORT)) +
setSystemProperty("log.level", "DEBUG") +
setSystemProperty("log.dir", "$MESOS_SANDBOX/pravegaLogs") +
setSystemProperty("curator-default-session-timeout", String.valueOf(10 * 1000)) +
setSystemProperty("MAX_LEASE_VALUE", String.valueOf(60 * 1000)) +
setSystemProperty("MAX_SCALE_GRACE_PERIOD", String.valueOf(60 * 1000));
Map<String, Object> map = new HashMap<>();
map.put("PRAVEGA_CONTROLLER_OPTS", controllerSystemProperties);
app.setEnv(map);
app.setArgs(Arrays.asList("controller"));
return app;
}
示例5: createBookieApp
import mesosphere.marathon.client.model.v2.App; //导入方法依赖的package包/类
private App createBookieApp() {
App app = new App();
app.setId(this.id);
app.setCpus(cpu);
app.setMem(mem);
app.setInstances(instances);
app.setConstraints(setConstraint("hostname", "UNIQUE"));
app.setContainer(new Container());
app.getContainer().setType(CONTAINER_TYPE);
app.getContainer().setDocker(new Docker());
app.getContainer().getDocker().setImage(IMAGE_PATH + "/nautilus/bookkeeper:" + PRAVEGA_VERSION);
Collection<Volume> volumeCollection = new ArrayList<>();
volumeCollection.add(createVolume("/bk", "mnt", "RW"));
//TODO: add persistent volume (see issue https://github.com/pravega/pravega/issues/639)
app.getContainer().setVolumes(volumeCollection);
app.setPorts(Arrays.asList(BK_PORT));
app.setRequirePorts(true);
//set env
String zk = zkUri.getHost() + ":" + ZKSERVICE_ZKPORT;
Map<String, Object> map = new HashMap<>();
map.put("ZK_URL", zk);
map.put("ZK", zk);
map.put("bookiePort", String.valueOf(BK_PORT));
map.put("DLOG_EXTRA_OPTS", "-Xms512m");
app.setEnv(map);
//healthchecks
List<HealthCheck> healthCheckList = new ArrayList<>();
healthCheckList.add(setHealthCheck(300, "TCP", false, 60, 20, 0, BK_PORT));
app.setHealthChecks(healthCheckList);
return app;
}
示例6: execute
import mesosphere.marathon.client.model.v2.App; //导入方法依赖的package包/类
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
getLog().info("processing Marathon config file from " + sourceMarathonConfigFile
+ " to " + finalMarathonConfigFile);
App app = readApp(sourceMarathonConfigFile);
if (id != null) {
app.setId(id);
}
app.getContainer().getDocker().setImage(image);
writeApp(app, finalMarathonConfigFile);
}
示例7: createApp
import mesosphere.marathon.client.model.v2.App; //导入方法依赖的package包/类
/**
* @return an app with 64MB memory, 0.5 cpus and 1 instance
*/
protected App createApp()
{
App app = new App();
app.setId("/test");
app.setMem(64.0);
app.setCpus(0.5);
app.setInstances(1);
return app;
}
示例8: setup
import mesosphere.marathon.client.model.v2.App; //导入方法依赖的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);
}
示例9: setup
import mesosphere.marathon.client.model.v2.App; //导入方法依赖的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);
}
示例10: setup
import mesosphere.marathon.client.model.v2.App; //导入方法依赖的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
示例11: test_list_of_servers
import mesosphere.marathon.client.model.v2.App; //导入方法依赖的package包/类
@Test
public void test_list_of_servers() throws MarathonException {
GetAppsResponse appsResponse = new GetAppsResponse();
when(marathonClient.getApps())
.thenReturn(appsResponse);
appsResponse.setApps(new ArrayList<>());
ReflectionAssert.assertReflectionEquals(
"should be no one element",
Collections.emptyList(),
discoveryClient.getServices(),
ReflectionComparatorMode.LENIENT_ORDER
);
//add first application
App app1 = new App();
app1.setId("app1");
appsResponse.getApps().add(app1);
ReflectionAssert.assertReflectionEquals(
"should be only one element",
Collections.singletonList("app1"),
discoveryClient.getServices(),
ReflectionComparatorMode.LENIENT_ORDER
);
//add another application
App app2 = new App();
app2.setId("app2");
appsResponse.getApps().add(app2);
ReflectionAssert.assertReflectionEquals(
"should be two elements",
IntStream.of(1,2)
.mapToObj(index -> "app" + index)
.collect(Collectors.toList()),
discoveryClient.getServices(),
ReflectionComparatorMode.LENIENT_ORDER
);
}
示例12: createAppDeployment
import mesosphere.marathon.client.model.v2.App; //导入方法依赖的package包/类
private void createAppDeployment(AppDeploymentRequest request, String deploymentId, Container container, Integer index) {
App app = new App();
app.setContainer(container);
app.setId(deploymentId);
Map<String, String> env = new HashMap<>();
env.putAll(request.getDefinition().getProperties());
for (String envVar : properties.getEnvironmentVariables()) {
String[] strings = envVar.split("=", 2);
Assert.isTrue(strings.length == 2, "Invalid environment variable declared: " + envVar);
env.put(strings[0], strings[1]);
}
if (index != null) {
env.put(INSTANCE_INDEX_PROPERTY_KEY, index.toString());
}
app.setEnv(env);
Collection<String> uris = deduceUris(request);
app.setUris(uris);
Collection<Constraint> constraints = deduceConstraints(request);
app.setConstraints(constraints.stream().map(Constraint::toStringList).collect(Collectors.toList()));
Double cpus = deduceCpus(request);
Double memory = deduceMemory(request);
Integer instances = index == null ? deduceInstances(request) : 1;
app.setCpus(cpus);
app.setMem(memory);
app.setInstances(instances);
HealthCheck healthCheck = new HealthCheck();
healthCheck.setPath("/health");
healthCheck.setGracePeriodSeconds(300);
app.setHealthChecks(Arrays.asList(healthCheck));
logger.debug("Creating app with definition:\n" + app.toString());
try {
marathon.createApp(app);
}
catch (MarathonException e) {
throw new RuntimeException(e);
}
}
示例13: createPravegaSegmentStoreApp
import mesosphere.marathon.client.model.v2.App; //导入方法依赖的package包/类
private App createPravegaSegmentStoreApp() {
App app = new App();
app.setId(this.id);
app.setCpus(cpu);
app.setMem(mem);
app.setInstances(instances);
//set constraints
app.setConstraints(setConstraint("hostname", "UNIQUE"));
//docker container
app.setContainer(new Container());
app.getContainer().setType(CONTAINER_TYPE);
app.getContainer().setDocker(new Docker());
//set the image and network
app.getContainer().getDocker().setImage(IMAGE_PATH + "/nautilus/pravega:" + PRAVEGA_VERSION);
//set port
app.setPortDefinitions(Arrays.asList(createPortDefinition(SEGMENTSTORE_PORT)));
app.setRequirePorts(true);
//healthchecks
List<HealthCheck> healthCheckList = new ArrayList<HealthCheck>();
healthCheckList.add(setHealthCheck(300, "TCP", false, 60, 20, 0, SEGMENTSTORE_PORT));
app.setHealthChecks(healthCheckList);
//set env
String zk = zkUri.getHost() + ":" + ZKSERVICE_ZKPORT;
//Environment variables to configure SS service.
Map<String, Object> map = new HashMap<>();
map.put("ZK_URL", zk);
map.put("BK_ZK_URL", zk);
map.put("CONTROLLER_URL", conUri.toString());
getCustomEnvVars(map, SEGMENTSTORE_EXTRA_ENV);
//Properties set to override defaults for system tests
String hostSystemProperties = "-Xmx1024m" +
setSystemProperty("autoScale.muteInSeconds", "120") +
setSystemProperty("autoScale.cooldownInSeconds", "120") +
setSystemProperty("autoScale.cacheExpiryInSeconds", "120") +
setSystemProperty("autoScale.cacheCleanUpInSeconds", "120") +
setSystemProperty("log.level", "DEBUG") +
setSystemProperty("log.dir", "$MESOS_SANDBOX/pravegaLogs") +
setSystemProperty("curator-default-session-timeout", String.valueOf(30 * 1000)) +
setSystemProperty("hdfs.replaceDataNodesOnFailure", "false");
map.put("PRAVEGA_SEGMENTSTORE_OPTS", hostSystemProperties);
app.setEnv(map);
app.setArgs(Arrays.asList("segmentstore"));
return app;
}