Java Code Examples for org.springframework.cloud.deployer.spi.core.RuntimeEnvironmentInfo

The following examples show how to use org.springframework.cloud.deployer.spi.core.RuntimeEnvironmentInfo. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
@Test
public void testCreatingRuntimeEnvironmentInfo() {
	RuntimeEnvironmentInfo rei = new RuntimeEnvironmentInfo.Builder()
			.spiClass(AppDeployer.class)
			.implementationName("TestDeployer")
			.implementationVersion("1.0.0")
			.platformClientVersion("1.2.0")
			.platformHostVersion("1.1.0")
			.platformType("Test")
			.platformApiVersion("1")
			.addPlatformSpecificInfo("foo", "bar")
			.build();
	assertThat(rei.getSpiVersion(), is(RuntimeVersionUtils.getVersion(AppDeployer.class)));
	assertThat(rei.getImplementationName(), is("TestDeployer"));
	assertThat(rei.getImplementationVersion(), is("1.0.0"));
	assertThat(rei.getPlatformType(), is("Test"));
	assertThat(rei.getPlatformApiVersion(), is("1"));
	assertThat(rei.getPlatformClientVersion(), is("1.2.0"));
	assertThat(rei.getPlatformHostVersion(), is("1.1.0"));
	assertThat(rei.getJavaVersion(), is(System.getProperty("java.version")));
	assertThat(rei.getSpringVersion(), is(SpringVersion.getVersion()));
	assertThat(rei.getSpringBootVersion(), is(RuntimeVersionUtils.getSpringBootVersion()));
	assertThat(rei.getPlatformSpecificInfo().get("foo"), is("bar"));
}
 
Example 2
@Override
public RuntimeEnvironmentInfo environmentInfo() {
	String apiVersion = "v1";
	String hostVersion = "unknown";
	String frameworkId = "unknown";
	String leader = "unknown";
	try {
		GetServerInfoResponse serverInfo = marathon.getServerInfo();
		hostVersion = serverInfo.getVersion();
		frameworkId = serverInfo.getFrameworkId();
		leader = serverInfo.getLeader();
	} catch (MarathonException ignore) {}
	return new RuntimeEnvironmentInfo.Builder()
			.spiClass(AppDeployer.class)
			.implementationName(this.getClass().getSimpleName())
			.implementationVersion(RuntimeVersionUtils.getVersion(this.getClass()))
			.platformType("Mesos")
			.platformApiVersion(apiVersion)
			.platformClientVersion(RuntimeVersionUtils.getVersion(marathon.getClass()))
			.platformHostVersion(hostVersion)
			.addPlatformSpecificInfo("leader", leader)
			.addPlatformSpecificInfo("frameworkId", frameworkId)
			.build();
}
 
Example 3
private RuntimeEnvironmentInfo runtimeEnvironmentInfo(Class spiClass, Class implementationClass) {
	CloudFoundryClient client = connectionConfiguration.cloudFoundryClient(
		connectionConfiguration.connectionContext(connectionConfiguration.cloudFoundryConnectionProperties()),
		connectionConfiguration.tokenProvider(connectionConfiguration.cloudFoundryConnectionProperties()));
	Version version = connectionConfiguration.version(client);

	return new CloudFoundryPlatformSpecificInfo(new RuntimeEnvironmentInfo.Builder())
		.apiEndpoint(connectionConfiguration.cloudFoundryConnectionProperties().getUrl().toString())
		.org(connectionConfiguration.cloudFoundryConnectionProperties().getOrg())
		.space(connectionConfiguration.cloudFoundryConnectionProperties().getSpace())
		.builder()
			.implementationName(implementationClass.getSimpleName())
			.spiClass(spiClass)
			.implementationVersion(RuntimeVersionUtils.getVersion(CloudFoundryAppDeployer.class))
			.platformType("Cloud Foundry")
			.platformClientVersion(RuntimeVersionUtils.getVersion(client.getClass()))
			.platformApiVersion(version.toString())
			.platformHostVersion("unknown")
			.build();
}
 
Example 4
private RuntimeEnvironmentInfo runtimeEnvironmentInfo(CloudFoundryClient cloudFoundryClient, String account) {
	return new CloudFoundryPlatformSpecificInfo(new RuntimeEnvironmentInfo.Builder())
			.apiEndpoint(connectionProperties(account).getUrl().toString())
			.org(connectionProperties(account).getOrg())
			.space(connectionProperties(account).getSpace())
			.builder()
				.implementationName(CloudFoundryAppDeployer.class.getSimpleName())
				.spiClass(AppDeployer.class)
				.implementationVersion(
					RuntimeVersionUtils.getVersion(CloudFoundryAppDeployer.class))
				.platformType("Cloud Foundry")
				.platformClientVersion(
					RuntimeVersionUtils.getVersion(cloudFoundryClient.getClass()))
				.platformApiVersion(version(cloudFoundryClient, account).toString()).platformHostVersion("unknown")
			.build();
}
 
