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.hadoop.hbase.master;
 
 
Stores the plan for the move of an individual region. Contains info for the region being moved, info for the server the region should be moved from, and info for the server the region should be moved to. The comparable implementation of this class compares only the region information and not the source/dest server info.
 
 public class RegionPlan implements Comparable<RegionPlan> {
   private final HRegionInfo hri;
   private final ServerName source;
   private ServerName dest;
 
   public static class RegionPlanComparator implements Comparator<RegionPlan>, Serializable {
 
     private static final long serialVersionUID = 4213207330485734853L;
 
     @Override
     public int compare(RegionPlan lRegionPlan r) {
       long diff = r.getRegionInfo().getRegionId() - l.getRegionInfo().getRegionId();
       if (diff < 0) return -1;
       if (diff > 0) return 1;
       return 0;
     }
   }

  
Instantiate a plan for a region move, moving the specified region from the specified source server to the specified destination server. Destination server can be instantiated as null and later set with setDestination(org.apache.hadoop.hbase.ServerName).

Parameters:
hri region to be moved
source regionserver region should be moved from
dest regionserver region should be moved to
 
   public RegionPlan(final HRegionInfo hriServerName sourceServerName dest) {
     this. = hri;
     this. = source;
     this. = dest;
   }

  
Set the destination server for the plan for this region.
 
   public void setDestination(ServerName dest) {
     this. = dest;
   }

  
Get the source server for the plan for this region.

Returns:
server info for source
 
   public ServerName getSource() {
     return ;
   }

  
Get the destination server for the plan for this region.

Returns:
server info for destination
 
   public ServerName getDestination() {
     return ;
   }

  
Get the encoded region name for the region this plan is for.

Returns:
Encoded region name
  public String getRegionName() {
    return this..getEncodedName();
  }
  public HRegionInfo getRegionInfo() {
    return this.;
  }

  
Compare the region info.

Parameters:
o region plan you are comparing against
  public int compareTo(RegionPlan o) {
    return getRegionName().compareTo(o.getRegionName());
  }
  public boolean equals(Object obj) {
    if (this == obj) {
      return true;
    }
    if (obj == null || getClass() != obj.getClass()) {
      return false;
    }
    RegionPlan other = (RegionPlanobj;
    return compareTo(other) == 0;
  }
  public String toString() {
    return "hri=" + this..getRegionNameAsString() + ", src=" +
      (this. == null""this..toString()) +
      ", dest=" + (this. == null""this..toString());
  }
New to GrepCode? Check out our FAQ X