/** * @param key e.g., {service}.configurators, {service}.tagrouters, {group}.dubbo.properties * @return */ @Override public Object getInternalProperty(String key) { ChildData childData = treeCache.getCurrentData(key); if (childData != null) { return new String(childData.getData(), StandardCharsets.UTF_8); } return null; }
/** * @param key e.g., {service}.configurators, {service}.tagrouters, {group}.dubbo.properties * @return */ @Override public Object getInternalProperty(String key) { ChildData childData = treeCache.getCurrentData(key); if (childData != null) { return new String(childData.getData(), StandardCharsets.UTF_8); } return null; }
private void dumpDirectly(final String path, final List<String> result) { for (String each : regCenter.getChildrenKeys(path)) { String zkPath = path + "/" + each; String zkValue = regCenter.get(zkPath); if (null == zkValue) { zkValue = ""; } TreeCache treeCache = (TreeCache) regCenter.getRawCache("/" + jobName); ChildData treeCacheData = treeCache.getCurrentData(zkPath); String treeCachePath = null == treeCacheData ? "" : treeCacheData.getPath(); String treeCacheValue = null == treeCacheData ? "" : new String(treeCacheData.getData()); if (zkValue.equals(treeCacheValue) && zkPath.equals(treeCachePath)) { result.add(Joiner.on(" | ").join(zkPath, zkValue)); } else { result.add(Joiner.on(" | ").join(zkPath, zkValue, treeCachePath, treeCacheValue)); } dumpDirectly(zkPath, result); } }
/** * 获取数据,先从本地获取,本地找不到,从远程获取 * * @param key * @return */ public String get(final String key) { if (null == cache) { return null; } ChildData data = cache.getCurrentData(key); if (null != data) { return null == data.getData() ? null : new String(data.getData(), Constants.UTF_8); } return getFromRemote(key); }
@Override public String get(final String key) { TreeCache cache = findTreeCache(key); if (null == cache) { return getDirectly(key); } ChildData resultInCache = cache.getCurrentData(key); if (null != resultInCache) { return null == resultInCache.getData() ? null : new String(resultInCache.getData(), Charsets.UTF_8); } return getDirectly(key); }
@Override public String get(final String key) { TreeCache cache = findTreeCache(key); if (null == cache) { return getDirectly(key); } ChildData resultInCache = cache.getCurrentData(key); if (null != resultInCache) { return null == resultInCache.getData() ? null : new String(resultInCache.getData(), Charsets.UTF_8); } return getDirectly(key); }
private TopicVO getTopicZkData(String topic) { return Optional.ofNullable(topicTreeCache.getCurrentData(ZkUtils.getTopicPath(topic))) .map(this::parseZkTopic) .orElse(null); }
/** * @param key e.g., {service}.configurators, {service}.tagrouters, {group}.dubbo.properties * @return */ @Override public Object getInternalProperty(String key) { ChildData childData = treeCache.getCurrentData(key); if (childData != null) { return new String(childData.getData(), StandardCharsets.UTF_8); } return null; }
public List<String> getChildrenNames(String fullPath) { TreeData parentData = getCurrentData(fullPath); if (parentData != null) { return new ArrayList<String>(parentData.getChildren()); } return Lists.newArrayList(); }
public static byte[] getByteData(TreeCache cache, String path) throws Exception { ChildData cacheData = cache.getCurrentData(path); if (cacheData != null) { return cacheData.getData(); } else { return null; } }
/** * @param key e.g., {service}.configurators, {service}.tagrouters, {group}.dubbo.properties * @return */ @Override public Object getInternalProperty(String key) { ChildData childData = treeCache.getCurrentData(key); if (childData != null) { return new String(childData.getData(), StandardCharsets.UTF_8); } return null; }
private Optional<TopicPartitionStateVO> partitionState(String topicName, int partitionId) throws IOException { final Optional<byte[]> partitionData = Optional.ofNullable(topicTreeCache.getCurrentData( ZkUtils.getTopicPartitionLeaderAndIsrPath(topicName, partitionId))) .map(ChildData::getData); if (partitionData.isPresent()) { return Optional.ofNullable(objectMapper.reader(TopicPartitionStateVO.class).readValue(partitionData.get())); } else { return Optional.empty(); } }
public List<TreeData> getChildren(String fullPath) { List<TreeData> children = Lists.newArrayList(); for (String child : getChildrenNames(fullPath)) { String childFullPath = ZKPaths.makePath(fullPath, child); children.add(getCurrentData(childFullPath)); } return children; }
@Override public byte[] getConfigurationDataFor(String path) throws SiteWhereException { ChildData data = getTreeCache().getCurrentData(path); return (data != null) ? data.getData() : null; }
/** * @param subPath 相对于{@link #root}的节点路径 * @return 节点数据,如果节点不存在那么返回null */ public String get(String subPath) { String fullPath = getFullPath(subPath); ChildData childData = treeCache.getCurrentData(fullPath); if (childData == null) { LOG.warn("节点" + fullPath + "不存在"); return null; } String dataStr = new String(childData.getData()); LOG.debug("歪歪日志: cache data=" + dataStr); return dataStr; }
@Override public String get(final String key) { TreeCache cache = findTreeCache(key); if (null == cache) { return getDirectly(key); } ChildData resultInCache = cache.getCurrentData(key); if (null != resultInCache) { return null == resultInCache.getData() ? null : new String(resultInCache.getData(), Charsets.UTF_8); } return getDirectly(key); }
@Override public String get(final String key) { TreeCache cache = findTreeCache(key); if (null == cache) { return getDirectly(key); } ChildData resultInCache = cache.getCurrentData(key); if (null != resultInCache) { return null == resultInCache.getData() ? null : new String(resultInCache.getData(), Charsets.UTF_8); } return getDirectly(key); }
@Override public String get(final String key) { TreeCache cache = findTreeCache(key); if (null == cache) { return getDirectly(key); } ChildData resultInCache = cache.getCurrentData(key); if (null != resultInCache) { return null == resultInCache.getData() ? null : new String(resultInCache.getData(), Charsets.UTF_8); } return getDirectly(key); }
@Override public String get(final String key) { TreeCache cache = findTreeCache(key); if (null == cache) { return getDirectly(key); } ChildData resultInCache = cache.getCurrentData(key); if (null != resultInCache) { return null == resultInCache.getData() ? null : new String(resultInCache.getData(), StandardCharsets.UTF_8); } return getDirectly(key); }
@Override public String get(final String key) { TreeCache cache = findTreeCache(key); if (null == cache) { return getDirectly(key); } ChildData resultInCache = cache.getCurrentData(key); if (null != resultInCache) { return null == resultInCache.getData() ? null : new String(resultInCache.getData(), Charsets.UTF_8); } return getDirectly(key); }