Example 5
@Override
public RuntimeEnvironmentInfo environmentInfo() {
	AboutResource skipperInfo = skipperClient.info();
	Collection<Deployer> deployers = skipperClient.listDeployers();
	RuntimeEnvironmentInfo.Builder builder = new RuntimeEnvironmentInfo.Builder()
			.implementationName(skipperInfo.getVersionInfo().getServer().getName())
			.implementationVersion(skipperInfo.getVersionInfo().getServer().getVersion())
			.platformApiVersion("")
			.platformClientVersion("")
			.platformHostVersion("")
			.platformType("Skipper Managed")
			.spiClass(SkipperClient.class);
	for (Deployer d : deployers) {
		builder.addPlatformSpecificInfo(d.getName(), d.getType());
	}
	return builder.build();
}
 
Example 6
Source Project: spring-cloud-dataflow   Source File: TestDependencies.java    License: Apache License 2.0 6 votes vote down vote up
@Bean
public AboutController aboutController(VersionInfoProperties versionInfoProperties,
		FeaturesProperties featuresProperties, StreamDeployer streamDeployer, GrafanaInfoProperties grafanaInfoProperties) {

	Launcher launcher = mock(Launcher.class);
	TaskLauncher taskLauncher = mock(TaskLauncher.class);
	LauncherRepository launcherRepository = mock(LauncherRepository.class);

	RuntimeEnvironmentInfo taskDeployerEnvInfo = new RuntimeEnvironmentInfo.Builder()
			.implementationName("testTaskDepImplementationName")
			.implementationVersion("testTaskDepImplementationVersion")
			.platformType("testTaskDepPlatformType")
			.platformApiVersion("testTaskDepPlatformApiVersion")
			.platformClientVersion("testTaskDepPlatformClientVersion")
			.spiClass(Class.class)
			.platformHostVersion("testTaskDepPlatformHostVersion").build();

	when(taskLauncher.environmentInfo()).thenReturn(taskDeployerEnvInfo);
	when(launcher.getTaskLauncher()).thenReturn(taskLauncher);
	when(launcherRepository.findByName("default")).thenReturn(launcher);

	return new AboutController(streamDeployer, launcherRepository,
			featuresProperties, versionInfoProperties,
			mock(SecurityStateBean.class), grafanaInfoProperties);
}
 
Example 7
/**
 * Create the RuntimeEnvironmentInfo.
 *
 * @param spiClass the SPI interface class
 * @param implementationClass the SPI implementation class
 * @return the Kubernetes runtime environment info
 */
protected RuntimeEnvironmentInfo createRuntimeEnvironmentInfo(Class spiClass, Class implementationClass) {
	return new RuntimeEnvironmentInfo.Builder()
			.spiClass(spiClass)
			.implementationName(implementationClass.getSimpleName())
			.implementationVersion(RuntimeVersionUtils.getVersion(implementationClass))
			.platformType("Kubernetes")
			.platformApiVersion(client.getApiVersion())
			.platformClientVersion(RuntimeVersionUtils.getVersion(client.getClass()))
			.platformHostVersion("unknown")
			.addPlatformSpecificInfo("master-url", String.valueOf(client.getMasterUrl()))
			.addPlatformSpecificInfo("namespace", client.getNamespace())
			.build();
}
 
Example 8
@Override
public RuntimeEnvironmentInfo environmentInfo() {
	return new RuntimeEnvironmentInfo.Builder()
			.spiClass(AppDeployer.class)
			.implementationName(getClass().getSimpleName())
			.implementationVersion(RuntimeVersionUtils.getVersion(this.getClass()))
			.platformType("Yarn")
			.platformApiVersion(System.getProperty("os.name") + " " + System.getProperty("os.version"))
			.platformClientVersion(System.getProperty("os.version"))
			.platformHostVersion(System.getProperty("os.version"))
			.build();
}
 
