protected ServiceInstance<DrillbitEndpoint> newServiceInstance( DrillbitEndpoint endpoint) throws Exception { return ServiceInstance.<DrillbitEndpoint> builder().name(serviceName) .payload(endpoint).build(); }
@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); } }
.name(serviceName) .uriSpec(URI_SPEC) .address(addr.getAddress().getHostAddress())
try { instance = ServiceInstance.<Void>builder() .name(serviceName) .address(service.getHost()) .port(service.getPlaintextPort())
/** * Pretend to be a Drillbit creating its ZK entry. Real Drillbits use a GUID * as the key, but we just use the host name, which is good enough for our * purposes here. * * @param zk * @param host * @throws Exception */ private void addDrillbit(CuratorFramework zk, String host) throws Exception { DrillbitEndpoint dbe = makeEndpoint(host); ServiceInstance<DrillbitEndpoint> si = ServiceInstance .<DrillbitEndpoint> builder().name(CLUSTER_ID).payload(dbe).build(); byte data[] = DrillServiceInstanceHelper.SERIALIZER.serialize(si); zk.create().forPath("/" + host, data); }
private ServiceDiscovery createAndAnnounceServices(List<String> serviceNames) throws Exception { int port = 1000; ServiceDiscovery<Void> serviceDiscovery = ServiceDiscoveryBuilder.builder(Void.class) .basePath("/test") .client(curator) .build(); for (String serviceName : serviceNames) { String serviceNameToUse = CuratorServiceUtils.makeCanonicalServiceName(serviceName); ServiceInstance instance = ServiceInstance.<Void>builder() .name(serviceNameToUse) .address("localhost") .port(port++) .build(); serviceDiscovery.registerService(instance); } return serviceDiscovery; }
.address(endpointUrl.getHost()) .id(containerId) .name(name) .port(endpointUrl.getPort()) .registrationTimeUTC(System.currentTimeMillis())
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(); }
.address(endpointUrl.getHost()) .id("0") .name("dga") .port(endpointUrl.getPort()) .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<NodeEndpoint> newServiceInstance(String name, NodeEndpoint endpoint) throws Exception { return ServiceInstance.<NodeEndpoint>builder() .name(name) .payload(endpoint) .build(); }
protected ServiceInstance<DrillbitEndpoint> newServiceInstance(DrillbitEndpoint endpoint) throws Exception { return ServiceInstance.<DrillbitEndpoint>builder() .name(serviceName) .payload(endpoint) .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(); } }
protected ServiceInstance serviceInstance(StubConfiguration stubConfiguration, int port) { try { return ServiceInstance.builder() .uriSpec(new UriSpec(this.zookeeperDiscoveryProperties.getUriSpec())) .address("localhost").port(port).name(name(stubConfiguration)) .build(); } catch (Exception e) { throw new IllegalStateException(e); } }
@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(); }
@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(); }