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


Java EnvironmentVariable类代码示例

本文整理汇总了Java中org.cloudfoundry.receptor.support.EnvironmentVariable的典型用法代码示例。如果您正苦于以下问题:Java EnvironmentVariable类的具体用法?Java EnvironmentVariable怎么用?Java EnvironmentVariable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


EnvironmentVariable类属于org.cloudfoundry.receptor.support包,在下文中一共展示了EnvironmentVariable类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: findEnvVar

import org.cloudfoundry.receptor.support.EnvironmentVariable; //导入依赖的package包/类
protected String findEnvVar(Process process, String varName) {
	String value = null;
	for (EnvironmentVariable env : process.getDesired().getEnv()) {
		if (env.getName().equals(varName)) {
			value = env.getValue();
		}
	}
	return value;
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-lattice,代码行数:10,代码来源:LatticeServiceInfoCreator.java

示例2: deploy

import org.cloudfoundry.receptor.support.EnvironmentVariable; //导入依赖的package包/类
@Override
public ModuleDeploymentId deploy(ModuleDeploymentRequest request) {
	ModuleDeploymentId id =
			ModuleDeploymentId.fromModuleDefinition(request.getDefinition());
	String guid = guid(id);

	TaskCreateRequest task = new TaskCreateRequest();
	task.setLogGuid(guid);
	task.setTaskGuid(guid);
	task.setRootfs(DOCKER_PATH);

	RunAction runAction = task.getAction().get("run");
	runAction.setPath("java");
	runAction.addArg("-Djava.security.egd=file:/dev/./urandom");
	runAction.addArg("-jar");
	runAction.addArg("/module-launcher.jar");

	List<EnvironmentVariable> environmentVariables = new ArrayList<EnvironmentVariable>();
	environmentVariables.add(new EnvironmentVariable(JMX_DEFAULT_DOMAIN_KEY.toUpperCase().replace(".", "_"),
			String.format("%s.%s", request.getDefinition().getGroup(), request.getDefinition().getLabel())));
	Collections.addAll(environmentVariables, task.getEnv());
	environmentVariables.add(new EnvironmentVariable("MODULES", request.getCoordinates().toString()));
	environmentVariables.add(new EnvironmentVariable("SPRING_PROFILES_ACTIVE", "cloud"));
	for (Map.Entry<String, String> entry : request.getDefinition().getParameters().entrySet()) {
		environmentVariables.add(new EnvironmentVariable(entry.getKey(), entry.getValue()));
	}

	task.setEnv(environmentVariables.toArray(new EnvironmentVariable[environmentVariables.size()]));
	task.setMemoryMb(512);

	logger.debug("Desired Task: {}", task);
	for (EnvironmentVariable e : environmentVariables) {
		logger.debug("{}={}", e.getName(), e.getValue());
	}

	receptorClient.createTask(task);
	return id;
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-dataflow-admin-lattice,代码行数:39,代码来源:TaskModuleDeployer.java

示例3: setProcessGuid

import org.cloudfoundry.receptor.support.EnvironmentVariable; //导入依赖的package包/类
public void setProcessGuid(String processGuid) {
	this.processGuid = processGuid;
	if (this.env.length == 1) {
		this.env = Arrays.copyOf(env, 2);
	}
	this.env[1] = new EnvironmentVariable("PROCESS_GUID", processGuid);
}
 
开发者ID:cloudfoundry-attic,项目名称:receptor-client,代码行数:8,代码来源:DesiredLRPCreateRequest.java

示例4: deploy

import org.cloudfoundry.receptor.support.EnvironmentVariable; //导入依赖的package包/类
@Override
public ModuleDeploymentId deploy(ModuleDeploymentRequest request) {
	ModuleDeploymentId id = ModuleDeploymentId.fromModuleDefinition(request.getDefinition());
	String guid = guid(id);

	DesiredLRPCreateRequest lrp = new DesiredLRPCreateRequest();
	lrp.setProcessGuid(guid);
	lrp.setInstances(request.getCount());
	lrp.setRootfs(DOCKER_PATH);
	lrp.runAction().setPath("java");
	lrp.runAction().addArg("-Djava.security.egd=file:/dev/./urandom");
	lrp.runAction().addArg("-jar");
	lrp.runAction().addArg("/module-launcher.jar");

	List<EnvironmentVariable> environmentVariables = new ArrayList<>();
	Collections.addAll(environmentVariables, lrp.getEnv());
	environmentVariables.add(new EnvironmentVariable("MODULES", request.getCoordinates().toString()));
	Map<String, String> rawArgs = new HashMap<>();
	rawArgs.putAll(request.getDefinition().getParameters());
	rawArgs.putAll(request.getDeploymentProperties());
	rawArgs.put(JMX_DEFAULT_DOMAIN_KEY, String.format("%s.%s", request.getDefinition().getGroup(), request.getDefinition().getLabel()));
	Map<String, String> qualifiedArgs = ModuleArgumentQualifier.qualifyArgs(0, rawArgs);
	for (Map.Entry<String, String> entry : qualifiedArgs.entrySet()) {
		environmentVariables.add(new EnvironmentVariable(entry.getKey(), entry.getValue()));
	}
	environmentVariables.add(new EnvironmentVariable("SPRING_CLOUD_LATTICE_RECEPTOR_HOST", receptorHost));

	lrp.setEnv(environmentVariables.toArray(new EnvironmentVariable[environmentVariables.size()]));
	lrp.setMemoryMb(512);
	int serverPort = rawArgs.containsKey(SERVER_PORT_KEY) ?
			Integer.valueOf(rawArgs.get(SERVER_PORT_KEY)) : DEFAULT_SERVER_PORT;
	lrp.setPorts(new int[] {serverPort});
	lrp.addHttpRoute(serverPort, new String[] {String.format("%s.%s", guid, BASE_ADDRESS),
			String.format("%s-%s.%s", guid, serverPort, BASE_ADDRESS) });

	logger.debug("Desired LRP: {}", lrp);
	for (EnvironmentVariable e : environmentVariables) {
		logger.debug("{}={}", e.getName(), e.getValue());
	}

	receptorClient.createDesiredLRP(lrp);
	return id;
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-dataflow-admin-lattice,代码行数:44,代码来源:LrpModuleDeployer.java

示例5: getEnv

import org.cloudfoundry.receptor.support.EnvironmentVariable; //导入依赖的package包/类
public EnvironmentVariable[] getEnv() {
	return env;
}
 
开发者ID:cloudfoundry-attic,项目名称:receptor-client,代码行数:4,代码来源:DesiredLRPCreateRequest.java

示例6: setEnv

import org.cloudfoundry.receptor.support.EnvironmentVariable; //导入依赖的package包/类
public void setEnv(EnvironmentVariable[] env) {
	this.env = env;
}
 
开发者ID:cloudfoundry-attic,项目名称:receptor-client,代码行数:4,代码来源:DesiredLRPCreateRequest.java

示例7: createAndDeleteLRPWithTcpRoute

import org.cloudfoundry.receptor.support.EnvironmentVariable; //导入依赖的package包/类
@Test
public void createAndDeleteLRPWithTcpRoute() throws Exception {
	int desiredLrpCountAtStart = client.getDesiredLRPs().size();
	int actualLrpCountAtStart = client.getActualLRPs().size();
	DesiredLRPCreateRequest request = new DesiredLRPCreateRequest();
	String processGuid = UUID.randomUUID().toString();
	request.setProcessGuid(processGuid);
	request.setRootfs(MYSQL_DOCKER_PATH);
	request.setPorts(new int[]{3306});
	request.setEnv(new EnvironmentVariable[]{new EnvironmentVariable("MYSQL_ROOT_PASSWORD", "somesecret")});
	request.runAction().setPath("/entrypoint.sh");
	request.runAction().addArg("mysqld");
	request.runAction().setUser("root");
	request.addTcpRoute(3306, 3306);
	request.setPriviliged(true);
	request.setMemoryMb(512);
	request.setDomain("yomamma");
	logger.info("creating LRP: " + objectMapper.writeValueAsString(request));
	client.createDesiredLRP(request);

	boolean desiredLrpExists = false;
	for (DesiredLRPResponse desiredLRPResponse : client.getDesiredLRPs()) {
		if(desiredLRPResponse.getProcessGuid().equals(processGuid)) {
			desiredLrpExists = true;
			break;
		}
	}

	assertTrue(desiredLrpExists);

	boolean actualLrpExists = false;
	for (ActualLRPResponse actualLRPResponse : client.getActualLRPs()) {
		if(actualLRPResponse.getProcessGuid().equals(processGuid)) {
			actualLrpExists = true;
			break;
		}
	}

	assertTrue(actualLrpExists);

	client.deleteDesiredLRP(processGuid);
	for (int i = 0; i < 1000; i++) {
		Thread.sleep(100);
		if (0 == client.getActualLRPsByProcessGuid(processGuid).size()) {
			break;
		}
	}
	assertEquals(desiredLrpCountAtStart, client.getDesiredLRPs().size());
	assertEquals(actualLrpCountAtStart, client.getActualLRPs().size());
}
 
开发者ID:cloudfoundry-attic,项目名称:receptor-client,代码行数:51,代码来源:ReceptorClientIntegrationTests.java


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