@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); } }
ServiceInstanceBuilder<ModelEndpoint> builder = ServiceInstance.<ModelEndpoint> builder() .address(endpointUrl.getHost()) .id(containerId) .name(name) .port(endpointUrl.getPort())
public RegistrationBuilder id(String id) { this.builder.id(id); return this; }
private ServiceInstance<ModelEndpoint> createInstance(ModelEndpoint ep) throws Exception { URL url = new URL(ep.getEndpoint().getUrl()); ServiceInstanceBuilder<ModelEndpoint> builder = ServiceInstance.<ModelEndpoint> builder() .address(url.getHost()) .id(ep.getContainerId()) .name(ep.getName()) .port(url.getPort()) .registrationTimeUTC(System.currentTimeMillis()) .serviceType(ServiceType.STATIC) .payload(ep) ; return builder.build(); }
.id("0") .name("dga") .port(endpointUrl.getPort())
/** * Return a new builder. The {@link #address} is set to the ip of the first * NIC in the system. The {@link #id} is set to a random UUID. * * @return builder * @throws Exception errors getting the local IP */ public static<T> ServiceInstanceBuilder<T>builder() throws Exception { String address = null; Collection<InetAddress> ips = ServiceInstanceBuilder.getAllLocalIPs(); if ( ips.size() > 0 ) { address = ips.iterator().next().getHostAddress(); // default to the first address } String id = UUID.randomUUID().toString(); return new ServiceInstanceBuilder<T>().address(address).id(id).registrationTimeUTC(System.currentTimeMillis()); }
private ServiceInstance<Map> getMetadataInstance() throws Exception { // Creates the metadata that this server is providing to ZooKeeper and other Oozie Servers String url = ConfigUtils.getOozieEffectiveUrl(); Map<String, String> map = new HashMap<String, String>(); map.put(ZKMetadataKeys.OOZIE_ID, zkId); map.put(ZKMetadataKeys.OOZIE_URL, url); return ServiceInstance.<Map>builder() .name(ZK_OOZIE_SERVICE) .id(zkId) .payload(map) .build(); }
private ServiceInstance<Map> getMetadataInstance() throws Exception { // Creates the metadata that this server is providing to ZooKeeper and other Oozie Servers String url = ConfigUtils.getOozieEffectiveUrl(); Map<String, String> map = new HashMap<String, String>(); map.put(ZKMetadataKeys.OOZIE_ID, zkId); map.put(ZKMetadataKeys.OOZIE_URL, url); return ServiceInstance.<Map>builder() .name(ZK_OOZIE_SERVICE) .id(zkId) .payload(map) .build(); }
private ServiceInstance<Map> getMetadataInstance() throws Exception { // Creates the metadata that this server is providing to ZooKeeper and other Oozie Servers Map<String, String> map = new HashMap<String, String>(); map.put("OOZIE_ID", zkId); map.put("OOZIE_URL", metadataUrl); return ServiceInstance.<Map>builder() .name("servers") .id(zkId) .payload(map) .build(); } }
public void registerService(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.registerService(service); logger.info("registerService|serviceName=" + serviceName + "|port=" + port); }
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 ServiceInstance<WorkerMetadata> getServiceInstance() throws Exception { WorkerMetadata workerMetadata = new WorkerMetadata(workerId, listenAddress, listenPort); return ServiceInstance.<WorkerMetadata>builder() .name(zookeeperConfig.getWorkerServiceName()) .address(listenAddress) .port(listenPort) .id(workerId.toString()) .payload(workerMetadata) .build(); }
@Override public ServiceInstance<DrillbitEndpoint> deserialize(byte[] bytes) throws Exception { DrillServiceInstance i = DrillServiceInstance.parseFrom(bytes); ServiceInstanceBuilder<DrillbitEndpoint> b = ServiceInstance.<DrillbitEndpoint>builder(); b.id(i.getId()); b.name(ExecConstants.SERVICE_NAME); b.registrationTimeUTC(i.getRegistrationTimeUTC()); b.payload(i.getEndpoint()); return b.build(); }
public static ServiceInstance<UnitProxy> curatorServiceInstance(UnitInstance unitInstance) { try { return ServiceInstance.<UnitProxy>builder() .address(unitInstance.getAddress()) .enabled(true) .id(unitInstance.getId()) .name(unitInstance.getName()) .port(unitInstance.getPort()) .payload(unitInstance.getPayload()) .build(); } catch (Exception e) { throw new RuntimeException(e); } }
public static ServiceInstance<NodeStatus> curatorServiceInstance(ApplicationInstance applicationInstance) { try { return ServiceInstance.<NodeStatus>builder() .address(/*applicationInstance.getPayload().getHost()*/applicationInstance.getAddress()) .enabled(true) .id(applicationInstance.getId()) .name(applicationInstance.getName()) .port(applicationInstance.getPort()) .payload(applicationInstance.getPayload()) .build(); } catch (Exception e) { throw new RuntimeException(e); } }
public static ServiceInstance<GroupProxy> curatorServiceInstance(GroupInstance groupInstance) { try { return ServiceInstance.<GroupProxy>builder() .address(groupInstance.getAddress()) .enabled(true) .id(groupInstance.getId()) .name(groupInstance.getName()) .port(groupInstance.getPort()) .payload(groupInstance.getPayload()) .build(); } catch (Exception e) { throw new RuntimeException(e); } }
@Override public ServiceInstance<NodeEndpoint> deserialize(byte[] bytes) throws Exception { DremioServiceInstance i = DremioServiceInstance.parseFrom(bytes); ServiceInstanceBuilder<NodeEndpoint> b = ServiceInstance.<NodeEndpoint>builder(); b.id(i.getId()); b.name(i.getName()); b.registrationTimeUTC(i.getRegistrationTimeUTC()); b.payload(i.getEndpoint()); return b.build(); }
public static ServiceInstance<NodeStatus> thisCuratorServiceInstance() throws Exception { return ServiceInstance.<NodeStatus>builder() .address(EnvUtil.getLocalIp()) .enabled(true) .id(LocalNodeManager.LOCAL_NODE_ID) .name(EnvUtil.getApplication()) .port(Node.RPC_PORT) .payload(LocalNodeManager.singleton.getFullStatus()) .build(); }
public static ServiceInstance<GroupProxy> thisCuratorServiceInstance(String groupName) throws Exception { return ServiceInstance.<GroupProxy>builder() .address(EnvUtil.getLocalIp()) .enabled(true) .id(new GroupInstanceIdBean(groupName, LocalNodeManager.LOCAL_NODE_ID).getGroupInstanceId()) .name(groupName) .port(Node.RPC_PORT) .payload(GroupProxy.create(LocalUnitsManager.getGroupByName(groupName))) .build(); }
public static ServiceInstance<UnitProxy> thisCuratorServiceInstance(Unit unit) throws Exception { String fullUnitName = Unit.fullName(unit); return ServiceInstance.<UnitProxy>builder() .address(EnvUtil.getLocalIp()) .enabled(true) .id(new UnitInstanceIdBean(fullUnitName, LocalNodeManager.LOCAL_NODE_ID).getUnitInstanceId()) .name(fullUnitName) .port(Node.RPC_PORT) .payload(UnitProxy.create(unit)) .serviceType(ServiceType.DYNAMIC) .build(); }