org.springframework.cloud.deployer.spi.util.RuntimeVersionUtils Java Examples

The following examples show how to use org.springframework.cloud.deployer.spi.util.RuntimeVersionUtils. 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
Source File: RuntimeEnvironmentInfo.java    From spring-cloud-deployer with Apache License 2.0 6 votes vote down vote up
private RuntimeEnvironmentInfo(Class spiClass, String implementationName, String implementationVersion,
                               String platformType, String platformApiVersion, String platformClientVersion,
                               String platformHostVersion, Map<String, String> platformSpecificInfo) {
	Assert.notNull(spiClass, "spiClass is required");
	Assert.notNull(implementationName, "implementationName is required");
	Assert.notNull(implementationVersion, "implementationVersion is required");
	Assert.notNull(platformType, "platformType is required");
	Assert.notNull(platformApiVersion, "platformApiVersion is required");
	Assert.notNull(platformClientVersion, "platformClientVersion is required");
	Assert.notNull(platformHostVersion, "platformHostVersion is required");
	this.spiVersion = RuntimeVersionUtils.getVersion(spiClass);
	this.implementationName = implementationName;
	this.implementationVersion = implementationVersion;
	this.platformType = platformType;
	this.platformApiVersion = platformApiVersion;
	this.platformClientVersion = platformClientVersion;
	this.platformHostVersion = platformHostVersion;
	this.javaVersion = System.getProperty("java.version");
	this.springVersion = SpringVersion.getVersion();
	this.springBootVersion = RuntimeVersionUtils.getSpringBootVersion();
	this.platformSpecificInfo.putAll(platformSpecificInfo);
}
 
Example #2
Source File: RuntimeEnvironmentInfoBuilderTests.java    From spring-cloud-deployer with Apache License 2.0 6 votes vote down vote up
@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 #3
Source File: MarathonAppDeployer.java    From spring-cloud-deployer-mesos with Apache License 2.0 6 votes vote down vote up
@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 #4
Source File: CloudFoundryDeployerAutoConfiguration.java    From spring-cloud-deployer-cloudfoundry with Apache License 2.0 6 votes vote down vote up
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 #5
Source File: CloudFoundryTaskPlatformFactory.java    From spring-cloud-dataflow with Apache License 2.0 6 votes vote down vote up
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 #6
Source File: AbstractKubernetesDeployer.java    From spring-cloud-deployer-kubernetes with Apache License 2.0 5 votes vote down vote up
/**
 * 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 #7
Source File: YarnAppDeployer.java    From spring-cloud-deployer-yarn with Apache License 2.0 5 votes vote down vote up
@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 #8
Source File: YarnTaskLauncher.java    From spring-cloud-deployer-yarn with Apache License 2.0 5 votes vote down vote up
@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 #9
Source File: ChronosTaskLauncher.java    From spring-cloud-deployer-mesos with Apache License 2.0 5 votes vote down vote up
@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 #10
Source File: AbstractLocalDeployerSupport.java    From spring-cloud-deployer-local with Apache License 2.0 5 votes vote down vote up
/**
 * 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 #11
Source File: UnsupportedVersionTaskLauncher.java    From spring-cloud-deployer-cloudfoundry with Apache License 2.0 4 votes vote down vote up
private UnsupportedOperationException failure() {
	return new UnsupportedOperationException("Cloud Foundry API version " + actualVersion + " is earlier than "
		+ MINIMUM_SUPPORTED_VERSION + " and is incompatible with cf-java-client " +
		RuntimeVersionUtils.getVersion(CloudFoundryOperations.class)+ ". It is thus unsupported");
}