hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jxi...@apache.org
Subject svn commit: r1374423 - in /hbase/trunk/hbase-server/src/main: java/org/apache/hadoop/hbase/master/HMaster.java java/org/apache/hadoop/hbase/master/RegionStates.java ruby/shell/commands/assign.rb
Date Fri, 17 Aug 2012 20:28:33 GMT
Author: jxiang
Date: Fri Aug 17 20:28:32 2012
New Revision: 1374423

URL: http://svn.apache.org/viewvc?rev=1374423&view=rev
Log:
HBASE-6487 assign region doesn't check if the region is already assigned

Modified:
    hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
    hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/RegionStates.java
    hbase/trunk/hbase-server/src/main/ruby/shell/commands/assign.rb

Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java?rev=1374423&r1=1374422&r2=1374423&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java (original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java Fri
Aug 17 20:28:32 2012
@@ -2085,8 +2085,13 @@ Server {
         LOG.warn("assignRegion specifier type: expected: " + RegionSpecifierType.REGION_NAME
           + " actual: " + type);
       }
-      HRegionInfo regionInfo = assignmentManager.getRegionStates().getRegionInfo(regionName);
+      RegionStates regionStates = assignmentManager.getRegionStates();
+      HRegionInfo regionInfo = regionStates.getRegionInfo(regionName);
       if (regionInfo == null) throw new UnknownRegionException(Bytes.toString(regionName));
+      RegionState regionState = regionStates.getRegionState(regionInfo);
+      if (regionState != null && !regionState.isOffline()) {
+        throw new IOException("Region " + regionInfo + " is not offline");
+      }
       if (cpHost != null) {
         if (cpHost.preAssign(regionInfo)) {
           return arr;

Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/RegionStates.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/RegionStates.java?rev=1374423&r1=1374422&r2=1374423&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/RegionStates.java
(original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/RegionStates.java
Fri Aug 17 20:28:32 2012
@@ -133,6 +133,13 @@ public class RegionStates {
   }
 
   /**
+   * @return the server the specified region assigned to; null if not assigned.
+   */
+  public synchronized ServerName getAssignedServer(final HRegionInfo hri) {
+    return regionAssignments.get(hri);
+  }
+
+  /**
    * Wait for the state map to be updated by assignment manager.
    */
   public synchronized void waitForUpdate(
@@ -519,7 +526,11 @@ public class RegionStates {
     try {
       Pair<HRegionInfo, ServerName> p =
         MetaReader.getRegion(server.getCatalogTracker(), regionName);
-      return p == null ? null : p.getFirst();
+      HRegionInfo hri = p == null ? null : p.getFirst();
+      if (hri != null) {
+        createRegionState(hri);
+      }
+      return hri;
     } catch (IOException e) {
       server.abort("Aborting because error occoured while reading " +
         Bytes.toStringBinary(regionName) + " from .META.", e);

Modified: hbase/trunk/hbase-server/src/main/ruby/shell/commands/assign.rb
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/ruby/shell/commands/assign.rb?rev=1374423&r1=1374422&r2=1374423&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/ruby/shell/commands/assign.rb (original)
+++ hbase/trunk/hbase-server/src/main/ruby/shell/commands/assign.rb Fri Aug 17 20:28:32 2012
@@ -24,8 +24,7 @@ module Shell
       def help
         return <<-EOF
 Assign a region.Use with caution.If region already assigned,
-this command will just go ahead and reassign
-the region anyways. For experts only.
+this command will throw an exception. For experts only.
 EOF
       end
 



Mime
View raw message