Example 9
@Override
public RuntimeEnvironmentInfo environmentInfo() {
	return new RuntimeEnvironmentInfo.Builder()
			.spiClass(TaskLauncher.class)
			.implementationName(getClass().getSimpleName())
			.implementationVersion(RuntimeVersionUtils.getVersion(this.getClass()))
			.platformType("Yarn")
			.platformApiVersion(System.getProperty("os.name") + " " + System.getProperty("os.version"))
			.platformClientVersion(System.getProperty("os.version"))
			.platformHostVersion(System.getProperty("os.version"))
			.build();
}
 
Example 10
/**
 * Tests support for DeployerEnvironmentInfo is implemented.
 */
@Test
public void testEnvironmentInfo() {
	RuntimeEnvironmentInfo info = appDeployer().environmentInfo();
	assertNotNull(info.getImplementationVersion());
	assertNotNull(info.getPlatformType());
	assertNotNull(info.getPlatformClientVersion());
	assertNotNull(info.getPlatformHostVersion());
}
 
Example 11
/**
 * Tests support for DeployerEnvironmentInfo is implemented.
 */
@Test
public void testEnvironmentInfo() {
	RuntimeEnvironmentInfo info = taskLauncher().environmentInfo();
	assertNotNull(info.getImplementationVersion());
	assertNotNull(info.getPlatformType());
	assertNotNull(info.getPlatformClientVersion());
	assertNotNull(info.getPlatformHostVersion());
}
 
Example 12
@Override
public RuntimeEnvironmentInfo environmentInfo() {
	String apiVersion = "v1";
	String hostVersion = "unknown";
	return new RuntimeEnvironmentInfo.Builder()
			.spiClass(AppDeployer.class)
			.implementationName(this.getClass().getSimpleName())
			.implementationVersion(RuntimeVersionUtils.getVersion(this.getClass()))
			.platformType("Mesos")
			.platformApiVersion(apiVersion)
			.platformClientVersion(RuntimeVersionUtils.getVersion(chronos.getClass()))
			.platformHostVersion(hostVersion)
			.build();
}
 
Example 13
public RuntimeEnvironmentInfo.Builder builder() {
	Assert.hasText(apiEndpoint, "'apiEndpoint' must contain text");
	Assert.hasText(org, "'org' must contain text");
	Assert.hasText(space, "'space' must contain text");
	runtimeEnvironmentInfo.addPlatformSpecificInfo(API_ENDPOINT, apiEndpoint);
	runtimeEnvironmentInfo.addPlatformSpecificInfo(ORG, org);
	runtimeEnvironmentInfo.addPlatformSpecificInfo(SPACE, space);
	return runtimeEnvironmentInfo;
}
 
Example 14
public CloudFoundryTaskLauncher(CloudFoundryClient client,
											CloudFoundryDeploymentProperties deploymentProperties,
											CloudFoundryOperations operations,
										    RuntimeEnvironmentInfo runtimeEnvironmentInfo) {
	super(client, deploymentProperties, runtimeEnvironmentInfo);
	this.client = client;
	this.deploymentProperties = deploymentProperties;
	this.operations = operations;
}
 
Example 15
public CloudFoundryAppDeployer(AppNameGenerator applicationNameGenerator,
	CloudFoundryDeploymentProperties deploymentProperties,
	CloudFoundryOperations operations,
	RuntimeEnvironmentInfo runtimeEnvironmentInfo
) {
	super(deploymentProperties, runtimeEnvironmentInfo);
	this.operations = operations;
	this.applicationNameGenerator = applicationNameGenerator;
}
 
Example 16
AbstractCloudFoundryTaskLauncher(CloudFoundryClient client,
		CloudFoundryDeploymentProperties deploymentProperties,
		RuntimeEnvironmentInfo runtimeEnvironmentInfo) {
	super(deploymentProperties, runtimeEnvironmentInfo);
	this.client = client;
	organizationId = organizationId();
	spaceId = spaceId();
}
 
Example 17
/**
 * Create the RuntimeEnvironmentInfo.
 *
 * @return the local runtime environment info
 */
protected RuntimeEnvironmentInfo createRuntimeEnvironmentInfo(Class<?> spiClass, Class<?> implementationClass) {
	return new RuntimeEnvironmentInfo.Builder().spiClass(spiClass)
			.implementationName(implementationClass.getSimpleName())
			.implementationVersion(RuntimeVersionUtils.getVersion(implementationClass)).platformType("Local")
			.platformApiVersion(System.getProperty("os.name") + " " + System.getProperty("os.version"))
			.platformClientVersion(System.getProperty("os.version"))
			.platformHostVersion(System.getProperty("os.version")).build();
}
 
