hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From te...@apache.org
Subject svn commit: r1173811 - in /hbase/trunk/src: main/java/org/apache/hadoop/hbase/client/ main/java/org/apache/hadoop/hbase/master/ main/java/org/apache/hadoop/hbase/regionserver/ test/java/org/apache/hadoop/hbase/master/ test/java/org/apache/hadoop/hbase/...
Date Wed, 21 Sep 2011 19:48:38 GMT
Author: tedyu
Date: Wed Sep 21 19:48:38 2011
New Revision: 1173811

URL: http://svn.apache.org/viewvc?rev=1173811&view=rev
Log:
HBASE-4153 apply the correct patch - v4

Modified:
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/RegionAlreadyInTransitionException.java
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/RegionServerServices.java
    hbase/trunk/src/test/java/org/apache/hadoop/hbase/master/TestZKBasedOpenCloseRegion.java
    hbase/trunk/src/test/java/org/apache/hadoop/hbase/regionserver/handler/MockRegionServerServices.java
    hbase/trunk/src/test/java/org/apache/hadoop/hbase/regionserver/handler/TestOpenRegionHandler.java

Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java?rev=1173811&r1=1173810&r2=1173811&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java (original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java Wed Sep 21 19:48:38
2011
@@ -1311,6 +1311,8 @@ public class HBaseAdmin implements Abort
   }
 
   /**
+   * Tries to assign a region. Region could be reassigned to the same server.
+   * 
    * @param regionName
    *          Region name to assign.
    * @param force

Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java?rev=1173811&r1=1173810&r2=1173811&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java (original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java Wed Sep
21 19:48:38 2011
@@ -64,7 +64,6 @@ import org.apache.hadoop.hbase.regionser
 import org.apache.hadoop.hbase.regionserver.RegionOpeningState;
 import org.apache.hadoop.hbase.ipc.ServerNotRunningYetException;
 import org.apache.hadoop.hbase.master.RegionPlan;
-import org.apache.hadoop.hbase.master.AssignmentManager.RegionState.State;
 import org.apache.hadoop.hbase.master.handler.ClosedRegionHandler;
 import org.apache.hadoop.hbase.master.handler.DisableTableHandler;
 import org.apache.hadoop.hbase.master.handler.EnableTableHandler;
@@ -164,9 +163,6 @@ public class AssignmentManager extends Z
 
   //Thread pool executor service for timeout monitor
   private java.util.concurrent.ExecutorService threadPoolExecutorService;
-  //String to compare the RegionsAlreadyInTransition from RS
-  private static final String ALREADY_TRANSITIONING = "for the region we are " +
-  	"already trying to ";
 
   /**
    * Constructs a new assignment manager.
@@ -1457,13 +1453,10 @@ public class AssignmentManager extends Z
         if (t instanceof RemoteException) {
           t = ((RemoteException) t).unwrapRemoteException();
           if (t instanceof RegionAlreadyInTransitionException) {
-            String errorMsg = "Failed assignment of " +
-              state.getRegion().getRegionNameAsString() + " to " +
-              plan.getDestination() + " as the region was already " +
-              extractRegionState((RegionAlreadyInTransitionException) t) +
-              " in the RS " +plan.getDestination();
+            String errorMsg = "Failed assignment in: " + plan.getDestination()
+                + " due to " + t.getMessage();
             LOG.error(errorMsg, t);
-            return;            
+            return;
           }
         LOG.warn("Failed assignment of " +
           state.getRegion().getRegionNameAsString() + " to " +
@@ -1484,13 +1477,6 @@ public class AssignmentManager extends Z
    }
   }
 
-  private State extractRegionState(RegionAlreadyInTransitionException t) {
-    RegionState.State state = t.getMessage().contains(
-        ALREADY_TRANSITIONING + "OPEN") ? RegionState.State.PENDING_OPEN
-        : RegionState.State.PENDING_CLOSE;
-    return state;
-  }
-  
   private void debugLog(HRegionInfo region, String string) {
     if (region.isMetaTable() || region.isRootRegion()) {
       LOG.info(string);

Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java?rev=1173811&r1=1173810&r2=1173811&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java (original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java Wed
Sep 21 19:48:38 2011
@@ -44,7 +44,6 @@ import java.util.SortedMap;
 import java.util.TreeMap;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentSkipListMap;
-import java.util.concurrent.ConcurrentSkipListSet;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.locks.ReentrantReadWriteLock;
@@ -101,7 +100,6 @@ import org.apache.hadoop.hbase.filter.Wr
 import org.apache.hadoop.hbase.io.hfile.BlockCache;
 import org.apache.hadoop.hbase.io.hfile.BlockCacheColumnFamilySummary;
 import org.apache.hadoop.hbase.io.hfile.CacheStats;
-import org.apache.hadoop.hbase.io.hfile.LruBlockCache;
 import org.apache.hadoop.hbase.ipc.CoprocessorProtocol;
 import org.apache.hadoop.hbase.ipc.HBaseRPC;
 import org.apache.hadoop.hbase.ipc.HBaseRPCErrorHandler;
@@ -313,13 +311,10 @@ public class HRegionServer implements HR
 
   /*
    * Strings to be used in forming the exception message for
-   * RegionsAlreadyInTransitionException. The below strings combination  
-   * is used to extract the status in the master. 
+   * RegionsAlreadyInTransitionException.
    */
