/** {@inheritDoc} */ @Override public Collection<InetSocketAddress> getRegisteredAddresses() throws IgniteSpiException { initComputeService(); Collection<InetSocketAddress> addresses = new LinkedList<>(); try { Set<NodeMetadata> nodes; if (nodesFilter != null) nodes = (Set<NodeMetadata>)computeService.listNodesDetailsMatching(nodesFilter); else { nodes = new HashSet<>(); for (ComputeMetadata metadata : computeService.listNodes()) nodes.add(computeService.getNodeMetadata(metadata.getId())); } for (NodeMetadata metadata : nodes) { if (metadata.getStatus() != NodeMetadata.Status.RUNNING) continue; for (String addr : metadata.getPrivateAddresses()) addresses.add(new InetSocketAddress(addr, 0)); for (String addr : metadata.getPublicAddresses()) addresses.add(new InetSocketAddress(addr, 0)); } } catch (Exception e) { throw new IgniteSpiException("Failed to get registered addresses for the provider: " + provider, e); } return addresses; }
/** * get all nodes including details such as image and ip addresses even if it incurs extra * requests to the service. * * @param filter how to select the nodes you are interested in details on. */ @Override public Set<? extends NodeMetadata> listNodesDetailsMatching(Predicate<ComputeMetadata> filter) { return computeService.listNodesDetailsMatching(filter); }
/** * get all nodes including details such as image and ip addresses even if it incurs extra * requests to the service. * * @param filter how to select the nodes you are interested in details on. */ @Override public Set<? extends NodeMetadata> listNodesDetailsMatching(Predicate<? super NodeMetadata> filter) { return computeService.listNodesDetailsMatching(filter); }
/** * Sets the metadata of the available nodes to the out message. */ protected void listNodes(Exchange exchange) { Predicate<ComputeMetadata> predicate = getComputePredicate(exchange); Set<? extends ComputeMetadata> computeMetadatas = computeService.listNodesDetailsMatching(predicate); exchange.getOut().setBody(computeMetadatas); }
@Override public Set<? extends NodeMetadata> getNodes(ClusterSpec clusterSpec) throws IOException, InterruptedException { ComputeServiceContext computeServiceContext = getCompute().apply(clusterSpec); ComputeService computeService = computeServiceContext.getComputeService(); return computeService.listNodesDetailsMatching(Predicates.in(computeService.listNodes())); } }
@Override public Set<? extends NodeMetadata> getNodes(ClusterSpec clusterSpec) throws IOException, InterruptedException { ComputeServiceContext computeServiceContext = getCompute().apply(clusterSpec); ComputeService computeService = computeServiceContext.getComputeService(); return computeService.listNodesDetailsMatching(Predicates.in(computeService.listNodes())); } }
@Deprecated public Set<? extends NodeMetadata> getNodes(ClusterSpec clusterSpec) throws IOException, InterruptedException { ComputeService computeService = getCompute().apply(clusterSpec).getComputeService(); return computeService.listNodesDetailsMatching( runningInGroup(clusterSpec.getClusterName())); }
@Deprecated public Set<? extends NodeMetadata> getNodes(ClusterSpec clusterSpec) throws IOException, InterruptedException { ComputeService computeService = getCompute().apply(clusterSpec).getComputeService(); return computeService.listNodesDetailsMatching( runningInGroup(clusterSpec.getClusterName())); }
@Override public boolean apply(DatacenterAndName input) { return all(computeService.listNodesDetailsMatching(locationId(input.getDatacenter())), and(inGroup(input.getName()), TERMINATED)); } }
@Override public boolean apply(String groupName) { return all(filter(computeService.listNodesDetailsMatching(all()), inGroup(groupName)), TERMINATED); } }
@Override public boolean apply(String groupName) { return all(filter(computeService.listNodesDetailsMatching(all()), inGroup(groupName)), TERMINATED); } }
private void get(ComputeService computeService) { if (nodeElement.getId() != null) { log(String.format("get id: %s", nodeElement.getId())); logDetails(computeService, computeService.getNodeMetadata(nodeElement.getId())); } else { log(String.format("get group: %s", nodeElement.getGroup())); for (ComputeMetadata node : Iterables.filter(computeService.listNodesDetailsMatching(NodePredicates.all()), NodePredicates.inGroup(nodeElement.getGroup()))) { logDetails(computeService, node); } } }
@Override public boolean apply(ZoneAndName input) { // new nodes can have the zone as their location, existing nodes, the parent is the // location return all(computeService.listNodesDetailsMatching(Predicates.<ComputeMetadata> or(locationId(input.getZone()), parentLocationId(input.getZone()))), and(inGroup(input.getName()), TERMINATED)); } }
@Override public boolean apply(RegionAndName input) { // new nodes can have the region as their location, existing nodes, the parent is the // location return all(computeService.listNodesDetailsMatching(Predicates.<ComputeMetadata> or(locationId(input.getRegion()), parentLocationId(input.getRegion()))), Predicates.and(inGroup(input.getName()), TERMINATED)); } }
@Override public boolean apply(ZoneAndName input) { // new nodes can have the zone as their location, existing nodes, the parent is the // location return all(computeService.listNodesDetailsMatching(Predicates.<ComputeMetadata> or(locationId(input.getZone()), parentLocationId(input.getZone()))), and(inGroup(input.getName()), TERMINATED)); } }
@Override public boolean apply(RegionAndName input) { // new nodes can have the region as their location, existing nodes, the parent is the // location return all(computeService.listNodesDetailsMatching(Predicates.<ComputeMetadata> or(locationId(input.getRegion()), parentLocationId(input.getRegion()))), and(inGroup(input.getName()), TERMINATED)); } }
@Override public boolean apply(ZoneAndName input) { // new nodes can have the zone as their location, existing nodes, the parent is the // location return all(computeService.listNodesDetailsMatching(Predicates.<ComputeMetadata> or(locationId(input.getZone()), parentLocationId(input.getZone()))), Predicates.and(inGroup(input.getName()), TERMINATED)); } }
@Override public boolean apply(RegionAndName input) { // new nodes can have the region as their location, existing nodes, the parent is the // location return all(computeService.listNodesDetailsMatching(Predicates.<ComputeMetadata> or(locationId(input.getRegion()), parentLocationId(input.getRegion()))), and(inGroup(input.getName()), TERMINATED)); } }
@Test(enabled = true, dependsOnMethods = { "testListNodes", "testGetNodesWithDetails", "testListNodesByIds" }) public void testDestroyNodes() { int toDestroy = refreshNodes().size(); Set<? extends NodeMetadata> destroyed = client.destroyNodesMatching(inGroup(group)); assertEquals(toDestroy, destroyed.size()); for (NodeMetadata node : filter(client.listNodesDetailsMatching(all()), inGroup(group))) { assert node.getStatus() == Status.TERMINATED : node; assert view.utils().credentialStore().get("node#" + node.getId()) == null : "credential should have been null for " + "node#" + node.getId(); } }
@Test(enabled = true, alwaysRun = true, dependsOnMethods = { "testListNodes", "testGetNodesWithDetails", "testListNodesByIds" }) public void testDestroyNodes() { int toDestroy = refreshNodes().size(); Set<? extends NodeMetadata> destroyed = client.destroyNodesMatching(inGroup(group)); assertEquals(toDestroy, destroyed.size()); waitGracePeriodForDestroyedNodes(); for (NodeMetadata node : filter(client.listNodesDetailsMatching(all()), inGroup(group))) { assert node.getStatus() == Status.TERMINATED : node; assert view.utils().credentialStore().get("node#" + node.getId()) == null : "credential should have been null for " + "node#" + node.getId(); } }