Search in sources :

Example 6 with ComputeMetadata

use of org.jclouds.compute.domain.ComputeMetadata in project SimianArmy by Netflix.

the class AWSClient method getJcloudsNode.

private NodeMetadata getJcloudsNode(ComputeService computeService, String jcloudsId) {
    // Work around a jclouds bug / documentation issue...
    // TODO: Figure out what's broken, and eliminate this function
    // This should work (?):
    // Set<NodeMetadata> nodes = computeService.listNodesByIds(Collections.singletonList(jcloudsId));
    Set<NodeMetadata> nodes = Sets.newHashSet();
    for (ComputeMetadata n : computeService.listNodes()) {
        if (jcloudsId.equals(n.getId())) {
            nodes.add((NodeMetadata) n);
        }
    }
    if (nodes.isEmpty()) {
        LOGGER.warn("Unable to find jclouds node: {}", jcloudsId);
        for (ComputeMetadata n : computeService.listNodes()) {
            LOGGER.info("Did find node: {}", n);
        }
        throw new IllegalStateException("Unable to find node using jclouds: " + jcloudsId);
    }
    NodeMetadata node = Iterables.getOnlyElement(nodes);
    return node;
}
Also used : NodeMetadata(org.jclouds.compute.domain.NodeMetadata) ComputeMetadata(org.jclouds.compute.domain.ComputeMetadata)

Example 7 with ComputeMetadata

use of org.jclouds.compute.domain.ComputeMetadata in project acceptance-test-harness by jenkinsci.

the class JcloudsMachineProvider method getRunningInstances.

private Set<NodeMetadata> getRunningInstances() {
    logger.info(String.format("Check if we already got running machines in the security group: %s... ", getGroupName()));
    Set<? extends NodeMetadata> nodeMetadatas = computeService.listNodesDetailsMatching(new Predicate<ComputeMetadata>() {

        @Override
        public boolean apply(ComputeMetadata computeMetadata) {
            return true;
        }
    });
    Set<NodeMetadata> filteredNodes = new HashSet<>();
    for (NodeMetadata nm : nodeMetadatas) {
        if (getGroupName().equals(nm.getGroup()) && nm.getStatus() == NodeMetadata.Status.RUNNING) {
            logger.info(String.format("Found running machine: %s", getGroupName()));
            filteredNodes.add(nm);
        }
    }
    return filteredNodes;
}
Also used : NodeMetadata(org.jclouds.compute.domain.NodeMetadata) ComputeMetadata(org.jclouds.compute.domain.ComputeMetadata)

Aggregations

ComputeMetadata (org.jclouds.compute.domain.ComputeMetadata)7 NodeMetadata (org.jclouds.compute.domain.NodeMetadata)5 IOException (java.io.IOException)3 ComputeServiceContext (org.jclouds.compute.ComputeServiceContext)3 Predicate (com.google.common.base.Predicate)2 IgniteInterruptedCheckedException (org.apache.ignite.internal.IgniteInterruptedCheckedException)2 IgniteSpiException (org.apache.ignite.spi.IgniteSpiException)2 InetSocketAddress (java.net.InetSocketAddress)1 DecimalFormat (java.text.DecimalFormat)1 HashSet (java.util.HashSet)1 LinkedList (java.util.LinkedList)1 Properties (java.util.Properties)1 Set (java.util.Set)1 TreeSet (java.util.TreeSet)1 ExecutionException (java.util.concurrent.ExecutionException)1 Future (java.util.concurrent.Future)1 Cluster (org.apache.whirr.Cluster)1 Instance (org.apache.whirr.Cluster.Instance)1 ClusterSpec (org.apache.whirr.ClusterSpec)1 InstanceTemplate (org.apache.whirr.InstanceTemplate)1