-  private static final String ALREADY_TRANSITIONING = "for the region we are already trying
to ";
-  private static final String RECEIVED = " received ";
-  private static final String OPEN = "OPEN ";
-  private static final String CLOSE = "CLOSE ";
+  private static final String OPEN = "OPEN";
+  private static final String CLOSE = "CLOSE";
 
   /**
    * Starts a HRegionServer at the default location
@@ -2367,7 +2362,7 @@ public class HRegionServer implements HR
   public RegionOpeningState openRegion(HRegionInfo region, int versionOfOfflineNode)
       throws IOException {
     checkOpen();
-    checkIfRegionInTransition(region,OPEN);
+    checkIfRegionInTransition(region, OPEN);
     HRegion onlineRegion = this.getFromOnlineRegions(region.getEncodedName());
     if (null != onlineRegion) {
       LOG.warn("Attempted open of " + region.getEncodedName()
@@ -2395,23 +2390,17 @@ public class HRegionServer implements HR
   
   private void checkIfRegionInTransition(HRegionInfo region,
       String currentAction) throws RegionAlreadyInTransitionException {
-
     byte[] encodedName = region.getEncodedNameAsBytes();
     if (this.regionsInTransitionInRS.containsKey(encodedName)) {
+      boolean openAction = this.regionsInTransitionInRS.get(encodedName);
       // The below exception message will be used in master.
-      throw new RegionAlreadyInTransitionException(getExceptionMessage(region,
-          encodedName, currentAction));
+      throw new RegionAlreadyInTransitionException("Received:" + currentAction + 
+        " for the region:" + region.getRegionNameAsString() +
+        " ,which we are already trying to " + 
+        (openAction ? OPEN : CLOSE)+ ".");
     }
   }
 
-  private String getExceptionMessage(HRegionInfo region, byte[] encodedName,
-      String receivedAction) {
-    boolean openAction = this.regionsInTransitionInRS.get(encodedName);
-    return REGIONSERVER + ":" + this.getServerName() + RECEIVED
-        + receivedAction + ALREADY_TRANSITIONING + (openAction ? OPEN : CLOSE)
-        + "; " + region.getRegionNameAsString();
-  }
-
   @Override
   @QosPriority(priority=HIGH_QOS)
   public void openRegions(List<HRegionInfo> regions)

Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/RegionAlreadyInTransitionException.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/RegionAlreadyInTransitionException.java?rev=1173811&r1=1173810&r2=1173811&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/RegionAlreadyInTransitionException.java
(original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/RegionAlreadyInTransitionException.java
Wed Sep 21 19:48:38 2011
@@ -30,4 +30,5 @@ public class RegionAlreadyInTransitionEx
   public RegionAlreadyInTransitionException(String s) {
     super(s);
   }
+  
 }

Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/RegionServerServices.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/RegionServerServices.java?rev=1173811&r1=1173810&r2=1173811&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/RegionServerServices.java
(original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/RegionServerServices.java
Wed Sep 21 19:48:38 2011
@@ -78,4 +78,5 @@ public interface RegionServerServices ex
    * @return map of regions in transition in this RS
    */
   public ConcurrentSkipListMap<byte[], Boolean> getRegionsInTransitionInRS();
