hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r661211 - in /hadoop/hbase/trunk: ./ src/java/org/apache/hadoop/hbase/client/ src/java/org/apache/hadoop/hbase/ipc/ src/java/org/apache/hadoop/hbase/regionserver/ src/test/org/apache/hadoop/hbase/util/
Date Thu, 29 May 2008 04:54:27 GMT
Author: stack
Date: Wed May 28 21:54:27 2008
New Revision: 661211

URL: http://svn.apache.org/viewvc?rev=661211&view=rev
Log:
HBASE-640 TestMigrate failing on hudson

Modified:
    hadoop/hbase/trunk/CHANGES.txt
    hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/HConnectionManager.java
    hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/ipc/HRegionInterface.java
    hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HStore.java
    hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/util/TestMigrate.java

Modified: hadoop/hbase/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/CHANGES.txt?rev=661211&r1=661210&r2=661211&view=diff
==============================================================================
--- hadoop/hbase/trunk/CHANGES.txt (original)
+++ hadoop/hbase/trunk/CHANGES.txt Wed May 28 21:54:27 2008
@@ -28,6 +28,7 @@
                write-ahead-log edits
    HBASE-646   EOFException opening HStoreFile info file (spin on HBASE-645and 550)
    HBASE-648   If mapfile index is empty, run repair
+   HBASE-640   TestMigrate failing on hudson
 
   IMPROVEMENTS
    HBASE-559   MR example job to count table rows

Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/HConnectionManager.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/HConnectionManager.java?rev=661211&r1=661210&r2=661211&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/HConnectionManager.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/HConnectionManager.java Wed
May 28 21:54:27 2008
@@ -69,7 +69,7 @@
   // Note that although the Map is synchronized, the objects it contains
   // are mutable and hence require synchronized access to them
   private static final Map<String, TableServers> HBASE_INSTANCES =
-    Collections.synchronizedMap(new HashMap<String, TableServers>());
+    new ConcurrentHashMap<String, TableServers>();
 
   /**
    * Get the connection object for the instance specified by the configuration
@@ -81,9 +81,7 @@
     TableServers connection;
     synchronized (HBASE_INSTANCES) {
       String instanceName = conf.get(HBASE_DIR);
-
       connection = HBASE_INSTANCES.get(instanceName);
-
       if (connection == null) {
         connection = new TableServers(conf);
         HBASE_INSTANCES.put(instanceName, connection);
@@ -121,11 +119,12 @@
     private volatile HBaseConfiguration conf;
     
     // Known region HServerAddress.toString() -> HRegionInterface 
-    private Map<String, HRegionInterface> servers;
+    private final Map<String, HRegionInterface> servers =
+      new ConcurrentHashMap<String, HRegionInterface>();
 
     private HRegionLocation rootRegionLocation; 
     
-    private Map<Integer, SoftSortedMap<byte [], HRegionLocation>> 
+    private final Map<Integer, SoftSortedMap<byte [], HRegionLocation>> 
       cachedRegionLocations = Collections.synchronizedMap(
          new HashMap<Integer, SoftSortedMap<byte [], HRegionLocation>>());
     
@@ -156,7 +155,6 @@
       
       this.master = null;
       this.masterChecked = false;
-      this.servers = new ConcurrentHashMap<String, HRegionInterface>();
     }
     
     /** {@inheritDoc} */
@@ -596,15 +594,12 @@
     }
     
     /** {@inheritDoc} */
