/** * Return a service instance POJO * * @param name name of the service * @param id ID of the instance * @return the instance or <code>null</code> if not found * @throws Exception errors */ @Override public ServiceInstance<T> queryForInstance(String name, String id) throws Exception { String path = pathForInstance(name, id); try { byte[] bytes = client.getData().forPath(path); return serializer.deserialize(bytes); } catch ( KeeperException.NoNodeException ignore ) { // ignore } return null; }
/** * Return a group instance POJO * * @param name name of the group * @param id ID of the instance * @return the instance or <code>null</code> if not found * @throws Exception errors */ @Override public ServiceInstance<T> queryForInstance(String name, String id) throws Exception { String path = pathForInstance(name, id); try { byte[] bytes = client.getData().forPath(path); return serializer.deserialize(bytes); } catch ( KeeperException.NoNodeException ignore ) { // ignore } return null; }
@Override public ServiceInstance<T> queryForInstance(String name, String id) throws Exception { EtcdResult result = client.get(String.format("%s/instance", pathForInstance(name, id))); String b64Instance = result.getNode().getValue(); byte[] bytes = Base64.decodeBase64(b64Instance); return serializer.deserialize(bytes); }
@Override public void nodeChanged() throws Exception { if ( nodeCache.getCurrentData() != null ) { ServiceInstance<T> newInstance = serializer.deserialize(nodeCache.getCurrentData().getData()); Entry<T> entry = services.get(newInstance.getId()); if ( entry != null ) { synchronized(entry) { entry.service = newInstance; } } } else { log.warn("Instance data has been deleted for: " + instance); } } };
@Override public void nodeChanged() throws Exception { if ( nodeCache.getCurrentData() != null ) { ServiceInstance<T> newInstance = serializer.deserialize(nodeCache.getCurrentData().getData()); Entry<T> entry = services.get(newInstance.getId()); if ( entry != null ) { synchronized(entry) { entry.service = newInstance; } } } else { log.warn("Instance data has been deleted for: " + instance); } } };
private ServiceInstance<T> addInstance(ChildData childData, boolean onlyIfAbsent) throws Exception { String instanceId = instanceIdFromData(childData); ServiceInstance<T> serviceInstance = discovery.getSerializer().deserialize(childData.getData()); if (onlyIfAbsent) { instances.putIfAbsent(instanceId, serviceInstance); } else { instances.put(instanceId, serviceInstance); } cache.clearDataBytes(childData.getPath(), childData.getStat().getVersion()); return serviceInstance; } }
private void addInstance(ChildData childData, boolean onlyIfAbsent) throws Exception { String instanceId = instanceIdFromData(childData); ServiceInstance<T> serviceInstance = discovery.getSerializer().deserialize(childData.getData()); if ( onlyIfAbsent ) { instances.putIfAbsent(instanceId, serviceInstance); } else { instances.put(instanceId, serviceInstance); } cache.clearDataBytes(childData.getPath(), childData.getStat().getVersion()); } }
ServiceInstance<T> serviceInstance = discovery.getSerializer().deserialize(Base64.decodeBase64(er.getNode().getValue()));
ServiceInstance<T> serviceInstance = discovery.getSerializer().deserialize(Base64.decodeBase64(result.getNode().getValue()));