本文整理了Java中org.apache.brooklyn.entity.zookeeper.ZooKeeperEnsemble
类的一些代码示例,展示了ZooKeeperEnsemble
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZooKeeperEnsemble
类的具体详情如下:
包路径:org.apache.brooklyn.entity.zookeeper.ZooKeeperEnsemble
类名称:ZooKeeperEnsemble
暂无
代码示例来源:origin: org.apache.brooklyn/brooklyn-software-messaging
public List<ZooKeeperServerConfig> getZookeeperServers() throws ExecutionException, InterruptedException {
List<ZooKeeperServerConfig> result = Lists.newArrayList();
if (entity.getParent() instanceof ZooKeeperEnsemble) {
ZooKeeperEnsemble ensemble = (ZooKeeperEnsemble) entity.getParent();
for (Entity member : ensemble.getMembers()) {
Integer memberId = member.config().get(ZooKeeperNode.MY_ID);
if (memberId == null) {
throw new IllegalStateException(member + " has null value for " + ZooKeeperNode.MY_ID);
}
String hostname = Entities.attributeSupplierWhenReady(member, ZooKeeperNode.SUBNET_HOSTNAME).get();
Integer port = Entities.attributeSupplierWhenReady(member, ZooKeeperNode.ZOOKEEPER_PORT).get();
Integer leaderPort = Entities.attributeSupplierWhenReady(member, ZooKeeperNode.ZOOKEEPER_LEADER_PORT).get();
Integer electionPort = Entities.attributeSupplierWhenReady(member, ZooKeeperNode.ZOOKEEPER_ELECTION_PORT).get();
result.add(new ZooKeeperServerConfig(memberId, hostname, port, leaderPort, electionPort));
}
}
return result;
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-software-messaging
assertNotNull(ensemble.sensors().get(ZooKeeperEnsemble.ZOOKEEPER_ENDPOINTS),
"expected value for " + ZooKeeperEnsemble.ZOOKEEPER_ENDPOINTS + " on " + ensemble + ", was null");
Set<Integer> nodeIds = Sets.newHashSet();
for (Entity zkNode : ensemble.getMembers()) {
nodeIds.add(zkNode.config().get(ZooKeeperNode.MY_ID));
List<String> servers = ensemble.sensors().get(ZooKeeperEnsemble.ZOOKEEPER_SERVERS);
assertNotNull(servers, "value for sensor should not be null: " + ZooKeeperEnsemble.ZOOKEEPER_SERVERS);
assertEquals(servers.size(), initialSize, "expected " + initialSize + " entries in " + servers);
内容来源于网络,如有侵权,请联系作者删除!