use of com.netflix.appinfo.InstanceInfo.InstanceStatus in project eureka by Netflix.
the class InstanceResource method deleteStatusUpdate.
/**
* Removes status override for an instance, set with
* {@link #statusUpdate(String, String, String)}.
*
* @param isReplication
* a header parameter containing information whether this is
* replicated from other nodes.
* @param lastDirtyTimestamp
* last timestamp when this instance information was updated.
* @return response indicating whether the operation was a success or
* failure.
*/
@DELETE
@Path("status")
public Response deleteStatusUpdate(@HeaderParam(PeerEurekaNode.HEADER_REPLICATION) String isReplication, @QueryParam("value") String newStatusValue, @QueryParam("lastDirtyTimestamp") String lastDirtyTimestamp) {
try {
if (registry.getInstanceByAppAndId(app.getName(), id) == null) {
logger.warn("Instance not found: {}/{}", app.getName(), id);
return Response.status(Status.NOT_FOUND).build();
}
InstanceStatus newStatus = newStatusValue == null ? InstanceStatus.UNKNOWN : InstanceStatus.valueOf(newStatusValue);
boolean isSuccess = registry.deleteStatusOverride(app.getName(), id, newStatus, lastDirtyTimestamp, "true".equals(isReplication));
if (isSuccess) {
logger.info("Status override removed: " + app.getName() + " - " + id);
return Response.ok().build();
} else {
logger.warn("Unable to remove status override: " + app.getName() + " - " + id);
return Response.serverError().build();
}
} catch (Throwable e) {
logger.error("Error removing instance's {} status override", id);
return Response.serverError().build();
}
}
use of com.netflix.appinfo.InstanceInfo.InstanceStatus in project ribbon by Netflix.
the class NIWSDiscoveryPing method isAlive.
public boolean isAlive(Server server) {
boolean isAlive = true;
if (server != null && server instanceof DiscoveryEnabledServer) {
DiscoveryEnabledServer dServer = (DiscoveryEnabledServer) server;
InstanceInfo instanceInfo = dServer.getInstanceInfo();
if (instanceInfo != null) {
InstanceStatus status = instanceInfo.getStatus();
if (status != null) {
isAlive = status.equals(InstanceStatus.UP);
}
}
}
return isAlive;
}
use of com.netflix.appinfo.InstanceInfo.InstanceStatus in project eureka by Netflix.
the class AbstractInstanceRegistry method storeOverriddenStatusIfRequired.
/**
* Stores overridden status if it is not already there. This happens during
* a reconciliation process during renewal requests.
*
* @param appName the application name of the instance.
* @param id the unique identifier of the instance.
* @param overriddenStatus overridden status if any.
*/
@Override
public void storeOverriddenStatusIfRequired(String appName, String id, InstanceStatus overriddenStatus) {
InstanceStatus instanceStatus = overriddenInstanceStatusMap.get(id);
if ((instanceStatus == null) || (!overriddenStatus.equals(instanceStatus))) {
// We might not have the overridden status if the server got
// restarted -this will help us maintain the overridden state
// from the replica
logger.info("Adding overridden status for instance id {} and the value is {}", id, overriddenStatus.name());
overriddenInstanceStatusMap.put(id, overriddenStatus);
InstanceInfo instanceInfo = this.getInstanceByAppAndId(appName, id, false);
instanceInfo.setOverriddenStatus(overriddenStatus);
logger.info("Set the overridden status for instance (appname:{}, id:{}} and the value is {} ", appName, id, overriddenStatus.name());
}
}
Aggregations