public List<String> getZookeeperServers() { ZooKeeperEnsemble zooKeeperEnsemble = entity.getConfig(Storm.ZOOKEEPER_ENSEMBLE); Supplier<List<String>> supplier = Entities.attributeSupplierWhenReady(zooKeeperEnsemble, ZooKeeperEnsemble.ZOOKEEPER_SERVERS); return supplier.get(); }
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; }
@Override public void run() { result.set(Entities.attributeSupplierWhenReady(entity, TestEntity.NAME).get()); }}); try {
public static <T> Supplier<T> attributeSupplierWhenReady(EntityAndAttribute<T> tuple) { return attributeSupplierWhenReady(tuple.getEntity(), tuple.getAttribute()); }
assertEquals(Entities.attributeSupplierWhenReady(entity, TestEntity.NAME).get(), "myname");
@Override public void postStart() { Entities.waitForServiceUp(this); sensors().get(DOCKER_CONTAINER_CLUSTER).sensors().set(SERVICE_UP, Boolean.TRUE); if (Boolean.TRUE.equals(sensors().get(DOCKER_INFRASTRUCTURE).config().get(SdnAttributes.SDN_ENABLE))) { LOG.info("Waiting on SDN agent"); SdnAgent agent = Entities.attributeSupplierWhenReady(this, SdnAgent.SDN_AGENT).get(); Entities.waitForServiceUp(agent); LOG.info("SDN agent running: " + agent.sensors().get(SERVICE_UP)); } String imageId = config().get(DOCKER_IMAGE_ID); if (Strings.isBlank(imageId)) { String dockerfileUrl = config().get(DockerInfrastructure.DOCKERFILE_URL); String imageName = DockerUtils.imageName(this, dockerfileUrl); imageId = buildImage(dockerfileUrl, null, null, imageName, config().get(DockerHost.DOCKER_USE_SSH), ImmutableMap.<String, Object>of("fullyQualifiedImageName", imageName)); sensors().set(DOCKER_IMAGE_NAME, imageName); } sensors().set(DOCKER_IMAGE_ID, imageId); scan = scanner(); // If a registry URL is configured with credentials then log in String registryUrl = config().get(DockerInfrastructure.DOCKER_IMAGE_REGISTRY_URL); Boolean internalRegistry = config().get(DockerInfrastructure.DOCKER_SHOULD_START_REGISTRY); if (Strings.isNonBlank(registryUrl) && !internalRegistry) { String username = config().get(DockerInfrastructure.DOCKER_IMAGE_REGISTRY_USERNAME); String password = config().get(DockerInfrastructure.DOCKER_IMAGE_REGISTRY_PASSWORD); if (Strings.isNonBlank(username) && Strings.isNonBlank(password)) { runDockerCommand(String.format("login -e \"fake@example.org\" -u %s -p %s %s", username, password, registryUrl)); } } }
SdnAgent agent = Entities.attributeSupplierWhenReady(dockerHost, SdnAgent.SDN_AGENT).get(); List<String> networks = sensors().get(SdnAttributes.ATTACHED_NETWORKS); Set<String> addresses = Sets.newHashSet();