Java Code Examples for com.netflix.appinfo.InstanceInfo.InstanceStatus#name()

The following examples show how to use com.netflix.appinfo.InstanceInfo.InstanceStatus#name() . 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: WebClientEurekaHttpClient.java    From spring-cloud-netflix with Apache License 2.0 6 votes vote down vote up
@Override
public EurekaHttpResponse<InstanceInfo> sendHeartBeat(String appName, String id,
		InstanceInfo info, InstanceStatus overriddenStatus) {
	String urlPath = "apps/" + appName + '/' + id + "?status="
			+ info.getStatus().toString() + "&lastDirtyTimestamp="
			+ info.getLastDirtyTimestamp().toString() + (overriddenStatus != null
					? "&overriddenstatus=" + overriddenStatus.name() : "");

	ClientResponse response = webClient.put().uri(urlPath, InstanceInfo.class)
			.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)
			.header(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE).exchange()
			.block();

	EurekaHttpResponseBuilder<InstanceInfo> builder = anEurekaHttpResponse(
			statusCodeValueOf(response), InstanceInfo.class)
					.headers(headersOf(response));

	InstanceInfo entity = response.toEntity(InstanceInfo.class).block().getBody();

	if (entity != null) {
		builder.entity(entity);
	}

	return builder.build();

}
 
Example 2
Source File: RestTemplateEurekaHttpClient.java    From spring-cloud-netflix with Apache License 2.0 6 votes vote down vote up
@Override
public EurekaHttpResponse<InstanceInfo> sendHeartBeat(String appName, String id,
		InstanceInfo info, InstanceStatus overriddenStatus) {
	String urlPath = serviceUrl + "apps/" + appName + '/' + id + "?status="
			+ info.getStatus().toString() + "&lastDirtyTimestamp="
			+ info.getLastDirtyTimestamp().toString() + (overriddenStatus != null
					? "&overriddenstatus=" + overriddenStatus.name() : "");

	ResponseEntity<InstanceInfo> response = restTemplate.exchange(urlPath,
			HttpMethod.PUT, null, InstanceInfo.class);

	EurekaHttpResponseBuilder<InstanceInfo> eurekaResponseBuilder = anEurekaHttpResponse(
			response.getStatusCodeValue(), InstanceInfo.class)
					.headers(headersOf(response));

	if (response.hasBody()) {
		eurekaResponseBuilder.entity(response.getBody());
	}

	return eurekaResponseBuilder.build();
}
 
Example 3
Source File: WebClientEurekaHttpClient.java    From spring-cloud-netflix with Apache License 2.0 5 votes vote down vote up
@Override
public EurekaHttpResponse<Void> statusUpdate(String appName, String id,
		InstanceStatus newStatus, InstanceInfo info) {
	String urlPath = "apps/" + appName + '/' + id + "/status?value="
			+ newStatus.name() + "&lastDirtyTimestamp="
			+ info.getLastDirtyTimestamp().toString();

	return webClient.put().uri(urlPath, Void.class)
			.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)
			.exchange().map(response -> eurekaHttpResponse(response)).block();
}
 
Example 4
Source File: RestTemplateEurekaHttpClient.java    From spring-cloud-netflix with Apache License 2.0 5 votes vote down vote up
@Override
public EurekaHttpResponse<Void> statusUpdate(String appName, String id,
		InstanceStatus newStatus, InstanceInfo info) {
	String urlPath = serviceUrl + "apps/" + appName + '/' + id + "/status?value="
			+ newStatus.name() + "&lastDirtyTimestamp="
			+ info.getLastDirtyTimestamp().toString();

	ResponseEntity<Void> response = restTemplate.exchange(urlPath, HttpMethod.PUT,
			null, Void.class);

	return anEurekaHttpResponse(response.getStatusCodeValue())
			.headers(headersOf(response)).build();
}