gpt4 book ai didi

org.apache.brooklyn.entity.zookeeper.ZooKeeperNode类的使用及代码示例

转载 作者:知者 更新时间:2024-03-13 09:51:08 25 4
gpt4 key购买 nike

本文整理了Java中org.apache.brooklyn.entity.zookeeper.ZooKeeperNode类的一些代码示例,展示了ZooKeeperNode类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZooKeeperNode类的具体详情如下:
包路径:org.apache.brooklyn.entity.zookeeper.ZooKeeperNode
类名称:ZooKeeperNode

ZooKeeperNode介绍

[英]An org.apache.brooklyn.api.entity.Entity that represents a single Apache ZooKeeper instance.
[中]一个组织。阿帕奇。布鲁克林应用程序编程接口。实体表示单个Apache ZooKeeper实例的实体。

代码示例

代码示例来源:origin: org.apache.brooklyn/brooklyn-software-messaging

/** Use the {@link #getZookeeper() zookeeper} details if available, otherwise use our own host and port. */
@Override
public void setBrokerUrl() {
  ZooKeeperNode zookeeper = getZookeeper();
  if (zookeeper != null) {
    sensors().set(BROKER_URL, String.format("zookeeper://%s:%d", zookeeper.getAttribute(HOSTNAME), zookeeper.getZookeeperPort()));
  } else {
    sensors().set(BROKER_URL, String.format("kafka://%s:%d", getAttribute(HOSTNAME), getKafkaPort()));
  }
}

代码示例来源:origin: org.apache.brooklyn/brooklyn-software-messaging

@Override
public void stop() {
  List<Exception> errors = Lists.newArrayList();
  if (getZooKeeper() != null && Objects.equal(this, getZooKeeper().getParent())) {
    try {
      getZooKeeper().stop();
    } catch (Exception e) {
      errors.add(e);
    }
  }
  if (getCurrentSize() > 0) {
    try {
      getCluster().stop();
    } catch (Exception e) {
      errors.add(e);
    }
  }
  clearLocations();
  sensors().set(SERVICE_UP, false);
  if (errors.size() != 0) {
    throw new CompoundRuntimeException("Error stopping Kafka cluster", errors);
  }
}

代码示例来源:origin: org.apache.brooklyn/brooklyn-software-messaging

props.put("zookeeper.connect", format(zookeeper.getHostname(), zookeeper.getZookeeperPort()));
props.put("group.id", "brooklyn");
props.put("partition.assignment.strategy", "RoundRobin");

代码示例来源:origin: org.apache.brooklyn/brooklyn-software-messaging

@Override
  public Void call() {
    assertTrue(cluster.getAttribute(Startable.SERVICE_UP));
    assertTrue(cluster.getZooKeeper().getAttribute(Startable.SERVICE_UP));
    assertEquals(cluster.getCurrentSize().intValue(), 2);
    return null;
  }
});

代码示例来源:origin: org.apache.brooklyn/brooklyn-software-messaging

@Override
public void start(Collection<? extends Location> locations) {
  if (isLegacyConstruction()) {
    // TODO should no longer be needed?
    init();
  }
  locations = MutableList.copyOf(Locations.getLocationsCheckingAncestors(locations, this));
  Iterables.getOnlyElement(locations); // Assert just one
  // set it; here we don't allow changing locations
  addLocations(locations);
  List<Entity> childrenToStart = MutableList.<Entity>of(getCluster());
  // Set the KafkaZookeeper entity as child of cluster, if it does not already have a parent
  if (getZooKeeper().getParent() == null) {
    addChild(getZooKeeper());
  } // And only start zookeeper if we are parent
  if (Objects.equal(this, getZooKeeper().getParent())) childrenToStart.add(getZooKeeper());
  Entities.invokeEffector(this, childrenToStart, Startable.START, ImmutableMap.of("locations", locations)).getUnchecked();
}

代码示例来源:origin: org.apache.brooklyn/brooklyn-software-messaging

/**
 * Test that can install, start and use a Zookeeper instance.
 */
@Override
protected void doTest(Location loc) throws Exception {
  ZooKeeperNode zookeeper = app.createAndManageChild(EntitySpec.create(ZooKeeperNode.class)
      .configure("jmxPort", "31001+"));
  app.start(ImmutableList.of(loc));
  EntityAsserts.assertAttributeEqualsEventually(zookeeper, Startable.SERVICE_UP, true);
  HostAndPort conn = HostAndPort.fromParts(
      zookeeper.sensors().get(ZooKeeperNode.HOSTNAME),
      zookeeper.sensors().get(ZooKeeperNode.ZOOKEEPER_PORT));
  try (ZooKeeperTestSupport zkts = new ZooKeeperTestSupport(conn)) {
    zkts.create("/ec2livetest", "data".getBytes());
    assertEquals(new String(zkts.get("/ec2livetest")), "data");
  }
}

代码示例来源:origin: org.apache.brooklyn/brooklyn-software-messaging

@Override
  public Void call() {
    assertTrue(cluster.getAttribute(Startable.SERVICE_UP));
    assertTrue(cluster.getZooKeeper().getAttribute(Startable.SERVICE_UP));
    assertEquals(cluster.getCurrentSize().intValue(), 2);
    return null;
  }
});

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com