以编程方式从Eureka Server中删除已注册的实例

时间:2017-01-25 09:40:27

标签: java spring spring-cloud netflix-eureka spring-cloud-netflix

有没有办法在不使用REST操作的情况下从Eureka Server中删除已注册的实例?哪个数据结构包含所有应用程序?

(很明显,我想删除他们在Eureka服务器中编写代码)。

谢谢,

纳米

1 个答案:

答案 0 :(得分:2)

您所使用的功能可通过InstanceRegistry获取,PeerAwareInstanceRegistryImpl本身只是Netflix Eureka课程的扩展(AbstractInstanceRegistryhere)。

具体来说,AbstractInstanceRegistry#cancel(String,String,boolean)方法应该从注册表中删除应用程序。

此方法的Javadoc声明:

/**
 * Cancels the registration of an instance.
 *
 * <p>
 * This is normally invoked by a client when it shuts down informing the
 * server to remove the instance from traffic.
 * </p>
 *
 * @param appName the application name of the application.
 * @param id the unique identifier of the instance.
 * @param isReplication true if this is a replication event from other nodes, false
 *                      otherwise.
 * @return true if the instance was removed from the {@link AbstractInstanceRegistry} successfully, false otherwise.
 */

这是您从Eureka服务器本身实现这一目标的方法。

相关问题