CuratorDatabaseClient { public List<Node> readNodes(Node.State ... states) { List<Node> nodes = new ArrayList<>(); if (states.length == 0) states = Node.State.values(); CuratorDatabase.Session session = db.getSession(); for (Node.State state : states) { for (String hostname : session.getChildren(toPath(state))) { Optional<Node> node = readNode(session, hostname, state); node.ifPresent(nodes::add); } } return nodes; } CuratorDatabaseClient(NodeFlavors flavors, Curator curator, Clock clock, Zone zone, boolean useCache,
                                 long nodeCacheSize); List<String> cluster(); List<Node> addNodesInState(List<Node> nodes, Node.State expectedState, Agent agent); void removeNodes(List<Node> nodes); List<Node> writeTo(List<Node> nodes, Agent agent, Optional<String> reason); List<Node> writeTo(Node.State toState, List<Node> nodes,
                              Agent agent, Optional<String> reason); Node writeTo(Node.State toState, Node node, Agent agent, Optional<String> reason); List<Node> writeTo(Node.State toState, List<Node> nodes,
                              Agent agent, Optional<String> reason,
                              NestedTransaction transaction); List<Node> readNodes(Node.State ... states); List<Node> readNodes(ApplicationId applicationId, Node.State ... states); Optional<Node> readNode(CuratorDatabase.Session session, String hostname, Node.State ... states); Optional<Node> readNode(String hostname, Node.State ... states); Lock lockInactive(); Lock lock(ApplicationId application); Lock lock(ApplicationId application, Duration timeout); Lock configLock(ApplicationId application); List<ApplicationId> readApplicationIds(); Optional<Application> readApplication(ApplicationId id); void writeApplication(Application application, NestedTransaction transaction); void deleteApplication(ApplicationId application, NestedTransaction transaction); Lock lockMaintenanceJob(String jobName); Map<NodeType, Version> readInfrastructureVersions(); void writeInfrastructureVersions(Map<NodeType, Version> infrastructureVersions); Lock lockInfrastructureVersions(); OsVersionChange readOsVersionChange(); void writeOsVersionChange(OsVersionChange change); Lock lockOsVersionChange(); Map<NodeType, DockerImage> readDockerImages(); void writeDockerImages(Map<NodeType, DockerImage> dockerImages); Lock lockDockerImages(); void writeFirmwareCheck(Optional<Instant> after); Optional<Instant> readFirmwareCheck(); List<LoadBalancerId> readLoadBalancerIds(); Map<LoadBalancerId, LoadBalancer> readLoadBalancers(Predicate<LoadBalancerId> filter); Optional<LoadBalancer> readLoadBalancer(LoadBalancerId id); void writeLoadBalancer(LoadBalancer loadBalancer); void writeLoadBalancers(Collection<LoadBalancer> loadBalancers, NestedTransaction transaction); void removeLoadBalancer(LoadBalancerId loadBalancer); List<Integer> getProvisionIndexes(int numIndexes); CacheStats cacheStats(); CacheStats nodeSerializerCacheStats();  }
@Test public void can_read_stored_host_information() throws Exception { String zkline = "{\"hostname\":\"host1\",\"ipAddresses\":[\"127.0.0.1\"],\"openStackId\":\"7951bb9d-3989-4a60-a21c-13690637c8ea\",\"flavor\":\"default\",\"created\":1421054425159, \"type\":\"host\"}"; curator.framework().create().creatingParentsIfNeeded().forPath("/provision/v1/ready/host1", zkline.getBytes()); List<Node> allocatedNodes = zkClient.readNodes(Node.State.ready); assertEquals(1, allocatedNodes.size()); assertEquals(NodeType.host, allocatedNodes.get(0).type()); }