@Override public void unregister(RegistrationHandle handle) { if (!(handle instanceof ZKRegistrationHandle)) { throw new UnsupportedOperationException( "Unknown handle type: " + handle.getClass().getName()); } // when Drillbit is unregistered, clean all the listeners registered in CC. this.listeners.clear(); ZKRegistrationHandle h = (ZKRegistrationHandle) handle; try { ServiceInstance<DrillbitEndpoint> serviceInstance = ServiceInstance .<DrillbitEndpoint> builder().address("").port(0).id(h.id) .name(serviceName).build(); discovery.unregisterService(serviceInstance); } catch (Exception e) { Throwables.throwIfUnchecked(e); throw new RuntimeException(e); } }
@Override public void unannounce(DruidNode service) { final String serviceName = CuratorServiceUtils.makeCanonicalServiceName(service.getServiceName()); final ServiceInstance<Void> instance; synchronized (monitor) { instance = instanceMap.get(serviceName); if (instance == null) { log.warn("Ignoring request to unannounce service[%s]", service); return; } } log.info("Unannouncing service[%s]", service); try { discovery.unregisterService(instance); } catch (Exception e) { log.makeAlert(e, "Failed to unannounce service[%s], zombie znode perhaps in existence.", serviceName) .addData("service", service) .emit(); } finally { synchronized (monitor) { instanceMap.remove(serviceName); } } } }
/** {@inheritDoc} */ @Override public void unregisterAddresses(Collection<InetSocketAddress> addrs) throws IgniteSpiException { // if curator is not STARTED, we have nothing to unregister, because we are using ephemeral nodes, // which means that our addresses will only be registered in ZK as long as our connection is alive if (curator.getState() != CuratorFrameworkState.STARTED) return; if (log.isInfoEnabled()) log.info("Unregistering addresses with ZooKeeper IP Finder: " + addrs); for (InetSocketAddress addr : addrs) { ServiceInstance<IgniteInstanceDetails> si = ourInstances.get(addr); if (si == null) { log.warning("Asked to unregister address from ZooKeeper IP Finder, but no match was found in local " + "instance map for: " + addrs); continue; } try { discovery.unregisterService(si); } catch (Exception e) { log.warning("Error while unregistering an address from ZooKeeper IP Finder: " + addr, e); } } }
/** * Reset the state to empty. */ public void resetState() { rwLock.readLock().lock(); ServiceInstance<ModelEndpoint> ep = null; try { for(Map.Entry<String, ServiceInstance<ModelEndpoint>> kv : containerToEndpoint.entrySet()) { ep = kv.getValue(); serviceDiscovery.unregisterService(ep); } } catch (Exception e) { LOG.error("Unable to unregister endpoint " + ep.getPayload(), e); } finally { rwLock.readLock().unlock(); } }
/** * Unregister a service based on its container ID. * @param containerIdRaw */ public void unregisterByContainer(String containerIdRaw) { rwLock.readLock().lock(); try { String containerId = containerIdRaw; //if(containerIdRaw.contains("_")) { // containerId = "" + Long.parseLong(Iterables.getLast(Splitter.on("_").split(containerIdRaw), null)); //} ServiceInstance<ModelEndpoint> ep = containerToEndpoint.get(containerId); if(ep != null) { serviceDiscovery.unregisterService(ep); } else { LOG.warn("Unable to find registered model associated with container " + containerId); throw new IllegalStateException("Unable."); } } catch (Exception e) { LOG.error("Unable to unregister container " + containerIdRaw + " due to: " + e.getMessage(), e); } finally { rwLock.readLock().unlock(); } }
@Override public void unregisterService(ServiceInstance<String> serviceInstance) throws Exception { discovery.unregisterService(serviceInstance); }
@Override public void unregisterService(ServiceInstance<String> serviceInstance) throws Exception { discovery.unregisterService(serviceInstance); }
public void selfUnregister() { try { serviceDiscovery.unregisterService(ZkServiceInstanceAdaptor.thisCuratorServiceInstance()); } catch (Throwable e) { throw new RuntimeException(e); } }
@Override public void unregister(ApplicationInstance applicationInstance) throws Exception { ServiceInstance<NodeStatus> serviceInstance = ZkServiceInstanceAdaptor.curatorServiceInstance(applicationInstance); serviceDiscovery.unregisterService(serviceInstance); }
void unregister(ZKRegistrationHandle handle) { //do not remove listeners, as they are global per service try { discovery.unregisterService(handle.getServiceInstance()); } catch(Exception e) { throw propagate(e); } }
@Override public void unregister(GroupInstance groupInstance) throws Exception { serviceDiscovery.unregisterService(ZkServiceInstanceAdaptor.curatorServiceInstance(groupInstance)); }
@Override public void unregister(UnitInstance unitInstance) throws Exception { serviceDiscovery.unregisterService(ZkServiceInstanceAdaptor.curatorServiceInstance(unitInstance)); }
@Override public void unregister() throws ComponentRegistrationException { try { serviceDiscovery.unregisterService(registeredInstance); registeredInstance = null; registered = false; } catch (Exception e) { // TODO Auto-generated catch block throw new ComponentRegistrationException(e); } }
public synchronized void deAdvertiseAvailability() { checkInitialized(); logger.info("Deadvertising availability at <" + listenAddress + ":" + listenPort + ">"); try { serviceDiscovery.unregisterService(getServiceInstance()); } catch (Exception e) { throw new RuntimeException(e); } }
/** * 注销本节点内所有unit实例 */ public void selfUnregister() { LocalUnitsManager.searchUnitMap(searchUnitMap -> searchUnitMap.forEach((unitFullName, unit) -> { try { ServiceInstance<UnitProxy> thisInstance = ZkServiceInstanceAdaptor.thisCuratorServiceInstance(unit); serviceDiscovery.unregisterService(thisInstance); } catch (Throwable e) { LOG.error(e);//别打断循环内其他操作 } })); }
@Override public void deregister(ZookeeperRegistration registration) { try { getServiceDiscovery().unregisterService(registration.getServiceInstance()); } catch (Exception e) { rethrowRuntimeException(e); } }
private void unadvertiseService() throws Exception { // Stop the service discovery cache sCache.close(); // Unadvertise on the service discovery sDiscovery.unregisterService(getMetadataInstance()); sDiscovery.close(); }
private void unadvertiseService() throws Exception { // Stop the service discovery cache sCache.close(); // Unadvertise on the service discovery sDiscovery.unregisterService(getMetadataInstance()); sDiscovery.close(); }
public void unregisterService(String serviceName, int port) throws Exception{ String localIp = getInnerHostIp(); String id = serviceName.substring(serviceName.lastIndexOf(".")+1) + ":"+localIp+":"+port; ServiceInstance<InstanceDetails> service = ServiceInstance.<InstanceDetails>builder() .name(serviceName) .address(getInnerHostIp()) .port(port) .id(id) .serviceType(ServiceType.DYNAMIC) .payload(new InstanceDetails(id)).build(); serviceDiscovery.unregisterService(service); logger.info("unregisterService|serviceName=" + serviceName + "|port=" + port); }
private void unadvertiseService() throws Exception { // Unadvertise on the service discovery sDiscovery.unregisterService(getMetadataInstance()); sDiscovery.close(); sleep(1000); // Sleep to allow ZKUtils ServiceCache to update }