-}
+  
+}

Modified: hbase/trunk/src/test/java/org/apache/hadoop/hbase/master/TestZKBasedOpenCloseRegion.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/test/java/org/apache/hadoop/hbase/master/TestZKBasedOpenCloseRegion.java?rev=1173811&r1=1173810&r2=1173811&view=diff
==============================================================================
--- hbase/trunk/src/test/java/org/apache/hadoop/hbase/master/TestZKBasedOpenCloseRegion.java
(original)
+++ hbase/trunk/src/test/java/org/apache/hadoop/hbase/master/TestZKBasedOpenCloseRegion.java
Wed Sep 21 19:48:38 2011
@@ -50,7 +50,7 @@ import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
 /**

Modified: hbase/trunk/src/test/java/org/apache/hadoop/hbase/regionserver/handler/MockRegionServerServices.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/test/java/org/apache/hadoop/hbase/regionserver/handler/MockRegionServerServices.java?rev=1173811&r1=1173810&r2=1173811&view=diff
==============================================================================
--- hbase/trunk/src/test/java/org/apache/hadoop/hbase/regionserver/handler/MockRegionServerServices.java
(original)
+++ hbase/trunk/src/test/java/org/apache/hadoop/hbase/regionserver/handler/MockRegionServerServices.java
Wed Sep 21 19:48:38 2011
@@ -19,9 +19,7 @@ package org.apache.hadoop.hbase.regionse
 
 import java.io.IOException;
 import java.util.HashMap;
-import java.util.HashSet;
 import java.util.Map;
-import java.util.Set;
 import java.util.concurrent.ConcurrentSkipListMap;
 
 import org.apache.hadoop.conf.Configuration;
@@ -135,10 +133,10 @@ class MockRegionServerServices implement
   public boolean isStopped() {
     return false;
   }
-}
-  @Override
+}
  @Override
   public boolean isAborted() {
     // TODO Auto-generated method stub
     return false;
   }
+  
 }

Modified: hbase/trunk/src/test/java/org/apache/hadoop/hbase/regionserver/handler/TestOpenRegionHandler.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/test/java/org/apache/hadoop/hbase/regionserver/handler/TestOpenRegionHandler.java?rev=1173811&r1=1173810&r2=1173811&view=diff
==============================================================================
--- hbase/trunk/src/test/java/org/apache/hadoop/hbase/regionserver/handler/TestOpenRegionHandler.java
(original)
+++ hbase/trunk/src/test/java/org/apache/hadoop/hbase/regionserver/handler/TestOpenRegionHandler.java
Wed Sep 21 19:48:38 2011
@@ -132,7 +132,7 @@ public class TestOpenRegionHandler {
   @Test
   public void testFailedOpenRegion() throws Exception {
     Server server = new MockServer(HTU);
-    RegionServerServices rsServices = new MockRegionServerServices();
+    RegionServerServices rsServices = Mockito.mock(RegionServerServices.class);
 
     // Create it OFFLINE, which is what it expects
     ZKAssign.createNodeOffline(server.getZooKeeper(), TEST_HRI, server.getServerName());
@@ -157,7 +157,7 @@ public class TestOpenRegionHandler {
   @Test
   public void testFailedUpdateMeta() throws Exception {
     Server server = new MockServer(HTU);
-    RegionServerServices rsServices = new MockRegionServerServices();
+    RegionServerServices rsServices = Mockito.mock(RegionServerServices.class);
 
     // Create it OFFLINE, which is what it expects
     ZKAssign.createNodeOffline(server.getZooKeeper(), TEST_HRI, server.getServerName());



Mime
View raw message