Search in sources :

Example 1 with StatusChangeEvent

use of com.netflix.discovery.StatusChangeEvent in project eureka by Netflix.

the class ApplicationInfoManager method setInstanceStatus.

/**
     * Set the status of this instance. Application can use this to indicate
     * whether it is ready to receive traffic. Setting the status here also notifies all registered listeners
     * of a status change event.
     *
     * @param status Status of the instance
     */
public synchronized void setInstanceStatus(InstanceStatus status) {
    InstanceStatus next = instanceStatusMapper.map(status);
    if (next == null) {
        return;
    }
    InstanceStatus prev = instanceInfo.setStatus(next);
    if (prev != null) {
        for (StatusChangeListener listener : listeners.values()) {
            try {
                listener.notify(new StatusChangeEvent(prev, next));
            } catch (Exception e) {
                logger.warn("failed to notify listener: {}", listener.getId(), e);
            }
        }
    }
}
Also used : StatusChangeEvent(com.netflix.discovery.StatusChangeEvent) InstanceStatus(com.netflix.appinfo.InstanceInfo.InstanceStatus)

Aggregations

InstanceStatus (com.netflix.appinfo.InstanceInfo.InstanceStatus)1 StatusChangeEvent (com.netflix.discovery.StatusChangeEvent)1