/** * 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); }
@Override public void updateService(ServiceInstance<T> service) throws Exception { Preconditions.checkArgument(services.containsKey(service.getId()), "Service is not registered: " + service); byte[] bytes = serializer.serialize(service); String path = String.format("%s/instance", pathForInstance(service.getName(), service.getId())); client.set(path, Base64.encodeBase64String(bytes)); }
@Override public void updateService(final ServiceInstance<T> service) throws Exception { Entry<T> entry = services.get(service.getId()); if ( entry == null ) { throw new Exception("Service not registered: " + service); } synchronized(entry) { entry.service = service; byte[] bytes = serializer.serialize(service); String path = pathForInstance(service.getName(), service.getId()); client.setData().forPath(path, bytes); } }
@Override public void updateService(final ServiceInstance<T> service) throws Exception { Entry<T> entry = services.get(service.getId()); if ( entry == null ) { throw new Exception("Service not registered: " + service); } synchronized(entry) { entry.service = service; byte[] bytes = serializer.serialize(service); String path = pathForInstance(service.getName(), service.getId()); client.setData().forPath(path, bytes); } }
@VisibleForTesting protected void internalRegisterService(ServiceInstance<T> service) throws Exception final byte[] bytes = serializer.serialize(service); final String path = pathForInstance(service.getName(), service.getId());
@VisibleForTesting protected void internalRegisterService(ServiceInstance<T> service) throws Exception byte[] bytes = serializer.serialize(service); String path = pathForInstance(service.getName(), service.getId());
@VisibleForTesting protected void internalRegisterService(ServiceInstance<T> service) throws Exception byte[] bytes = serializer.serialize(service); String path = pathForInstance(service.getName(), service.getId());