Example 18
@Override
public RuntimeEnvironmentInfo environmentInfo() {
	return super.createRuntimeEnvironmentInfo(AppDeployer.class, this.getClass());
}
 
Example 19
@Override
public RuntimeEnvironmentInfo environmentInfo() {
	return super.createRuntimeEnvironmentInfo(TaskLauncher.class, this.getClass());
}
 
Example 20
@Override
public RuntimeEnvironmentInfo environmentInfo() {
	return wrapped.environmentInfo();
}
 
Example 21
@Override
public RuntimeEnvironmentInfo environmentInfo() {
	return wrapped.environmentInfo();
}
 
Example 22
AbstractCloudFoundryDeployer(CloudFoundryDeploymentProperties deploymentProperties, RuntimeEnvironmentInfo runtimeEnvironmentInfo) {
	this.deploymentProperties = deploymentProperties;
	this.runtimeEnvironmentInfo = runtimeEnvironmentInfo;
}
 
Example 23
public RuntimeEnvironmentInfo environmentInfo() {
	return runtimeEnvironmentInfo;
}
 
Example 24
public UnsupportedVersionTaskLauncher(Version actualVersion, RuntimeEnvironmentInfo info) {
	this.actualVersion = actualVersion;
	this.info = info;
}
 
Example 25
@Override
public RuntimeEnvironmentInfo environmentInfo() {
	return info;
}
 
Example 26
public CloudFoundryPlatformSpecificInfo(RuntimeEnvironmentInfo.Builder runtimeEnvironmentInfo) {
	this.runtimeEnvironmentInfo = runtimeEnvironmentInfo;
}
 
Example 27
@Test
public void testOrgSpaceCachingRetries() {
	CloudFoundryClient client = mock(CloudFoundryClient.class);
	AtomicBoolean spaceError = new AtomicBoolean(true);
	AtomicBoolean orgError = new AtomicBoolean(true);

	Spaces spaces = mock(Spaces.class);
	given(client.spaces()).willReturn(spaces);
	given(spaces.list(any())).willReturn(listSpacesResponse(spaceError));

	Organizations organizations = mock(Organizations.class);
	given(client.organizations()).willReturn(organizations);
	given(organizations.list(any())).willReturn(listOrganizationsResponse(orgError));

	Tasks tasks = mock(Tasks.class);
	given(client.tasks()).willReturn(tasks);
	given(tasks.list(any())).willReturn(runningTasksResponse());

	CloudFoundryDeploymentProperties deploymentProperties = new CloudFoundryDeploymentProperties();
	CloudFoundryOperations operations = mock(CloudFoundryOperations.class);
	RuntimeEnvironmentInfo runtimeEnvironmentInfo = mock(RuntimeEnvironmentInfo.class);
	Map<String, String> orgAndSpace = new HashMap<>();
	orgAndSpace.put(CloudFoundryPlatformSpecificInfo.ORG, "this-org");
	orgAndSpace.put(CloudFoundryPlatformSpecificInfo.SPACE, "this-space");
	given(runtimeEnvironmentInfo.getPlatformSpecificInfo()).willReturn(orgAndSpace);

	CloudFoundryTaskLauncher launcher = new CloudFoundryTaskLauncher(client, deploymentProperties, operations, runtimeEnvironmentInfo);

	Throwable thrown1 = catchThrowable(() -> {
		launcher.getRunningTaskExecutionCount();
	});
	assertThat(thrown1).isInstanceOf(RuntimeException.class).hasNoCause();

	// space should still error
	orgError.set(false);
	Throwable thrown2 = catchThrowable(() -> {
		launcher.getRunningTaskExecutionCount();
	});
	assertThat(thrown2).isInstanceOf(RuntimeException.class).hasNoCause();

	// cache should now be getting cleared as space doesn't error
	spaceError.set(false);
	Throwable thrown3 = catchThrowable(() -> {
		launcher.getRunningTaskExecutionCount();
	});
	assertThat(thrown3).doesNotThrowAnyException();
	assertThat(launcher.getRunningTaskExecutionCount()).isEqualTo(1);
}
 
Example 28
@Override
public RuntimeEnvironmentInfo environmentInfo() {
	return super.createRuntimeEnvironmentInfo(TaskLauncher.class, this.getClass());
}
 
Example 29
@Override
public RuntimeEnvironmentInfo environmentInfo() {
	return super.createRuntimeEnvironmentInfo(AppDeployer.class, this.getClass());
}
 
Example 30
@Override
public RuntimeEnvironmentInfo environmentInfo() {
	return null;
}