Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
 
 
 package org.apache.whirr;
 
 import static com.google.common.base.Preconditions.checkArgument;
 import static com.google.common.base.Preconditions.checkNotNull;
 
 
 import java.util.Set;
 
This class represents a real cluster of Cluster.Instances.
 
 public class Cluster {
  
  
This class represents a real node running in a cluster. An instance has one or more roles.

 
   public static class Instance {
     private final Credentials loginCredentials;
     private final Set<Stringroles;
     private final String publicIp;
     private String publicHostName;
     private final String privateIp;
     private String privateHostName;
     private final String id;
     private final NodeMetadata nodeMetadata;
 
     public Instance(Credentials loginCredentialsSet<StringrolesString publicIp,
         String privateIpString idNodeMetadata nodeMetadata) {
       this. = checkNotNull(loginCredentials"loginCredentials");
       this. = checkNotNull(roles"roles");
       this. = checkNotNull(publicIp"publicIp");
       checkArgument(InetAddresses.isInetAddress(publicIp),
           "invalid IP address: %s"publicIp);
       this. = checkNotNull(privateIp"privateIp");
       checkArgument(InetAddresses.isInetAddress(privateIp),
           "invalid IP address: %s"privateIp);
       this. = checkNotNull(id"id");
       this. = nodeMetadata;
     }
 
     public Credentials getLoginCredentials() {
       return ;
     }
     
     public Set<StringgetRoles() {
       return ;
     }
 
     public InetAddress getPublicAddress() throws IOException {
       return resolveIpAddress(getPublicIp(), getPublicHostName());
     }
 
     public InetAddress getPrivateAddress() throws IOException {
       return resolveIpAddress(getPrivateIp(), getPrivateHostName());
     }
     
     private InetAddress resolveIpAddress(String ipString hostthrows IOException {
       byte[] addr = InetAddresses.forString(ip).getAddress();
       return InetAddress.getByAddress(hostaddr);
     }
     
     public String getPublicIp() {
       return ;
     }
     
    public synchronized String getPublicHostName() throws IOException {
      if ( == null) {
         = DnsUtil.resolveAddress();
      }
      return ;
    }
    
    public String getPrivateIp() {
      return ;
    }
    
    public synchronized String getPrivateHostName() throws IOException {
      if ( == null) {
         = DnsUtil.resolveAddress();
      }
      return ;
    }
    
    public String getId() {
      return ;
    }
    
    public NodeMetadata getNodeMetadata() {
      return ;
    }
    
    public String toString() {
      return Objects.toStringHelper(this)
        .add("roles")
        .add("publicIp")
        .add("privateIp")
        .add("id")
        .add("nodeMetadata")
        .toString();
    }
  }
  private Set<Instanceinstances;
  public Cluster(Set<Instanceinstances) {
    this(instancesnew Properties());
  }
  public Cluster(Set<InstanceinstancesProperties configuration) {
    this. = instances;
    this. = configuration;
  }
  
  public Set<InstancegetInstances() {
    return ;
  }  
    return ;
  }
  public Instance getInstanceMatching(Predicate<Instancepredicate) {
    return Iterables.getOnlyElement(Sets.filter(predicate));
  }
  public Set<InstancegetInstancesMatching(Predicate<Instancepredicate) {
    return Sets.filter(predicate);
  }
  public void removeInstancesMatching(Predicate<Instancepredicate) {
     = Sets.filter(, Predicates.not(predicate));
  }
  public String toString() {
    return Objects.toStringHelper(this)
      .add("instances")
      .add("configuration")
      .toString();
  }
  
New to GrepCode? Check out our FAQ X