有没有办法在不使用REST操作的情况下从Eureka Server中删除已注册的实例?哪个数据结构包含所有应用程序?
(很明显,我想删除他们在Eureka服务器中编写代码)。
谢谢,
纳米
答案 0 :(得分:2)
您所使用的功能可通过InstanceRegistry
获取,PeerAwareInstanceRegistryImpl
本身只是Netflix Eureka课程的扩展(AbstractInstanceRegistry
和here)。
具体来说,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服务器本身实现这一目标的方法。