- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中org.apache.helix.manager.zk.ZkClient.getChildren()
方法的一些代码示例,展示了ZkClient.getChildren()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZkClient.getChildren()
方法的具体详情如下:
包路径:org.apache.helix.manager.zk.ZkClient
类名称:ZkClient
方法名:getChildren
暂无
代码示例来源:origin: org.apache.helix/helix-core
/**
* sync getChildNames
* @return null if parentPath doesn't exist
*/
@Override
public List<String> getChildNames(String parentPath, int options) {
try {
List<String> childNames = _zkClient.getChildren(parentPath);
Collections.sort(childNames);
return childNames;
} catch (ZkNoNodeException e) {
return null;
}
}
代码示例来源:origin: apache/helix
public static List<String> getInstancePropertyList(ZkClient zkClient, String clusterName,
String instanceName, PropertyType property, String key) {
String propertyPath = PropertyPathBuilder.instanceProperty(clusterName, instanceName, property, key);
return zkClient.getChildren(propertyPath);
}
}
代码示例来源:origin: org.apache.helix/helix-core
@Override
public List<String> getClusters() {
List<String> zkToplevelPathes = _zkClient.getChildren("/");
List<String> result = new ArrayList<String>();
for (String pathName : zkToplevelPathes) {
if (ZKUtil.isClusterSetup(pathName, _zkClient)) {
result.add(pathName);
}
}
return result;
}
代码示例来源:origin: org.apache.helix/helix-core
@Override
public List<String> getInstancesInCluster(String clusterName) {
String memberInstancesPath = PropertyPathBuilder.instance(clusterName);
return _zkClient.getChildren(memberInstancesPath);
}
代码示例来源:origin: org.apache.helix/helix-core
@Override
public List<String> getResourcesInCluster(String clusterName) {
return _zkClient.getChildren(PropertyPathBuilder.idealState(clusterName));
}
代码示例来源:origin: org.apache.helix/helix-core
@Override
public List<String> getStateModelDefs(String clusterName) {
return _zkClient.getChildren(PropertyPathBuilder.stateModelDef(clusterName));
}
代码示例来源:origin: org.apache.helix/helix-core
public void download(String zkPath, String fsPath) throws Exception {
List<String> children = client.getChildren(zkPath);
if (children != null && children.size() > 0) {
new File(fsPath).mkdirs();
for (String child : children) {
String childPath = zkPath.equals("/") ? "/" + child : zkPath + "/" + child;
download(childPath, fsPath + "/" + child);
}
} else {
System.out
.println("Saving " + zkPath + " to " + new File(fsPath + suffix).getCanonicalPath());
OutputStream out = new FileOutputStream(fsPath + suffix);
Object readData = client.readData(zkPath);
if (readData != null) {
out.write((byte[]) readData);
}
out.close();
}
}
}
代码示例来源:origin: apache/helix
public List<String> getChildren(final String path) {
List<String> children = super.getChildren(path);
for (String p : _dataMap.keySet()) {
if (p.contains(path)) {
String[] paths = p.split("/");
children.add(paths[paths.length-1]);
}
}
return children;
}
代码示例来源:origin: apache/helix
public static String getInstancePropertyNameListAsString(ZkClient zkClient, String clusterName,
String instanceName, PropertyType instanceProperty, String key, MediaType mediaType)
throws JsonGenerationException, JsonMappingException, IOException {
String path = PropertyPathBuilder.instanceProperty(clusterName, instanceName, instanceProperty, key);
if (zkClient.exists(path)) {
List<String> recordNames = zkClient.getChildren(path);
return ObjectToJson(recordNames);
}
return ObjectToJson(new ArrayList<String>());
}
代码示例来源:origin: org.apache.helix/helix-core
String fromPath = concatenate(srcRootPath, path);
List<String> children = srcClient.getChildren(fromPath);
List<String> paths = new ArrayList<String>();
if (children != null && children.size() > 0) {
代码示例来源:origin: apache/helix
private ZNRecord readZkChild(String zkPath, ZkClient zkClient) {
ZNRecord result = null;
// read data and stat
Stat stat = new Stat();
ZNRecord data = zkClient.readDataAndStat(zkPath, stat, true);
if (data != null) {
result = data;
} else {
result = new ZNRecord("");
}
// read childrenList
List<String> children = zkClient.getChildren(zkPath);
if (children != null && children.size() > 0) {
result.setSimpleField("numChildren", "" + children.size());
result.setListField("childrenList", children);
} else {
result.setSimpleField("numChildren", "" + 0);
}
return result;
}
代码示例来源:origin: org.apache.helix/helix-core
public static List<ZNRecord> getChildren(ZkClient client, String path) {
// parent watch will be set by zkClient
List<String> children = client.getChildren(path);
if (children == null || children.size() == 0) {
return Collections.emptyList();
}
List<ZNRecord> childRecords = new ArrayList<ZNRecord>();
for (String child : children) {
String childPath = path + "/" + child;
Stat newStat = new Stat();
ZNRecord record = client.readDataAndStat(childPath, newStat, true);
if (record != null) {
record.setVersion(newStat.getVersion());
record.setCreationTime(newStat.getCtime());
record.setModifiedTime(newStat.getMtime());
childRecords.add(record);
}
}
return childRecords;
}
代码示例来源:origin: org.apache.helix/helix-core
public boolean verifyByCallback(long timeout, List<ClusterVerifyTrigger> triggers) {
_countdown = new CountDownLatch(1);
for (ClusterVerifyTrigger trigger : triggers) {
String path = trigger._triggerKey.getPath();
_zkclient.subscribeChildChanges(path, this);
if (trigger._triggerOnChildDataChange) {
List<String> childs = _zkclient.getChildren(path);
for (String child : childs) {
String childPath = String.format("%s/%s", path, child);
_zkclient.subscribeDataChanges(childPath, this);
}
}
}
boolean success = false;
try {
success = verify();
if (!success) {
success = _countdown.await(timeout, TimeUnit.MILLISECONDS);
if (!success) {
// make a final try if timeout
success = verify();
}
}
} catch (Exception e) {
LOG.error("Exception in verifier", e);
}
// clean up
_zkclient.unsubscribeAll();
return success;
}
代码示例来源:origin: org.apache.helix/helix-core
@Override
public List<String> getInstancesInClusterWithTag(String clusterName, String tag) {
String memberInstancesPath = PropertyPathBuilder.instance(clusterName);
List<String> instances = _zkClient.getChildren(memberInstancesPath);
List<String> result = new ArrayList<String>();
HelixDataAccessor accessor =
new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<ZNRecord>(_zkClient));
Builder keyBuilder = accessor.keyBuilder();
for (String instanceName : instances) {
InstanceConfig config = accessor.getProperty(keyBuilder.instanceConfig(instanceName));
if (config == null) {
throw new IllegalStateException(String
.format("Instance %s does not have a config, cluster might be in bad state",
instanceName));
}
if (config.containsTag(tag)) {
result.add(instanceName);
}
}
return result;
}
代码示例来源:origin: org.apache.helix/helix-core
retKeys = new ArrayList<String>(record.getMapFields().keySet());
} else {
retKeys = zkClient.getChildren(zkPath);
代码示例来源:origin: org.apache.helix/helix-core
List<String> children = _zkClient.getChildren(path);
for (String child : children) {
String newPath = path + "/" + child;
代码示例来源:origin: org.apache.helix/helix-core
private void subscribeTrigger(ClusterVerifyTrigger trigger) {
String path = trigger.getTriggerKey().getPath();
if (trigger.isTriggerOnDataChange()) {
_zkClient.subscribeDataChanges(path, this);
}
if (trigger.isTriggerOnChildChange()) {
_zkClient.subscribeChildChanges(path, this);
}
if (trigger.isTriggerOnChildDataChange()) {
List<String> childs = _zkClient.getChildren(path);
for (String child : childs) {
String childPath = String.format("%s/%s", path, child);
_zkClient.subscribeDataChanges(childPath, this);
}
}
}
代码示例来源:origin: apache/helix
@Override
public Representation delete() {
String zkPath = getZKPath();
try {
ZkClient zkClient =
(ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);
List<String> childNames = zkClient.getChildren(zkPath);
if (childNames != null) {
for (String childName : childNames) {
String childPath = zkPath.equals("/") ? "/" + childName : zkPath + "/" + childName;
zkClient.deleteRecursively(childPath);
}
}
getResponse().setStatus(Status.SUCCESS_OK);
} catch (Exception e) {
getResponse().setEntity(ClusterRepresentationUtil.getErrorAsJsonStringFromException(e),
MediaType.APPLICATION_JSON);
getResponse().setStatus(Status.SUCCESS_OK);
LOG.error("Error in delete zkChild: " + zkPath, e);
}
return null;
}
}
代码示例来源:origin: apache/helix
private ZNRecord readZkDataStatAndChild(String zkPath, ZkClient zkClient) {
ZNRecord result = null;
// read data and stat
Stat stat = new Stat();
ZNRecord data = zkClient.readDataAndStat(zkPath, stat, true);
if (data != null) {
result = data;
} else {
result = new ZNRecord("");
}
result.setSimpleField("zkPath", zkPath);
result.setSimpleField("stat", stat.toString());
result.setSimpleField("numChildren", "" + stat.getNumChildren());
result.setSimpleField("ctime", "" + new Date(stat.getCtime()));
result.setSimpleField("mtime", "" + new Date(stat.getMtime()));
result.setSimpleField("dataLength", "" + stat.getDataLength());
// read childrenList
List<String> children = zkClient.getChildren(zkPath);
if (children != null && children.size() > 0) {
result.setListField("children", children);
}
return result;
}
代码示例来源:origin: apache/helix
@Override
public Representation post(Representation entity) {
String zkPath = getZKPath();
try {
JsonParameters jsonParameters = new JsonParameters(entity);
String command = jsonParameters.getCommand();
ZkClient zkClient =
(ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);
if (command.equalsIgnoreCase(JsonParameters.ZK_DELETE_CHILDREN)) {
List<String> childNames = zkClient.getChildren(zkPath);
if (childNames != null) {
for (String childName : childNames) {
String childPath = zkPath.equals("/") ? "/" + childName : zkPath + "/" + childName;
zkClient.deleteRecursively(childPath);
}
}
} else {
throw new HelixException("Unsupported command: " + command + ". Should be one of ["
+ JsonParameters.ZK_DELETE_CHILDREN + "]");
}
getResponse().setStatus(Status.SUCCESS_OK);
} catch (Exception e) {
getResponse().setEntity(ClusterRepresentationUtil.getErrorAsJsonStringFromException(e),
MediaType.APPLICATION_JSON);
getResponse().setStatus(Status.SUCCESS_OK);
LOG.error("Error in post zkPath: " + zkPath, e);
}
return null;
}
看下面的代码: public static void main(String[] args) { Group group1 = new Group(); Group g
我正在尝试制作一个创建棋盘的 javafx 程序。但是,当我尝试运行我的程序时,它会在这一行中抛出异常:optionsPane.getChildren().addAll(optionsPane, n_
例如,当我们向 Pane 添加新按钮时,我们需要编写以下代码: StackPane pane = new StackPane(); pane.getChildren().add(new Butto
我创建了一个单独的类来在 JavaFX 中设置网格。类如下: public class Grid { GridPane gp = new GridPane(); //sets grid (10
看下面的代码: public static void main(String[] args) { Group group1 = new Group(); Group g
我对 Java 比较陌生,尤其是 Javafx 和 GUI。我一直在研究这段代码,但我在理解最后一行正在做什么时遇到了一些困难。我知道倒数第二行是将所有组件添加到容器“p”中,但是当您在前面没有容器的
XML: .... PD1 PD2 PD3 ..
我想获取一个元素的所有子元素,包括文本节点。我如何在 MooTools 中执行此操作? mootools.net 上的文档明确指出 getChildren() 不包括文本节点。 最佳答案 您可以使用标
这是我的 xml: 例子: 987 0 F0F8DJH348DJ 46446
好吧,我不确定我是否在正确的地方问这个问题,但我希望这里有人可以帮助我。所以,我是 Java 初学者,我正在尝试制作 JavaFX 应用程序,但我的布局 1“getChildren.addAll(la
当我尝试调用 getChildren() 时在 mediapipeline 上其中运行了我的自定义模块端点我收到此异常: org.kurento.client.internal.server.Prot
为什么有时我们使用 getChildren() add() 而其他时候我们直接使用 add() es: https://docs.oracle.com/javafx/2/get_started/for
此代码不允许在我的窗口中绘制线条...我在 fxml 文件中只有一个简单的 Pane ,其 fx:id 为 hi 用于测试。没有错误,该行根本没有出现。我也用盒子和圆圈试过这个。我真的需要帮助,这是一
我有一个小问题,当我想添加文本字段时,VBOX 的按钮和标签我有一个错误:ObservableList 中的 addAll() 不能应用于: 在这个地方:vBox.getChildren().addA
如果我在 XML 文件上运行以下 python(请参见 Q 底部): import xml.etree.ElementTree as ET tree = ET.parse('C:\\temp\\tes
我清除了所有子项的网格 Pane ,然后再次将子项添加到网格 Pane 中,但它说存在重复项。 public void render(){ boardPane.getChildren().cl
我试图读取我之前在Excel工作表中插入的图像及其位置与此代码,它在我的机器上工作正常,但是当我将代码迁移到另一台电脑时,我在工作表中遇到空指针异常。 getDrawingPatriarch.getC
上下文 我正在为一个小游戏创建一个 GUI。游戏有一个开始屏幕。当玩家点击开始时,舞台场景从菜单场景变为游戏场景。新的游戏场景以 Group 作为父级,并包含一些元素,例如玩家的得分和姓名,所有这些元
我有一个 Group 子类的实例,我正在向其中添加其他 Groups。其中一个组是一个组的子类,它有一个方法 getCollision() .在那种方法中,我正在运行 for each循环检查该组父级
本文整理了Java中com.yahoo.text.XML.getChildren()方法的一些代码示例,展示了XML.getChildren()的具体用法。这些代码示例主要来源于Github/Stac
我是一名优秀的程序员,十分优秀!