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

The following examples show how to use org.springframework.cloud.deployer.spi.core.RuntimeEnvironmentInfo. 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: 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 #2
Source File: TestDependencies.java    From spring-cloud-dataflow with 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 #3
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 #4
Source File: SkipperStreamDeployer.java    From spring-cloud-dataflow with Apache License 2.0 6 votes vote down vote up
@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 #5
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 #6
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 #7
Source File: CloudFoundryAppDeployer.java    From spring-cloud-deployer-cloudfoundry with Apache License 2.0 5 votes vote down vote up
public CloudFoundryAppDeployer(AppNameGenerator applicationNameGenerator,
	CloudFoundryDeploymentProperties deploymentProperties,
	CloudFoundryOperations operations,
	RuntimeEnvironmentInfo runtimeEnvironmentInfo
) {
	super(deploymentProperties, runtimeEnvironmentInfo);
	this.operations = operations;
	this.applicationNameGenerator = applicationNameGenerator;
}
 
Example #8
Source File: CloudFoundryTaskLauncher.java    From spring-cloud-deployer-cloudfoundry with Apache License 2.0 5 votes vote down vote up
public CloudFoundryTaskLauncher(CloudFoundryClient client,
											CloudFoundryDeploymentProperties deploymentProperties,
											CloudFoundryOperations operations,
										    RuntimeEnvironmentInfo runtimeEnvironmentInfo) {
	super(client, deploymentProperties, runtimeEnvironmentInfo);
	this.client = client;
	this.deploymentProperties = deploymentProperties;
	this.operations = operations;
}
 
Example #9
Source File: CloudFoundryPlatformSpecificInfo.java    From spring-cloud-deployer-cloudfoundry with Apache License 2.0 5 votes vote down vote up
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 #10
Source File: AbstractCloudFoundryTaskLauncher.java    From spring-cloud-deployer-cloudfoundry with Apache License 2.0 5 votes vote down vote up
AbstractCloudFoundryTaskLauncher(CloudFoundryClient client,
		CloudFoundryDeploymentProperties deploymentProperties,
		RuntimeEnvironmentInfo runtimeEnvironmentInfo) {
	super(deploymentProperties, runtimeEnvironmentInfo);
	this.client = client;
	organizationId = organizationId();
	spaceId = spaceId();
}
 
Example #11
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 #12
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 #13
Source File: AbstractTaskLauncherIntegrationTests.java    From spring-cloud-deployer with Apache License 2.0 5 votes vote down vote up
/**
 * 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 #14
Source File: AbstractAppDeployerIntegrationTests.java    From spring-cloud-deployer with Apache License 2.0 5 votes vote down vote up
/**
 * 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 #15
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 #16
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 #17
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 #18
Source File: DefaultTaskExecutionServiceTransactionTests.java    From spring-cloud-dataflow with Apache License 2.0 4 votes vote down vote up
@Override
public RuntimeEnvironmentInfo environmentInfo() {
	return null;
}
 
Example #19
Source File: LocalAppDeployer.java    From spring-cloud-deployer-local with Apache License 2.0 4 votes vote down vote up
@Override
public RuntimeEnvironmentInfo environmentInfo() {
	return super.createRuntimeEnvironmentInfo(AppDeployer.class, this.getClass());
}
 
Example #20
Source File: LocalTaskLauncher.java    From spring-cloud-deployer-local with Apache License 2.0 4 votes vote down vote up
@Override
public RuntimeEnvironmentInfo environmentInfo() {
	return super.createRuntimeEnvironmentInfo(TaskLauncher.class, this.getClass());
}
 
Example #21
Source File: CloudFoundryTaskLauncherCachingTests.java    From spring-cloud-deployer-cloudfoundry with Apache License 2.0 4 votes vote down vote up
@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 #22
Source File: TaskConfiguration.java    From spring-cloud-task with Apache License 2.0 4 votes vote down vote up
@Override
public RuntimeEnvironmentInfo environmentInfo() {
	throw new UnsupportedOperationException("environmentInfo is not supported");
}
 
Example #23
Source File: UnsupportedVersionTaskLauncher.java    From spring-cloud-deployer-cloudfoundry with Apache License 2.0 4 votes vote down vote up
@Override
public RuntimeEnvironmentInfo environmentInfo() {
	return info;
}
 
Example #24
Source File: CloudFoundryPlatformSpecificInfo.java    From spring-cloud-deployer-cloudfoundry with Apache License 2.0 4 votes vote down vote up
public CloudFoundryPlatformSpecificInfo(RuntimeEnvironmentInfo.Builder runtimeEnvironmentInfo) {
	this.runtimeEnvironmentInfo = runtimeEnvironmentInfo;
}
 
Example #25
Source File: KubernetesAppDeployer.java    From spring-cloud-deployer-kubernetes with Apache License 2.0 4 votes vote down vote up
@Override
public RuntimeEnvironmentInfo environmentInfo() {
	return super.createRuntimeEnvironmentInfo(AppDeployer.class, this.getClass());
}
 
Example #26
Source File: UnsupportedVersionTaskLauncher.java    From spring-cloud-deployer-cloudfoundry with Apache License 2.0 4 votes vote down vote up
public UnsupportedVersionTaskLauncher(Version actualVersion, RuntimeEnvironmentInfo info) {
	this.actualVersion = actualVersion;
	this.info = info;
}
 
Example #27
Source File: AbstractCloudFoundryDeployer.java    From spring-cloud-deployer-cloudfoundry with Apache License 2.0 4 votes vote down vote up
public RuntimeEnvironmentInfo environmentInfo() {
	return runtimeEnvironmentInfo;
}
 
Example #28
Source File: AbstractCloudFoundryDeployer.java    From spring-cloud-deployer-cloudfoundry with Apache License 2.0 4 votes vote down vote up
AbstractCloudFoundryDeployer(CloudFoundryDeploymentProperties deploymentProperties, RuntimeEnvironmentInfo runtimeEnvironmentInfo) {
	this.deploymentProperties = deploymentProperties;
	this.runtimeEnvironmentInfo = runtimeEnvironmentInfo;
}
 
Example #29
Source File: AbstractTaskLauncherIntegrationTests.java    From spring-cloud-deployer with Apache License 2.0 4 votes vote down vote up
@Override
public RuntimeEnvironmentInfo environmentInfo() {
	return wrapped.environmentInfo();
}
 
Example #30
Source File: AbstractAppDeployerIntegrationTests.java    From spring-cloud-deployer with Apache License 2.0 4 votes vote down vote up
@Override
public RuntimeEnvironmentInfo environmentInfo() {
	return wrapped.environmentInfo();
}