-    public HRegionInterface getHRegionConnection(
-      HServerAddress regionServer) 
+    public HRegionInterface getHRegionConnection(HServerAddress regionServer) 
     throws IOException {
-
       HRegionInterface server;
       synchronized (this.servers) {
         // See if we already have a connection
         server = this.servers.get(regionServer.toString());
-
         if (server == null) { // Get a connection
           long versionId = 0;
           try {
@@ -643,11 +638,8 @@
      */
     private HRegionLocation locateRootRegion()
     throws IOException {
-    
       getMaster();
-      
       HServerAddress rootRegionAddress = null;
-      
       for (int tries = 0; tries < numRetries; tries++) {
         int localTimeouts = 0;
         
@@ -669,12 +661,12 @@
             localTimeouts++;
           }
         }
-        
+
         if (rootRegionAddress == null) {
           throw new NoServerForRegionException(
               "Timed out trying to locate root region");
         }
-        
+
         // get a connection to the region server
         HRegionInterface server = getHRegionConnection(rootRegionAddress);
 

Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/ipc/HRegionInterface.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/ipc/HRegionInterface.java?rev=661211&r1=661210&r2=661211&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/ipc/HRegionInterface.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/ipc/HRegionInterface.java Wed May
28 21:54:27 2008
@@ -92,7 +92,7 @@
   public Cell[] get(final byte [] regionName, final byte [] row,
     final byte [] column, final long timestamp, final int numVersions)
   throws IOException;
-  
+
   /**
    * Get all the data for the specified row at a given timestamp
    * 
@@ -213,7 +213,7 @@
    * @throws IOException
    */
   public long openScanner(final byte [] regionName, final byte [][] columns,
-      final byte []startRow, long timestamp, RowFilterInterface filter)
+      final byte [] startRow, long timestamp, RowFilterInterface filter)
   throws IOException;
 
   /**

Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HStore.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HStore.java?rev=661211&r1=661210&r2=661211&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HStore.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HStore.java Wed May 28
21:54:27 2008
@@ -1307,7 +1307,7 @@
 
   /**
    * Get the value for the indicated HStoreKey.  Grab the target value and the 
-   * previous 'numVersions-1' values, as well.
+   * previous <code>numVersions - 1</code> values, as well.
    *
    * Use {@link HConstants.ALL_VERSIONS} to retrieve all versions.
    * @param key

Modified: hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/util/TestMigrate.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/util/TestMigrate.java?rev=661211&r1=661210&r2=661211&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/util/TestMigrate.java (original)
+++ hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/util/TestMigrate.java Wed May 28 21:54:27
2008
@@ -130,10 +130,13 @@
     // created earlier when no master was around.  The fact that there was no
     // master gets cached.  Need to delete so we go get master afresh.
     HConnectionManager.deleteConnection(this.conf);
+    
     LOG.info("Start a cluster against migrated FS");
     // Up number of retries.  Needed while cluster starts up. Its been set to 1
     // above.
-    this.conf.setInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER_KEY, 3);
+    final int retries = 5;
+    this.conf.setInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER_KEY, retries);
+    
     MiniHBaseCluster cluster = new MiniHBaseCluster(this.conf, 1);
     try {
       HBaseAdmin hb = new HBaseAdmin(this.conf);
@@ -147,15 +150,11 @@
         }
       }
       assertTrue(foundTable);
-      LOG.info(TABLENAME + " exists.  Creating an HTable to go against " +
-        TABLENAME + " and master " + this.conf.get(HConstants.MASTER_ADDRESS));
+      LOG.info(TABLENAME + " exists.  Now waiting till startcode " +
+        "changes before opening a scanner");
+      waitOnStartCodeChange(retries);
       HTable t = new HTable(this.conf, TABLENAME);
       int count = 0;
-      try {
-        Thread.sleep(10000);
-      } catch (InterruptedException e) {
-        e.printStackTrace();
-      }
       LOG.info("OPENING SCANNER");
       Scanner s = t.getScanner(TABLENAME_COLUMNS);
       try {
@@ -177,6 +176,45 @@
     }
   }
 
+  /*
+   * Wait till the startcode changes before we put up a scanner.  Otherwise
+   * we tend to hang, at least on hudson and I've had it time to time on
+   * my laptop.  The hang is down in RPC Client doing its call.  It
+   * never returns though the socket has a read timeout of 60 seconds by
+   * default. St.Ack
+   * @param retries How many retries to run.
+   * @throws IOException
+   */
+  private void waitOnStartCodeChange(final int retries) throws IOException {
+    HTable m = new HTable(this.conf, HConstants.META_TABLE_NAME);
+    // This is the start code that is in the old data.
+    long oldStartCode = 1199736332062L;
+    // This is the first row for the TestTable that is in the old data.
+    byte [] row = Bytes.toBytes("TestUpgrade,,1199736362468");
+    long pause = conf.getLong("hbase.client.pause", 5 * 1000);
+    long startcode = -1;
+    boolean changed = false;
+    for (int i = 0; i < retries; i++) {
+      startcode = Writables.cellToLong(m.get(row, HConstants.COL_STARTCODE));
+      if (startcode != oldStartCode) {
+        changed = true;
+        break;
+      }
+      if ((i + 1) != retries) {
+        try {
+          Thread.sleep(pause);
+        } catch (InterruptedException e) {
+          // continue
+        }
+      }
+    }
+    // If after all attempts startcode has not changed, fail.
+    if (!changed) {
+      throw new IOException("Startcode didn't change after " + retries +
+        " attempts");
+    }
+  }
+
   private void unzip(ZipInputStream zip, FileSystem dfs, Path root)
   throws IOException {
     ZipEntry e = null;



Mime
View raw message