Search in sources :

Example 11 with InstanceStatus

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();
    }
}
Also used : InstanceStatus(com.netflix.appinfo.InstanceInfo.InstanceStatus) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE)

Example 12 with InstanceStatus

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;
}
Also used : InstanceStatus(com.netflix.appinfo.InstanceInfo.InstanceStatus) InstanceInfo(com.netflix.appinfo.InstanceInfo)

Example 13 with InstanceStatus

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());
    }
}
Also used : InstanceStatus(com.netflix.appinfo.InstanceInfo.InstanceStatus) InstanceInfo(com.netflix.appinfo.InstanceInfo)

Aggregations

InstanceStatus (com.netflix.appinfo.InstanceInfo.InstanceStatus)13 InstanceInfo (com.netflix.appinfo.InstanceInfo)10 Lease (com.netflix.eureka.lease.Lease)4 AtomicLong (java.util.concurrent.atomic.AtomicLong)2 DataCenterInfo (com.netflix.appinfo.DataCenterInfo)1 LeaseInfo (com.netflix.appinfo.LeaseInfo)1 RefreshableInstanceConfig (com.netflix.appinfo.RefreshableInstanceConfig)1 UniqueIdentifier (com.netflix.appinfo.UniqueIdentifier)1 StatusChangeEvent (com.netflix.discovery.StatusChangeEvent)1 Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 DELETE (javax.ws.rs.DELETE)1 Path (javax.ws.rs.Path)1