hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r942184 [10/15] - in /hadoop/hbase/branches/0.20: ./ src/java/org/apache/hadoop/hbase/ src/java/org/apache/hadoop/hbase/client/ src/java/org/apache/hadoop/hbase/filter/ src/java/org/apache/hadoop/hbase/io/ src/java/org/apache/hadoop/hbase/i...
Date Fri, 07 May 2010 19:17:55 GMT
Modified: hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/regionserver/HLog.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/regionserver/HLog.java?rev=942184&r1=942183&r2=942184&view=diff
==============================================================================
--- hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/regionserver/HLog.java (original)
+++ hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/regionserver/HLog.java Fri May  7 19:17:48 2010
@@ -75,7 +75,7 @@ import org.apache.hadoop.io.SequenceFile
 import org.apache.hadoop.io.compress.DefaultCodec;
 
 /**
- * HLog stores all the edits to the HStore. Its the hbase write-ahead-log   
+ * HLog stores all the edits to the HStore. Its the hbase write-ahead-log
  * implementation.
  *
  * It performs logfile-rolling, so external callers are not aware that the
@@ -128,7 +128,7 @@ public class HLog implements HConstants,
   private int initialReplication;    // initial replication factor of SequenceFile.writer
   private Method getNumCurrentReplicas; // refers to DFSOutputStream.getNumCurrentReplicas
   private final static Object [] NO_ARGS = new Object []{};
-  
+
   // used to indirectly tell syncFs to force the sync
   private boolean forceSync = false;
 
@@ -138,7 +138,7 @@ public class HLog implements HConstants,
   SequenceFile.Writer writer;
 
   /*
-   * Map of all log files but the current one. 
+   * Map of all log files but the current one.
    */
   final SortedMap<Long, Path> outputfiles =
     Collections.synchronizedSortedMap(new TreeMap<Long, Path>());
@@ -156,11 +156,11 @@ public class HLog implements HConstants,
 
   // The timestamp (in ms) when the log file was created.
   private volatile long filenum = -1;
-  
+
   //number of transactions in the current Hlog.
   private final AtomicInteger numEntries = new AtomicInteger(0);
 
-  // If > than this size, roll the log. This is typically 0.95 times the size 
+  // If > than this size, roll the log. This is typically 0.95 times the size
   // of the default Hdfs block size.
   private final long logrollsize;
 
@@ -173,7 +173,7 @@ public class HLog implements HConstants,
   private final Object updateLock = new Object();
 
   private final boolean enabled;
-   
+
   /*
    * If more than this many logs, force flush of oldest region to oldest edit
    * goes to disk.  If too many and we crash, then will take forever replaying.
@@ -274,8 +274,8 @@ public class HLog implements HConstants,
     this.getNumCurrentReplicas = null;
     if(this.hdfs_out != null) {
       try {
-        this.getNumCurrentReplicas = 
-          this.hdfs_out.getClass().getMethod("getNumCurrentReplicas", 
+        this.getNumCurrentReplicas =
+          this.hdfs_out.getClass().getMethod("getNumCurrentReplicas",
                                              new Class<?> []{});
         this.getNumCurrentReplicas.setAccessible(true);
       } catch (NoSuchMethodException e) {
@@ -290,7 +290,7 @@ public class HLog implements HConstants,
     } else {
       LOG.info("getNumCurrentReplicas--HDFS-826 not available" );
     }
-    
+
     // Test if syncfs is available.
     Method m = null;
     if (isAppend(conf)) {
@@ -306,7 +306,7 @@ public class HLog implements HConstants,
       }
     }
     this.syncfs = m;
-  
+
     logSyncerThread = new LogSyncer(this.optionalFlushInterval);
     Threads.setDaemonThreadRunning(logSyncerThread,
         Thread.currentThread().getName() + ".logSyncer");
@@ -328,7 +328,7 @@ public class HLog implements HConstants,
     // Compression makes no sense for commit log.  Always return NONE.
     return CompressionType.NONE;
   }
-  
+
   /**
    * Called by HRegionServer when it opens a new region to ensure that log
    * sequence numbers are always greater than the latest sequence number of the
@@ -345,7 +345,7 @@ public class HLog implements HConstants,
       LOG.debug("Change sequence number from " + logSeqNum + " to " + newvalue);
     }
   }
-  
+
   /**
    * @return log sequence number
    */
@@ -398,7 +398,7 @@ public class HLog implements HConstants,
           final Field field = writer.getClass().getDeclaredField("out");
           field.setAccessible(true);
           // get variable: writer.out
-          FSDataOutputStream writer_out = 
+          FSDataOutputStream writer_out =
             (FSDataOutputStream)field.get(writer);
           // writer's OutputStream: writer.out.getWrappedStream()
           // important: only valid for the lifetime of this.writer
@@ -409,7 +409,7 @@ public class HLog implements HConstants,
           LOG.error("Problem obtaining hdfs_out: " + ex);
           this.hdfs_out = null;
         }
-        
+
         LOG.info((oldFile != null?
             "Roll " + FSUtils.getPath(oldFile) + ", entries=" +
             this.numEntries.get() +
@@ -442,7 +442,7 @@ public class HLog implements HConstants,
   protected SequenceFile.Writer createWriter(Path path) throws IOException {
     return createWriter(path, HLogKey.class, WALEdit.class);
   }
-  
+
   // usage: see TestLogRolling.java
   OutputStream getOutputStream() {
     return this.hdfs_out;
@@ -457,7 +457,7 @@ public class HLog implements HConstants,
         SequenceFile.CompressionType.NONE, new DefaultCodec(), null,
         new Metadata());
   }
-  
+
   /*
    * Clean up old commit logs.
    * @return If lots of logs, flush the returned region so next time through
@@ -566,7 +566,7 @@ public class HLog implements HConstants,
         FailedLogCloseException flce =
           new FailedLogCloseException("#" + currentfilenum);
         flce.initCause(e);
-        throw e; 
+        throw e;
       }
       if (currentfilenum >= 0) {
         oldFile = computeFilename(currentfilenum);
@@ -632,7 +632,7 @@ public class HLog implements HConstants,
   }
 
    /** Append an entry to the log.
-   * 
+   *
    * @param regionInfo
    * @param logEdit
    * @param now Time of this edit write.
@@ -656,11 +656,11 @@ public class HLog implements HConstants,
   protected HLogKey makeKey(byte[] regionName, byte[] tableName, long seqnum, long now) {
     return new HLogKey(regionName, tableName, seqnum, now);
   }
-  
-  
-  
+
+
+
   /** Append an entry to the log.
-   * 
+   *
    * @param regionInfo
    * @param logEdit
    * @param logKey
@@ -749,13 +749,13 @@ public class HLog implements HConstants,
     * it happens.
     */
    class LogSyncer extends Thread {
- 
+
      // Using fairness to make sure locks are given in order
      private final ReentrantLock lock = new ReentrantLock(true);
 
      // Condition used to wait until we have something to sync
      private final Condition queueEmpty = lock.newCondition();
- 
+
     // Condition used to signal that the sync is done
     private final Condition syncDone = lock.newCondition();
 
@@ -774,7 +774,7 @@ public class HLog implements HConstants,
          // awaiting with a timeout doesn't always
          // throw exceptions on interrupt
          while(!this.isInterrupted()) {
- 
+
            // Wait until something has to be hflushed or do it if we waited
            // enough time (useful if something appends but does not hflush).
            // 0 or less means that it timed out and maybe waited a bit more.
@@ -782,12 +782,12 @@ public class HLog implements HConstants,
                    this.optionalFlushInterval*1000000) <= 0)) {
              forceSync = true;
            }
- 
+
            // We got the signal, let's hflush. We currently own the lock so new
            // writes are waiting to acquire it in addToSyncQueue while the ones
            // we hflush are waiting on await()
            hflush();
- 
+
            // Release all the clients waiting on the hflush. Notice that we still
            // own the lock until we get back to await at which point all the
            // other threads waiting will first acquire and release locks
@@ -805,13 +805,13 @@ public class HLog implements HConstants,
          LOG.info(getName() + " exiting");
        }
      }
- 
+
      /**
       * This method first signals the thread that there's a sync needed
       * and then waits for it to happen before returning.
       */
      public void addToSyncQueue(boolean force) {
- 
+
        // Don't bother if somehow our append was already hflush
        if (unflushedEntries.get() == 0) {
          return;
@@ -827,7 +827,7 @@ public class HLog implements HConstants,
          }
          // Wake the thread
          queueEmpty.signal();
- 
+
          // Wait for it to hflush
          syncDone.await();
        } catch (InterruptedException e) {
@@ -851,7 +851,7 @@ public class HLog implements HConstants,
   public void sync(boolean force) {
     logSyncerThread.addToSyncQueue(force);
   }
-  
+
   protected void hflush() throws IOException {
     synchronized (this.updateLock) {
       if (this.closed) {
@@ -867,7 +867,7 @@ public class HLog implements HConstants,
           this.writer.sync();
           if (this.syncfs != null) {
             try {
-             this.syncfs.invoke(this.writer, NO_ARGS); 
+             this.syncfs.invoke(this.writer, NO_ARGS);
             } catch (Exception e) {
               throw new IOException("Reflection", e);
             }
@@ -876,23 +876,23 @@ public class HLog implements HConstants,
           this.syncOps++;
           this.forceSync = false;
           this.unflushedEntries.set(0);
-            
-          // if the number of replicas in HDFS has fallen below the initial   
-          // value, then roll logs.   
+
+          // if the number of replicas in HDFS has fallen below the initial
+          // value, then roll logs.
           try {
             int numCurrentReplicas = getLogReplication();
-            if (numCurrentReplicas != 0 &&  
-                numCurrentReplicas < this.initialReplication) {  
-              LOG.warn("HDFS pipeline error detected. " +   
+            if (numCurrentReplicas != 0 &&
+                numCurrentReplicas < this.initialReplication) {
+              LOG.warn("HDFS pipeline error detected. " +
                   "Found " + numCurrentReplicas + " replicas but expecting " +
-                  this.initialReplication + " replicas. " +  
-                  " Requesting close of hlog.");  
+                  this.initialReplication + " replicas. " +
+                  " Requesting close of hlog.");
               requestLogRoll();
               logRollRequested = true;
-            } 
-          } catch (Exception e) {   
+            }
+          } catch (Exception e) {
               LOG.warn("Unable to invoke DFSOutputStream.getNumCurrentReplicas" + e +
-                       " still proceeding ahead...");  
+                       " still proceeding ahead...");
           }
         } catch (IOException e) {
           LOG.fatal("Could not append. Requesting close of hlog", e);
@@ -906,26 +906,26 @@ public class HLog implements HConstants,
       }
     }
   }
-  
+
   /**
    * This method gets the datanode replication count for the current HLog.
    *
-   * If the pipeline isn't started yet or is empty, you will get the default 
-   * replication factor.  Therefore, if this function returns 0, it means you 
+   * If the pipeline isn't started yet or is empty, you will get the default
+   * replication factor.  Therefore, if this function returns 0, it means you
    * are not properly running with the HDFS-826 patch.
-   * 
+   *
    * @throws Exception
    */
   int getLogReplication() throws Exception {
     if(this.getNumCurrentReplicas != null && this.hdfs_out != null) {
       Object repl = this.getNumCurrentReplicas.invoke(this.hdfs_out, NO_ARGS);
-      if (repl instanceof Integer) {  
-        return ((Integer)repl).intValue();  
+      if (repl instanceof Integer) {
+        return ((Integer)repl).intValue();
       }
     }
     return 0;
   }
-  
+
   boolean canGetCurReplicas() {
     return this.getNumCurrentReplicas != null;
   }
@@ -935,7 +935,7 @@ public class HLog implements HConstants,
       this.listener.logRollRequested();
     }
   }
-  
+
   private void doWrite(HLogKey logKey, WALEdit logEdit)
   throws IOException {
     if (!this.enabled) {
@@ -1029,7 +1029,7 @@ public class HLog implements HConstants,
         KeyValue edit = completeCacheFlushLogEdit();
         WALEdit edits = new WALEdit();
         edits.add(edit);
-        this.writer.append(makeKey(regionName, tableName, logSeqId, System.currentTimeMillis()), 
+        this.writer.append(makeKey(regionName, tableName, logSeqId, System.currentTimeMillis()),
           edits);
         writeTime += System.currentTimeMillis() - now;
         writeOps++;
@@ -1069,7 +1069,7 @@ public class HLog implements HConstants,
   public static boolean isMetaFamily(byte [] family) {
     return Bytes.equals(METAFAMILY, family);
   }
-  
+
   /**
    * Split up a bunch of regionserver commit log files that are no longer
    * being written to, into new files, one per region for region to replay on
@@ -1122,13 +1122,13 @@ public class HLog implements HConstants,
       this.w = w;
     }
   }
-  
+
   @SuppressWarnings("unchecked")
   public static Class<? extends HLogKey> getKeyClass(HBaseConfiguration conf) {
-    return (Class<? extends HLogKey>) 
+    return (Class<? extends HLogKey>)
        conf.getClass("hbase.regionserver.hlog.keyclass", HLogKey.class);
   }
-  
+
   public static HLogKey newKey(HBaseConfiguration conf) throws IOException {
     Class<? extends HLogKey> keyClass = getKeyClass(conf);
     try {
@@ -1139,7 +1139,7 @@ public class HLog implements HConstants,
       throw new IOException("cannot create hlog key");
     }
   }
-  
+
   /*
    * @param rootDir
    * @param logfiles
@@ -1156,13 +1156,13 @@ public class HLog implements HConstants,
       Collections.synchronizedMap(
         new TreeMap<byte [], WriterAndPath>(Bytes.BYTES_COMPARATOR));
     List<Path> splits = null;
-    
+
     // Number of threads to use when log splitting to rewrite the logs.
     // More means faster but bigger mem consumption.
     int logWriterThreads =
       conf.getInt("hbase.regionserver.hlog.splitlog.writer.threads", 3);
-    
-    // Number of logs to read into memory before writing to their appropriate 
+
+    // Number of logs to read into memory before writing to their appropriate
     // regions when log splitting.  More means faster but bigger mem consumption
     int logFilesPerStep =
       conf.getInt("hbase.regionserver.hlog.splitlog.reader.threads", 3);
@@ -1172,21 +1172,21 @@ public class HLog implements HConstants,
     final boolean appendSupport = isAppend(conf);
 
     // store corrupt logs for post-mortem analysis (empty string = discard)
-    final String corruptDir = 
+    final String corruptDir =
       conf.get("hbase.regionserver.hlog.splitlog.corrupt.dir", ".corrupt");
 
     List<Path> finishedFiles = new LinkedList<Path>();
     List<Path> corruptFiles = new LinkedList<Path>();
 
     try {
-      int maxSteps = Double.valueOf(Math.ceil((logfiles.length * 1.0) / 
+      int maxSteps = Double.valueOf(Math.ceil((logfiles.length * 1.0) /
           logFilesPerStep)).intValue();
       for (int step = 0; step < maxSteps; step++) {
-        
+
         // Step 1: read N log files into memory
-        final Map<byte[], LinkedList<HLogEntry>> logEntries = 
+        final Map<byte[], LinkedList<HLogEntry>> logEntries =
           new TreeMap<byte[], LinkedList<HLogEntry>>(Bytes.BYTES_COMPARATOR);
-        int endIndex = step == maxSteps - 1? logfiles.length: 
+        int endIndex = step == maxSteps - 1? logfiles.length:
           step * logFilesPerStep + logFilesPerStep;
         for (int i = (step * logFilesPerStep); i < endIndex; i++) {
           Path curLogFile = logfiles[i].getPath();
@@ -1229,7 +1229,7 @@ public class HLog implements HConstants,
               LOG.debug("IOE Pushed=" + count + " entries from " + curLogFile);
               e = RemoteExceptionHandler.checkIOException(e);
               if (!(e instanceof EOFException)) {
-                String msg = "Exception processing " + curLogFile + 
+                String msg = "Exception processing " + curLogFile +
                              " -- continuing. Possible DATA LOSS!";
                 if (corruptDir.length() > 0) {
                   msg += "  Storing in hlog corruption directory.";
@@ -1262,13 +1262,13 @@ public class HLog implements HConstants,
           }
         }
 
-        // Step 2: Some regionserver log files have been read into memory.  
+        // Step 2: Some regionserver log files have been read into memory.
         //         Assign them to the appropriate region directory.
         class ThreadWithException extends Thread {
           ThreadWithException(String name) { super(name); }
           public IOException exception = null;
         }
-        List<ThreadWithException> threadList = 
+        List<ThreadWithException> threadList =
           new ArrayList<ThreadWithException>(logEntries.size());
         ExecutorService threadPool =
           Executors.newFixedThreadPool(logWriterThreads);
@@ -1278,7 +1278,7 @@ public class HLog implements HConstants,
             public void run() {
               LinkedList<HLogEntry> entries = logEntries.get(region);
               LOG.debug("Thread got " + entries.size() + " to process");
-              if(entries.size() <= 0) { 
+              if(entries.size() <= 0) {
                 LOG.warn("Got a region with no entries to process.");
                 return;
               }
@@ -1292,20 +1292,20 @@ public class HLog implements HConstants,
                   // first write to this region, make new logfile
                   assert entries.size() > 0;
                   Path logfile = new Path(HRegion.getRegionDir(HTableDescriptor
-                      .getTableDir(rootDir, 
+                      .getTableDir(rootDir,
                                    entries.getFirst().getKey().getTablename()),
                       HRegionInfo.encodeRegionName(region)),
                       HREGION_OLDLOGFILE_NAME);
 
-                  // If splitLog() was running when the user restarted his 
-                  // cluster, then we could already have a 'logfile'. 
-                  // Since we don't delete logs until everything is written to 
+                  // If splitLog() was running when the user restarted his
+                  // cluster, then we could already have a 'logfile'.
+                  // Since we don't delete logs until everything is written to
                   // their respective regions, we can safely remove this tmp.
                   if (fs.exists(logfile)) {
-                    LOG.warn("Deleting old hlog file: " + logfile); 
+                    LOG.warn("Deleting old hlog file: " + logfile);
                     fs.delete(logfile, true);
                   }
-                  
+
                   // associate an OutputStream with this logfile
                   SequenceFile.Writer w =
                     SequenceFile.createWriter(fs, conf, logfile,
@@ -1317,7 +1317,7 @@ public class HLog implements HConstants,
                         + logfile + " and region " + Bytes.toStringBinary(region));
                   }
                 }
-                
+
                 // Items were added to the linkedlist oldest first. Pull them
                 // out in that order.
                 for (ListIterator<HLogEntry> i =
@@ -1327,7 +1327,7 @@ public class HLog implements HConstants,
                   wap.w.append(logEntry.getKey(), logEntry.getEdit());
                   count++;
                 }
-                
+
                 if (LOG.isDebugEnabled()) {
                   LOG.debug("Applied " + count + " total edits to "
                       + Bytes.toStringBinary(region) + " in "
@@ -1335,7 +1335,7 @@ public class HLog implements HConstants,
                 }
               } catch (IOException e) {
                 e = RemoteExceptionHandler.checkIOException(e);
-                LOG.warn("Got while writing region " 
+                LOG.warn("Got while writing region "
                     + Bytes.toStringBinary(region) + " log " + e);
                 e.printStackTrace();
                 exception = e;
@@ -1357,14 +1357,14 @@ public class HLog implements HConstants,
               +"Retaining log files to avoid data loss.");
           throw new IOException(ex.getMessage(), ex.getCause());
         }
-        
+
         // throw an exception if one of the threads reported one
         for (ThreadWithException t : threadList) {
           if (t.exception != null) {
             throw t.exception;
           }
         }
-        
+
         // End of for loop. Rinse and repeat
       }
     } finally {
@@ -1398,14 +1398,14 @@ public class HLog implements HConstants,
           fs.mkdirs(cp);
         }
         Path newp = new Path(cp, p.getName());
-        if (!fs.exists(newp)) { 
+        if (!fs.exists(newp)) {
           if (!fs.rename(p, newp)) {
             LOG.warn("Rename of " + p + " to " + newp + " failed.");
           } else {
             LOG.warn("Corrupt Hlog (" + p + ") moved to " + newp);
           }
         } else {
-          LOG.warn("Corrupt Hlog (" + p + ") already moved to " + newp + 
+          LOG.warn("Corrupt Hlog (" + p + ") already moved to " + newp +
                    ".  Ignoring");
         }
       } else {
@@ -1427,7 +1427,7 @@ public class HLog implements HConstants,
     return splits;
   }
 
- /*  
+ /*
   * @param conf
   * @return True if append enabled and we have the syncFs in our path.
   */
@@ -1444,7 +1444,7 @@ public class HLog implements HConstants,
     }
     return append;
   }
-  
+
   /**
    * Utility class that lets us keep track of the edit with it's key
    * Only used when splitting logs
@@ -1540,20 +1540,20 @@ public class HLog implements HConstants,
     }
     LOG.info("Past out lease recovery");
   }
-  
+
   /**
    * Construct the HLog directory name
-   * 
+   *
    * @param info HServerInfo for server
    * @return the HLog directory name
    */
   public static String getHLogDirectoryName(HServerInfo info) {
     return getHLogDirectoryName(info.getServerName());
   }
-  
+
   /**
    * Construct the HLog directory name
-   * 
+   *
    * @param serverAddress
    * @param startCode
    * @return the HLog directory name
@@ -1566,10 +1566,10 @@ public class HLog implements HConstants,
     return getHLogDirectoryName(
         HServerInfo.getServerName(serverAddress, startCode));
   }
-  
+
   /**
    * Construct the HLog directory name
-   * 
+   *
    * @param serverName
    * @return the HLog directory name
    */
@@ -1641,5 +1641,5 @@ public class HLog implements HConstants,
   public static final long FIXED_OVERHEAD = ClassSize.align(
       ClassSize.OBJECT + (5 * ClassSize.REFERENCE) +
       ClassSize.ATOMIC_INTEGER + Bytes.SIZEOF_INT + (3 * Bytes.SIZEOF_LONG));
-  
+
 }

Modified: hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/regionserver/HLogKey.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/regionserver/HLogKey.java?rev=942184&r1=942183&r2=942184&view=diff
==============================================================================
--- hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/regionserver/HLogKey.java (original)
+++ hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/regionserver/HLogKey.java Fri May  7 19:17:48 2010
@@ -29,11 +29,11 @@ import java.io.*;
 
 /**
  * A Key for an entry in the change log.
- * 
- * The log intermingles edits to many tables and rows, so each log entry 
- * identifies the appropriate table and row.  Within a table and row, they're 
+ *
+ * The log intermingles edits to many tables and rows, so each log entry
+ * identifies the appropriate table and row.  Within a table and row, they're
  * also sorted.
- * 
+ *
  * <p>Some Transactional edits (START, COMMIT, ABORT) will not have an
  * associated row.
  */
@@ -50,7 +50,7 @@ public class HLogKey implements Writable
   public HLogKey() {
     this(null, null, 0L, HConstants.LATEST_TIMESTAMP);
   }
-  
+
   /**
    * Create the log key!
    * We maintain the tablename mainly for debugging purposes.
@@ -77,7 +77,7 @@ public class HLogKey implements Writable
   public byte [] getRegionName() {
     return regionName;
   }
-  
+
   /** @return table name */
   public byte [] getTablename() {
     return tablename;
@@ -87,7 +87,7 @@ public class HLogKey implements Writable
   public long getLogSeqNum() {
     return logSeqNum;
   }
-  
+
   void setLogSeqNum(long logSeqNum) {
     this.logSeqNum = logSeqNum;
   }
@@ -104,7 +104,7 @@ public class HLogKey implements Writable
     return Bytes.toString(tablename) + "/" + Bytes.toString(regionName) + "/" +
       logSeqNum;
   }
-  
+
   @Override
   public boolean equals(Object obj) {
     if (this == obj) {
@@ -115,7 +115,7 @@ public class HLogKey implements Writable
     }
     return compareTo((HLogKey)obj) == 0;
   }
-  
+
   @Override
   public int hashCode() {
     int result = Bytes.hashCode(this.regionName);
@@ -149,7 +149,7 @@ public class HLogKey implements Writable
     out.writeLong(logSeqNum);
     out.writeLong(this.writeTime);
   }
-  
+
   public void readFields(DataInput in) throws IOException {
     this.regionName = Bytes.readByteArray(in);
     this.tablename = Bytes.readByteArray(in);

Modified: hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/regionserver/HRegion.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/regionserver/HRegion.java?rev=942184&r1=942183&r2=942184&view=diff
==============================================================================
--- hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/regionserver/HRegion.java (original)
+++ hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/regionserver/HRegion.java Fri May  7 19:17:48 2010
@@ -78,9 +78,9 @@ package org.apache.hadoop.hbase.regionse
  * for each row. A given table consists of one or more HRegions.
  *
  * <p>We maintain multiple HStores for a single HRegion.
- * 
+ *
  * <p>An Store is a set of rows with some column data; together,
- * they make up all the data for the rows.  
+ * they make up all the data for the rows.
  *
  * <p>Each HRegion has a 'startKey' and 'endKey'.
  * <p>The first is inclusive, the second is exclusive (except for
@@ -96,15 +96,15 @@ package org.apache.hadoop.hbase.regionse
  * constructed, it holds a read lock until it is closed. A close takes out a
  * write lock and consequently will block for ongoing operations and will block
  * new operations from starting while the close is in progress.
- * 
+ *
  * <p>An HRegion is defined by its table and its key extent.
- * 
+ *
  * <p>It consists of at least one Store.  The number of Stores should be
  * configurable, so that data which is accessed together is stored in the same
- * Store.  Right now, we approximate that by building a single Store for 
- * each column family.  (This config info will be communicated via the 
+ * Store.  Right now, we approximate that by building a single Store for
+ * each column family.  (This config info will be communicated via the
  * tabledesc.)
- * 
+ *
  * <p>The HTableDescriptor contains metainfo about the HRegion's table.
  * regionName is a unique identifier for this HRegion. (startKey, endKey]
  * defines the keyspace for this HRegion.
@@ -114,8 +114,8 @@ public class HRegion implements HConstan
   static final String SPLITDIR = "splits";
   static final String MERGEDIR = "merges";
   final AtomicBoolean closed = new AtomicBoolean(false);
-  /* Closing can take some time; use the closing flag if there is stuff we don't 
-   * want to do while in closing state; e.g. like offer this region up to the 
+  /* Closing can take some time; use the closing flag if there is stuff we don't
+   * want to do while in closing state; e.g. like offer this region up to the
    * master as a region to close if the carrying regionserver is overloaded.
    * Once set, it is never cleared.
    */
@@ -134,13 +134,13 @@ public class HRegion implements HConstan
 
   protected final Map<byte [], Store> stores =
     new ConcurrentSkipListMap<byte [], Store>(Bytes.BYTES_RAWCOMPARATOR);
-  
+
   //These variable are just used for getting data out of the region, to test on
   //client side
   // private int numStores = 0;
   // private int [] storeSize = null;
   // private byte [] name = null;
-  
+
   final AtomicLong memstoreSize = new AtomicLong(0);
 
   // This is the table subdirectory.
@@ -184,7 +184,7 @@ public class HRegion implements HConstan
       this.writesEnabled = !onOff;
       this.readOnly = onOff;
     }
-    
+
     boolean isReadOnly() {
       return this.readOnly;
     }
@@ -204,7 +204,7 @@ public class HRegion implements HConstan
   // Used to guard splits and closes
   private final ReentrantReadWriteLock splitsAndClosesLock =
     new ReentrantReadWriteLock();
-  private final ReentrantReadWriteLock newScannerLock = 
+  private final ReentrantReadWriteLock newScannerLock =
     new ReentrantReadWriteLock();
 
   // Stop updates lock
@@ -244,7 +244,7 @@ public class HRegion implements HConstan
     this.regionInfo = null;
     this.threadWakeFrequency = 0L;
   }
-  
+
   /**
    * HRegion constructor.  This constructor should only be used for testing and
    * extensions.  Instances of HRegion should be instantiated with the
@@ -259,7 +259,7 @@ public class HRegion implements HConstan
    * appropriate log info for this HRegion. If there is a previous log file
    * (implying that the HRegion has been written-to before), then read it from
    * the supplied path.
-   * @param fs is the filesystem.  
+   * @param fs is the filesystem.
    * @param conf is global configuration settings.
    * @param regionInfo - HRegionInfo that describes the region
    * is new), then read them from the supplied path.
@@ -301,7 +301,7 @@ public class HRegion implements HConstan
   /**
    * Initialize this region and get it ready to roll.
    * Called after construction.
-   * 
+   *
    * @param initialFiles path
    * @param reporter progressable
    * @throws IOException e
@@ -318,7 +318,7 @@ public class HRegion implements HConstan
     // Load in all the HStores.
     long maxSeqId = -1;
     long minSeqIdToRecover = Integer.MAX_VALUE;
-    
+
     for (HColumnDescriptor c : this.regionInfo.getTableDesc().getFamilies()) {
       Store store = instantiateHStore(this.basedir, c, oldLogFile, reporter);
       this.stores.put(c.getName(), store);
@@ -326,7 +326,7 @@ public class HRegion implements HConstan
       if (storeSeqId > maxSeqId) {
         maxSeqId = storeSeqId;
       }
-      
+
       long storeSeqIdBeforeRecovery = store.getMaxSeqIdBeforeLogRecovery();
       if (storeSeqIdBeforeRecovery < minSeqIdToRecover) {
         minSeqIdToRecover = storeSeqIdBeforeRecovery;
@@ -341,7 +341,7 @@ public class HRegion implements HConstan
       }
       fs.delete(oldLogFile, false);
     }
-    
+
     // Add one to the current maximum sequence id so new edits are beyond.
     this.minSequenceId = maxSeqId + 1;
 
@@ -400,7 +400,7 @@ public class HRegion implements HConstan
     // Name of this file has two leading and trailing underscores so it doesn't
     // clash w/ a store/family name.  There is possibility, but assumption is
     // that its slim (don't want to use control character in filename because
-    // 
+    //
     Path regioninfo = new Path(this.regiondir, REGIONINFO_FILE);
     if (this.fs.exists(regioninfo) &&
         this.fs.getFileStatus(regioninfo).getLen() > 0) {
@@ -424,7 +424,7 @@ public class HRegion implements HConstan
   long getMinSequenceId() {
     return this.minSequenceId;
   }
-  
+
   /** @return a HRegionInfo object for this region */
   public HRegionInfo getRegionInfo() {
     return this.regionInfo;
@@ -434,7 +434,7 @@ public class HRegion implements HConstan
   public boolean isClosed() {
     return this.closed.get();
   }
-  
+
   /**
    * @return True if closing process has started.
    */
@@ -445,18 +445,18 @@ public class HRegion implements HConstan
    public ReadWriteConsistencyControl getRWCC() {
      return rwcc;
    }
-   
+
   /**
-   * Close down this HRegion.  Flush the cache, shut down each HStore, don't 
+   * Close down this HRegion.  Flush the cache, shut down each HStore, don't
    * service any more calls.
    *
-   * <p>This method could take some time to execute, so don't call it from a 
+   * <p>This method could take some time to execute, so don't call it from a
    * time-sensitive thread.
-   * 
-   * @return Vector of all the storage files that the HRegion's component 
+   *
+   * @return Vector of all the storage files that the HRegion's component
    * HStores make use of.  It's a list of all HStoreFile objects. Returns empty
    * vector if already closed and null if judged that it should not close.
-   * 
+   *
    * @throws IOException e
    */
   public List<StoreFile> close() throws IOException {
@@ -467,14 +467,14 @@ public class HRegion implements HConstan
    * Close down this HRegion.  Flush the cache unless abort parameter is true,
    * Shut down each HStore, don't service any more calls.
    *
-   * This method could take some time to execute, so don't call it from a 
+   * This method could take some time to execute, so don't call it from a
    * time-sensitive thread.
-   * 
+   *
    * @param abort true if server is aborting (only during testing)
-   * @return Vector of all the storage files that the HRegion's component 
+   * @return Vector of all the storage files that the HRegion's component
    * HStores make use of.  It's a list of HStoreFile objects.  Can be null if
    * we are not to close at this time or we are already closed.
-   * 
+   *
    * @throws IOException e
    */
   public List<StoreFile> close(final boolean abort) throws IOException {
@@ -522,12 +522,12 @@ public class HRegion implements HConstan
           // outstanding updates.
           waitOnRowLocks();
           LOG.debug("No more row locks outstanding on region " + this);
-  
+
           // Don't flush the cache if we are aborting
           if (!abort) {
             internalFlushcache();
           }
-  
+
           List<StoreFile> result = new ArrayList<StoreFile>();
           for (Store store: stores.values()) {
             result.addAll(store.close());
@@ -611,11 +611,11 @@ public class HRegion implements HConstan
   public long getLastFlushTime() {
     return this.lastFlushTime;
   }
-  
+
   //////////////////////////////////////////////////////////////////////////////
-  // HRegion maintenance.  
+  // HRegion maintenance.
   //
-  // These methods are meant to be called periodically by the HRegionServer for 
+  // These methods are meant to be called periodically by the HRegionServer for
   // upkeep.
   //////////////////////////////////////////////////////////////////////////////
 
@@ -737,7 +737,7 @@ public class HRegion implements HConstan
   protected void prepareToSplit() {
     // nothing
   }
-  
+
   /*
    * @param dir
    * @return compaction directory for the passed in <code>dir</code>
@@ -754,7 +754,7 @@ public class HRegion implements HConstan
   private void doRegionCompactionPrep() throws IOException {
     doRegionCompactionCleanup();
   }
-  
+
   /*
    * Removes the compaction directory for this Store.
    * @throws IOException
@@ -775,13 +775,13 @@ public class HRegion implements HConstan
    * Called by compaction thread and after region is opened to compact the
    * HStores if necessary.
    *
-   * <p>This operation could block for a long time, so don't call it from a 
+   * <p>This operation could block for a long time, so don't call it from a
    * time-sensitive thread.
    *
    * Note that no locking is necessary at this level because compaction only
    * conflicts with a region split, and that cannot happen because the region
    * server does them sequentially and not in parallel.
-   * 
+   *
    * @return mid key if split is needed
    * @throws IOException e
    */
@@ -795,13 +795,13 @@ public class HRegion implements HConstan
    * Called by compaction thread and after region is opened to compact the
    * HStores if necessary.
    *
-   * <p>This operation could block for a long time, so don't call it from a 
+   * <p>This operation could block for a long time, so don't call it from a
    * time-sensitive thread.
    *
    * Note that no locking is necessary at this level because compaction only
    * conflicts with a region split, and that cannot happen because the region
    * server does them sequentially and not in parallel.
-   * 
+   *
    * @param majorCompaction True to force a major compaction regardless of thresholds
    * @return split row if split is needed
    * @throws IOException e
@@ -829,7 +829,7 @@ public class HRegion implements HConstan
               return splitRow;
           }
         }
-        LOG.info("Starting" + (majorCompaction? " major " : " ") + 
+        LOG.info("Starting" + (majorCompaction? " major " : " ") +
             "compaction on region " + this);
         long startTime = System.currentTimeMillis();
         doRegionCompactionPrep();
@@ -842,7 +842,7 @@ public class HRegion implements HConstan
           }
         }
         doRegionCompactionCleanup();
-        String timeTaken = StringUtils.formatTimeDiff(System.currentTimeMillis(), 
+        String timeTaken = StringUtils.formatTimeDiff(System.currentTimeMillis(),
             startTime);
         LOG.info("compaction completed on region " + this + " in " + timeTaken);
       } finally {
@@ -859,7 +859,7 @@ public class HRegion implements HConstan
 
   /**
    * Flush the cache.
-   * 
+   *
    * When this method is called the cache will be flushed unless:
    * <ol>
    *   <li>the cache is empty</li>
@@ -868,11 +868,11 @@ public class HRegion implements HConstan
    *   <li>writes are disabled</li>
    * </ol>
    *
-   * <p>This method may block for some time, so it should not be called from a 
+   * <p>This method may block for some time, so it should not be called from a
    * time-sensitive thread.
-   * 
+   *
    * @return true if cache was flushed
-   * 
+   *
    * @throws IOException general io exceptions
    * @throws DroppedSnapshotException Thrown when replay of hlog is required
    * because a Snapshot was not properly persisted.
@@ -891,7 +891,7 @@ public class HRegion implements HConstan
               writestate.flushing + ", writesEnabled=" +
               writestate.writesEnabled);
         }
-        return false;  
+        return false;
       }
     }
     try {
@@ -920,25 +920,25 @@ public class HRegion implements HConstan
    * flushed. (That way, during recovery, we know when we can rely on the
    * on-disk flushed structures and when we have to recover the memstore from
    * the log.)
-   * 
+   *
    * <p>So, we have a three-step process:
-   * 
+   *
    * <ul><li>A. Flush the memstore to the on-disk stores, noting the current
    * sequence ID for the log.<li>
-   * 
+   *
    * <li>B. Write a FLUSHCACHE-COMPLETE message to the log, using the sequence
    * ID that was current at the time of memstore-flush.</li>
-   * 
+   *
    * <li>C. Get rid of the memstore structures that are now redundant, as
    * they've been flushed to the on-disk HStores.</li>
    * </ul>
    * <p>This method is protected, but can be accessed via several public
    * routes.
-   * 
+   *
    * <p> This method may block for some time.
-   * 
+   *
    * @return true if the region needs compacting
-   * 
+   *
    * @throws IOException general io exceptions
    * @throws DroppedSnapshotException Thrown when replay of hlog is required
    * because a Snapshot was not properly persisted.
@@ -1068,7 +1068,7 @@ public class HRegion implements HConstan
 
     // B.  Write a FLUSHCACHE-COMPLETE message to the log.
     //     This tells future readers that the HStores were emitted correctly,
-    //     and that all updates to the log for this regionName that have lower 
+    //     and that all updates to the log for this regionName that have lower
     //     log-sequence-ids can be safely ignored.
     this.log.completeCacheFlush(getRegionName(),
         regionInfo.getTableDesc().getName(), completeSequenceId,
@@ -1079,7 +1079,7 @@ public class HRegion implements HConstan
     synchronized (this) {
       notifyAll();
     }
-    
+
     if (LOG.isDebugEnabled()) {
       long now = System.currentTimeMillis();
       LOG.debug("Finished memstore flush of ~" +
@@ -1108,23 +1108,23 @@ public class HRegion implements HConstan
    /**
    * Get the sequence number to be associated with this cache flush. Used by
    * TransactionalRegion to not complete pending transactions.
-   * 
-   * 
+   *
+   *
    * @param currentSequenceId
    * @return sequence id to complete the cache flush with
-   */ 
+   */
   protected long getCompleteCacheFlushSequenceId(long currentSequenceId) {
     return currentSequenceId;
   }
-  
+
   //////////////////////////////////////////////////////////////////////////////
   // get() methods for client use.
   //////////////////////////////////////////////////////////////////////////////
   /**
-   * Return all the data for the row that matches <i>row</i> exactly, 
-   * or the one that immediately preceeds it, at or immediately before 
+   * Return all the data for the row that matches <i>row</i> exactly,
+   * or the one that immediately preceeds it, at or immediately before
    * <i>ts</i>.
-   * 
+   *
    * @param row row key
    * @return map of values
    * @throws IOException
@@ -1135,10 +1135,10 @@ public class HRegion implements HConstan
   }
 
   /**
-   * Return all the data for the row that matches <i>row</i> exactly, 
-   * or the one that immediately preceeds it, at or immediately before 
+   * Return all the data for the row that matches <i>row</i> exactly,
+   * or the one that immediately preceeds it, at or immediately before
    * <i>ts</i>.
-   * 
+   *
    * @param row row key
    * @param family column family to find on
    * @return map of values
@@ -1168,7 +1168,7 @@ public class HRegion implements HConstan
   }
 
   /**
-   * Return an iterator that scans over the HRegion, returning the indicated 
+   * Return an iterator that scans over the HRegion, returning the indicated
    * columns and rows specified by the {@link Scan}.
    * <p>
    * This Iterator must be closed by the caller.
@@ -1252,8 +1252,8 @@ public class HRegion implements HConstan
       splitsAndClosesLock.readLock().unlock();
     }
   }
-  
-  
+
+
   /**
    * @param familyMap map of family to edits for the given family.
    * @param writeToWAL
@@ -1272,10 +1272,10 @@ public class HRegion implements HConstan
 
       for (Map.Entry<byte[], List<KeyValue>> e : familyMap.entrySet()) {
 
-        byte[] family = e.getKey(); 
+        byte[] family = e.getKey();
         List<KeyValue> kvs = e.getValue();
         Map<byte[], Integer> kvCount = new TreeMap<byte[], Integer>(Bytes.BYTES_COMPARATOR);
- 
+
         Store store = getStore(family);
         for (KeyValue kv: kvs) {
           //  Check if time is LATEST, change to time of most recent addition if so
@@ -1349,9 +1349,9 @@ public class HRegion implements HConstan
 
       for (Map.Entry<byte[], List<KeyValue>> e : familyMap.entrySet()) {
 
-        byte[] family = e.getKey(); 
+        byte[] family = e.getKey();
         List<KeyValue> kvs = e.getValue();
-        
+
         Store store = getStore(family);
         for (KeyValue kv: kvs) {
           kv.setMemstoreTS(w.getWriteNumber());
@@ -1370,7 +1370,7 @@ public class HRegion implements HConstan
       requestFlush();
     }
   }
-  
+
   /**
    * @param put
    * @throws IOException
@@ -1378,7 +1378,7 @@ public class HRegion implements HConstan
   public void put(Put put) throws IOException {
     this.put(put, null, put.getWriteToWAL());
   }
-  
+
   /**
    * @param put
    * @param writeToWAL
@@ -1408,7 +1408,7 @@ public class HRegion implements HConstan
     checkReadOnly();
 
     // Do a rough check that we have resources to accept a write.  The check is
-    // 'rough' in that between the resource check and the call to obtain a 
+    // 'rough' in that between the resource check and the call to obtain a
     // read lock, resources may run out.  For now, the thought is that this
     // will be extremely rare; we'll deal with it when it happens.
     checkResources();
@@ -1436,13 +1436,13 @@ public class HRegion implements HConstan
     }
   }
 
-  
-  //TODO, Think that gets/puts and deletes should be refactored a bit so that 
+
+  //TODO, Think that gets/puts and deletes should be refactored a bit so that
   //the getting of the lock happens before, so that you would just pass it into
-  //the methods. So in the case of checkAndPut you could just do lockRow, 
+  //the methods. So in the case of checkAndPut you could just do lockRow,
   //get, put, unlockRow or something
   /**
-   * 
+   *
    * @param row
    * @param family
    * @param qualifier
@@ -1454,10 +1454,10 @@ public class HRegion implements HConstan
    * @return true if the new put was execute, false otherwise
    */
   public boolean checkAndPut(byte [] row, byte [] family, byte [] qualifier,
-      byte [] expectedValue, Put put, Integer lockId, boolean writeToWAL) 
+      byte [] expectedValue, Put put, Integer lockId, boolean writeToWAL)
   throws IOException{
     checkReadOnly();
-    //TODO, add check for value length or maybe even better move this to the 
+    //TODO, add check for value length or maybe even better move this to the
     //client if this becomes a global setting
     checkResources();
     splitsAndClosesLock.readLock().lock();
@@ -1469,7 +1469,7 @@ public class HRegion implements HConstan
       byte [] now = Bytes.toBytes(System.currentTimeMillis());
 
       // Lock row
-      Integer lid = getLock(lockId, get.getRow()); 
+      Integer lid = getLock(lockId, get.getRow());
       List<KeyValue> result = new ArrayList<KeyValue>();
       try {
         result = get(get);
@@ -1486,7 +1486,7 @@ public class HRegion implements HConstan
         if (matches) {
           // All edits for the given row (across all column families) must happen atomically.
           put(put.getFamilyMap(), writeToWAL);
-          return true;  
+          return true;
         }
         return false;
       } finally {
@@ -1494,10 +1494,10 @@ public class HRegion implements HConstan
       }
     } finally {
       splitsAndClosesLock.readLock().unlock();
-    }    
+    }
   }
-      
-  
+
+
   /**
    * Checks if any stamps is Long.MAX_VALUE.  If so, sets them to now.
    * <p>
@@ -1517,10 +1517,10 @@ public class HRegion implements HConstan
     }
     return true;
   }
-  
+
 
 //  /*
-//   * Utility method to verify values length. 
+//   * Utility method to verify values length.
 //   * @param batchUpdate The update to verify
 //   * @throws IOException Thrown if a value is too long
 //   */
@@ -1528,7 +1528,7 @@ public class HRegion implements HConstan
 //  throws IOException {
 //    Map<byte[], List<KeyValue>> families = put.getFamilyMap();
 //    for(Map.Entry<byte[], List<KeyValue>> entry : families.entrySet()) {
-//      HColumnDescriptor hcd = 
+//      HColumnDescriptor hcd =
 //        this.regionInfo.getTableDesc().getFamily(entry.getKey());
 //      int maxLen = hcd.getMaxValueLength();
 //      for(KeyValue kv : entry.getValue()) {
@@ -1543,7 +1543,7 @@ public class HRegion implements HConstan
 
   /*
    * Check if resources to support an update.
-   * 
+   *
    * Here we synchronize on HRegion, a broad scoped lock.  Its appropriate
    * given we're figuring in here whether this region is able to take on
    * writes.  This is only method with a synchronize (at time of writing),
@@ -1590,7 +1590,7 @@ public class HRegion implements HConstan
     }
   }
 
-  /** 
+  /**
    * Add updates first to the hlog and then add values to memstore.
    * Warning: Assumption is caller has lock on passed in row.
    * @param family
@@ -1605,7 +1605,7 @@ public class HRegion implements HConstan
     this.put(familyMap, true);
   }
 
-  /** 
+  /**
    * Add updates first to the hlog (if writeToWal) and then add values to memstore.
    * Warning: Assumption is caller has lock on passed in row.
    * @param familyMap map of family to edits for the given family.
@@ -1622,7 +1622,7 @@ public class HRegion implements HConstan
     try {
 
       WALEdit walEdit = new WALEdit();
-      
+
       // check if column families are valid;
       // check if any timestampupdates are needed;
       // and if writeToWAL is set, then also collapse edits into a single list.
@@ -1636,7 +1636,7 @@ public class HRegion implements HConstan
         // update timestamp on keys if required.
         if (updateKeys(edits, byteNow)) {
           if (writeToWAL) {
-            // bunch up all edits across all column families into a 
+            // bunch up all edits across all column families into a
             // single WALEdit.
             for (KeyValue kv : edits) {
               walEdit.add(kv);
@@ -1659,14 +1659,14 @@ public class HRegion implements HConstan
             walEdit, now,
             this.getRegionInfo().isMetaRegion());
       }
-      
+
       long size = 0;
 
       w = rwcc.beginMemstoreInsert();
 
       // now make changes to the memstore
       for (Map.Entry<byte[], List<KeyValue>> e : familyMap.entrySet()) {
-        byte[] family = e.getKey(); 
+        byte[] family = e.getKey();
         List<KeyValue> edits = e.getValue();
 
         Store store = getStore(family);
@@ -1720,7 +1720,7 @@ public class HRegion implements HConstan
     // Used by subclasses; e.g. THBase.
   }
 
-  protected Store instantiateHStore(Path baseDir, 
+  protected Store instantiateHStore(Path baseDir,
     HColumnDescriptor c, Path oldLogFile, Progressable reporter)
   throws IOException {
     return new Store(baseDir, this, c, this.fs, oldLogFile,
@@ -1735,7 +1735,7 @@ public class HRegion implements HConstan
    * TODO: Make this lookup faster.
    */
   public Store getStore(final byte [] column) {
-    return this.stores.get(column); 
+    return this.stores.get(column);
   }
 
   //////////////////////////////////////////////////////////////////////////////
@@ -1768,10 +1768,10 @@ public class HRegion implements HConstan
    * But it acts as a guard on the client; a miswritten client just can't
    * submit the name of a row and start writing to it; it must know the correct
    * lockid, which matches the lock list in memory.
-   * 
-   * <p>It would be more memory-efficient to assume a correctly-written client, 
+   *
+   * <p>It would be more memory-efficient to assume a correctly-written client,
    * which maybe we'll do in the future.
-   * 
+   *
    * @param row Name of row to lock.
    * @throws IOException
    * @return The id of the held lock.
@@ -1794,7 +1794,7 @@ public class HRegion implements HConstan
         // generate a new lockid. Attempt to insert the new [lockid, row].
         // if this lockid already exists in the map then revert and retry
         // We could have first done a lockIds.get, and if it does not exist only
-        // then do a lockIds.put, but the hope is that the lockIds.put will 
+        // then do a lockIds.put, but the hope is that the lockIds.put will
         // mostly return null the first time itself because there won't be
         // too many lockId collisions.
         byte [] prev = null;
@@ -1816,7 +1816,7 @@ public class HRegion implements HConstan
       splitsAndClosesLock.readLock().unlock();
     }
   }
-  
+
   /**
    * Used by unit tests.
    * @param lockid
@@ -1827,8 +1827,8 @@ public class HRegion implements HConstan
       return lockIds.get(lockid);
     }
   }
-  
-  /** 
+
+  /**
    * Release the row lock!
    * @param lockid  The lock ID to release.
    */
@@ -1839,7 +1839,7 @@ public class HRegion implements HConstan
       lockedRows.notifyAll();
     }
   }
-  
+
   /**
    * See if row is currently locked.
    * @param lockid
@@ -1853,14 +1853,14 @@ public class HRegion implements HConstan
       return false;
     }
   }
-  
+
   /**
    * Returns existing row lock if found, otherwise
    * obtains a new row lock and returns it.
    * @param lockid
    * @return lockid
    */
-  private Integer getLock(Integer lockid, byte [] row) 
+  private Integer getLock(Integer lockid, byte [] row)
   throws IOException {
     Integer lid = null;
     if (lockid == null) {
@@ -1873,13 +1873,13 @@ public class HRegion implements HConstan
     }
     return lid;
   }
-  
+
   private void waitOnRowLocks() {
     synchronized (lockedRows) {
       while (!this.lockedRows.isEmpty()) {
         if (LOG.isDebugEnabled()) {
           LOG.debug("Waiting on " + this.lockedRows.size() + " row locks");
-        } 
+        }
         try {
           this.lockedRows.wait();
         } catch (InterruptedException e) {
@@ -1888,17 +1888,17 @@ public class HRegion implements HConstan
       }
     }
   }
-  
+
   @Override
   public boolean equals(Object o) {
     return this.hashCode() == ((HRegion)o).hashCode();
   }
-  
+
   @Override
   public int hashCode() {
     return this.regionInfo.getRegionName().hashCode();
   }
-  
+
   @Override
   public String toString() {
     return this.regionInfo.getRegionNameAsString();
@@ -2096,7 +2096,7 @@ public class HRegion implements HConstan
     }
 
     /**
-     * 
+     *
      * @param scanner to be closed
      */
     public void close(KeyValueScanner scanner) {
@@ -2105,12 +2105,12 @@ public class HRegion implements HConstan
       } catch(NullPointerException npe) {}
     }
   }
-  
+
   // Utility methods
   /**
    * A utility method to create new instances of HRegion based on the
    * {@link org.apache.hadoop.hbase.HConstants#REGION_IMPL} configuration
-   * property. 
+   * property.
    * @param basedir qualified path of directory where region should be located,
    * usually the table directory.
    * @param log The HLog is the outbound log for any updates to the HRegion
@@ -2157,7 +2157,7 @@ public class HRegion implements HConstan
    * @param rootDir Root directory for HBase instance
    * @param conf
    * @return new HRegion
-   * 
+   *
    * @throws IOException
    */
   public static HRegion createHRegion(final HRegionInfo info, final Path rootDir,
@@ -2174,7 +2174,7 @@ public class HRegion implements HConstan
     region.initialize(null, null);
     return region;
   }
-  
+
   /**
    * Convenience method to open a HRegion outside of an HRegionServer context.
    * @param info Info for region to be opened.
@@ -2185,7 +2185,7 @@ public class HRegion implements HConstan
    * up.  HRegionStore does this every time it opens a new region.
    * @param conf
    * @return new HRegion
-   * 
+   *
    * @throws IOException
    */
   public static HRegion openHRegion(final HRegionInfo info, final Path rootDir,
@@ -2206,18 +2206,18 @@ public class HRegion implements HConstan
     }
     return r;
   }
-  
+
   /**
    * Inserts a new region's meta information into the passed
    * <code>meta</code> region. Used by the HMaster bootstrap code adding
    * new table to ROOT table.
-   * 
+   *
    * @param meta META HRegion to be updated
    * @param r HRegion to add to <code>meta</code>
    *
    * @throws IOException
    */
-  public static void addRegionToMETA(HRegion meta, HRegion r) 
+  public static void addRegionToMETA(HRegion meta, HRegion r)
   throws IOException {
     meta.checkResources();
     // The row key is the region name
@@ -2237,7 +2237,7 @@ public class HRegion implements HConstan
    * Delete a region's meta information from the passed
    * <code>meta</code> region.  Removes content in the 'info' column family.
    * Does not remove region historian info.
-   * 
+   *
    * @param srvr META server to be updated
    * @param metaRegionName Meta region name
    * @param regionName HRegion to remove from <code>meta</code>
@@ -2273,7 +2273,7 @@ public class HRegion implements HConstan
     srvr.put(metaRegionName, put);
     cleanRegionInMETA(srvr, metaRegionName, info);
   }
-  
+
   /**
    * Clean COL_SERVER and COL_STARTCODE for passed <code>info</code> in
    * <code>.META.</code>
@@ -2293,7 +2293,7 @@ public class HRegion implements HConstan
 
   /**
    * Deletes all the files for a HRegion
-   * 
+   *
    * @param fs the file system object
    * @param rootdir qualified path of HBase root directory
    * @param info HRegionInfo for region to be deleted
@@ -2316,7 +2316,7 @@ public class HRegion implements HConstan
 
   /**
    * Computes the Path of the HRegion
-   * 
+   *
    * @param tabledir qualified path for table
    * @param name ENCODED region name
    * @return Path of HRegion directory
@@ -2324,10 +2324,10 @@ public class HRegion implements HConstan
   public static Path getRegionDir(final Path tabledir, final int name) {
     return new Path(tabledir, Integer.toString(name));
   }
-  
+
   /**
    * Computes the Path of the HRegion
-   * 
+   *
    * @param rootdir qualified path of HBase root directory
    * @param info HRegionInfo for the region
    * @return qualified path of region directory
@@ -2341,7 +2341,7 @@ public class HRegion implements HConstan
   /**
    * Determines if the specified row is within the row range specified by the
    * specified HRegionInfo
-   *  
+   *
    * @param info HRegionInfo that specifies the row range
    * @param row row to be checked
    * @return true if the row is within the range specified by the HRegionInfo
@@ -2355,7 +2355,7 @@ public class HRegion implements HConstan
 
   /**
    * Make the directories for a specific column family
-   * 
+   *
    * @param fs the file system
    * @param tabledir base directory where region will live (usually the table dir)
    * @param hri
@@ -2373,7 +2373,7 @@ public class HRegion implements HConstan
 
   /**
    * Merge two HRegions.  The regions must be adjacent and must not overlap.
-   * 
+   *
    * @param srcA
    * @param srcB
    * @return new merged HRegion
@@ -2405,7 +2405,7 @@ public class HRegion implements HConstan
 
   /**
    * Merge two regions whether they are adjacent or not.
-   * 
+   *
    * @param a region a
    * @param b region b
    * @return new merged region
@@ -2420,12 +2420,12 @@ public class HRegion implements HConstan
     FileSystem fs = a.getFilesystem();
 
     // Make sure each region's cache is empty
-    
+
     a.flushcache();
     b.flushcache();
-    
+
     // Compact each region so we only have one store file per family
-    
+
     a.compactStores(true);
     if (LOG.isDebugEnabled()) {
       LOG.debug("Files for region: " + a);
@@ -2436,12 +2436,12 @@ public class HRegion implements HConstan
       LOG.debug("Files for region: " + b);
       listPaths(fs, b.getRegionDir());
     }
-    
+
     HBaseConfiguration conf = a.getConf();
     HTableDescriptor tabledesc = a.getTableDesc();
     HLog log = a.getLog();
     Path basedir = a.getBaseDir();
-    // Presume both are of same region type -- i.e. both user or catalog 
+    // Presume both are of same region type -- i.e. both user or catalog
     // table regions.  This way can use comparator.
     final byte [] startKey = a.comparator.matchingRows(a.getStartKey(), 0,
           a.getStartKey().length,
@@ -2449,7 +2449,7 @@ public class HRegion implements HConstan
       b.comparator.matchingRows(b.getStartKey(), 0, b.getStartKey().length,
         EMPTY_BYTE_ARRAY, 0, EMPTY_BYTE_ARRAY.length)?
         EMPTY_BYTE_ARRAY:
-          a.comparator.compareRows(a.getStartKey(), 0, a.getStartKey().length, 
+          a.comparator.compareRows(a.getStartKey(), 0, a.getStartKey().length,
           b.getStartKey(), 0, b.getStartKey().length) <= 0?
         a.getStartKey(): b.getStartKey();
     final byte [] endKey = a.comparator.matchingRows(a.getEndKey(), 0,
@@ -2463,7 +2463,7 @@ public class HRegion implements HConstan
 
     HRegionInfo newRegionInfo = new HRegionInfo(tabledesc, startKey, endKey);
     LOG.info("Creating new region " + newRegionInfo.toString());
-    int encodedName = newRegionInfo.getEncodedName(); 
+    int encodedName = newRegionInfo.getEncodedName();
     Path newRegionDir = HRegion.getRegionDir(a.getBaseDir(), encodedName);
     if(fs.exists(newRegionDir)) {
       throw new IOException("Cannot merge; target file collision at " +
@@ -2523,7 +2523,7 @@ public class HRegion implements HConstan
   }
 
   /*
-   * Fills a map with a vector of store files keyed by column family. 
+   * Fills a map with a vector of store files keyed by column family.
    * @param byFamily Map to fill.
    * @param storeFiles Store files to process.
    * @param family
@@ -2545,7 +2545,7 @@ public class HRegion implements HConstan
 
   /**
    * @return True if needs a mojor compaction.
-   * @throws IOException 
+   * @throws IOException
    */
   boolean isMajorCompaction() throws IOException {
     for (Store store: this.stores.values()) {
@@ -2558,7 +2558,7 @@ public class HRegion implements HConstan
 
   /*
    * List the files under the specified directory
-   * 
+   *
    * @param fs
    * @param dir
    * @throws IOException
@@ -2581,7 +2581,7 @@ public class HRegion implements HConstan
     }
   }
 
-  
+
   //
   // HBASE-880
   //
@@ -2627,7 +2627,7 @@ public class HRegion implements HConstan
   }
 
   /**
-   * 
+   *
    * @param row
    * @param family
    * @param qualifier
@@ -2696,13 +2696,13 @@ public class HRegion implements HConstan
 
     return result;
   }
-    
-  
+
+
   //
   // New HBASE-880 Helpers
   //
-  
-  private void checkFamily(final byte [] family) 
+
+  private void checkFamily(final byte [] family)
   throws NoSuchColumnFamilyException {
     if(!regionInfo.getTableDesc().hasFamily(family)) {
       throw new NoSuchColumnFamilyException("Column family " +
@@ -2714,9 +2714,9 @@ public class HRegion implements HConstan
   public static final long FIXED_OVERHEAD = ClassSize.align(
       (5 * Bytes.SIZEOF_LONG) + Bytes.SIZEOF_BOOLEAN +
       (21 * ClassSize.REFERENCE) + ClassSize.OBJECT + Bytes.SIZEOF_INT);
-  
+
   public static final long DEEP_OVERHEAD = ClassSize.align(FIXED_OVERHEAD +
-      ClassSize.OBJECT + (2 * ClassSize.ATOMIC_BOOLEAN) + 
+      ClassSize.OBJECT + (2 * ClassSize.ATOMIC_BOOLEAN) +
       ClassSize.ATOMIC_LONG + ClassSize.ATOMIC_INTEGER +
 
       // Using TreeMap for TreeSet
@@ -2729,7 +2729,7 @@ public class HRegion implements HConstan
       ClassSize.align(ClassSize.OBJECT +
         (5 * Bytes.SIZEOF_BOOLEAN)) +
         (3 * ClassSize.REENTRANT_LOCK));
-  
+
   public long heapSize() {
     long heapSize = DEEP_OVERHEAD;
     for(Store store : this.stores.values()) {
@@ -2838,7 +2838,7 @@ public class HRegion implements HConstan
    *   ./bin/hbase org.apache.hadoop.hbase.regionserver.HRegion
    * </pre>
    * @param args
-   * @throws IOException 
+   * @throws IOException
    */
   public static void main(String[] args) throws IOException {
     if (args.length < 1) {

Modified: hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java?rev=942184&r1=942183&r2=942184&view=diff
==============================================================================
--- hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java (original)
+++ hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java Fri May  7 19:17:48 2010
@@ -126,7 +126,7 @@ public class HRegionServer implements HC
   // plain boolean so we can pass a reference to Chore threads.  Otherwise,
   // Chore threads need to know about the hosting class.
   protected final AtomicBoolean stopRequested = new AtomicBoolean(false);
-  
+
   protected final AtomicBoolean quiesced = new AtomicBoolean(false);
 
   protected final AtomicBoolean safeMode = new AtomicBoolean(true);
@@ -137,7 +137,7 @@ public class HRegionServer implements HC
 
   // If false, the file system has become unavailable
   protected volatile boolean fsOk;
-  
+
   protected HServerInfo serverInfo;
   protected final HBaseConfiguration conf;
 
@@ -165,7 +165,7 @@ public class HRegionServer implements HC
   protected final int numRegionsToReport;
 
   private final long maxScannerResultSize;
-  
+
   // Remote HMaster
   private HMasterRegionInterface hbaseMaster;
 
@@ -175,7 +175,7 @@ public class HRegionServer implements HC
 
   // Leases
   private Leases leases;
-  
+
   // Request counter
   private volatile AtomicInteger requestCount = new AtomicInteger();
 
@@ -183,25 +183,25 @@ public class HRegionServer implements HC
   // is name of the webapp and the attribute name used stuffing this instance
   // into web context.
   InfoServer infoServer;
-  
+
   /** region server process name */
   public static final String REGIONSERVER = "regionserver";
-  
+
   /*
    * Space is reserved in HRS constructor and then released when aborting
    * to recover from an OOME. See HBASE-706.  TODO: Make this percentage of the
    * heap or a minimum.
    */
   private final LinkedList<byte[]> reservedSpace = new LinkedList<byte []>();
-  
+
   private RegionServerMetrics metrics;
 
   // Compactions
   CompactSplitThread compactSplitThread;
 
-  // Cache flushing  
+  // Cache flushing
   MemStoreFlusher cacheFlusher;
-  
+
   /* Check for major compactions.
    */
   Chore majorCompactionChecker;
@@ -210,7 +210,7 @@ public class HRegionServer implements HC
   // eclipse warning when accessed by inner classes
   protected volatile HLog hlog;
   LogRoller hlogRoller;
-  
+
   // flag set after we're done setting up server threads (used for testing)
   protected volatile boolean isOnline;
 
@@ -247,7 +247,7 @@ public class HRegionServer implements HC
     machineName = DNS.getDefaultHost(
         conf.get("hbase.regionserver.dns.interface","default"),
         conf.get("hbase.regionserver.dns.nameserver","default"));
-    String addressStr = machineName + ":" + 
+    String addressStr = machineName + ":" +
       conf.get(REGIONSERVER_PORT, Integer.toString(DEFAULT_REGIONSERVER_PORT));
     // This is not necessarily the address we will run with.  The address we
     // use will be in #serverInfo data member.  For example, we may have been
@@ -260,9 +260,9 @@ public class HRegionServer implements HC
     this.fsOk = true;
     this.conf = conf;
     this.connection = ServerConnectionManager.getConnection(conf);
-    
+
     this.isOnline = false;
-    
+
     // Config'ed params
     this.numRetries =  conf.getInt("hbase.client.retries.number", 2);
     this.threadWakeFrequency = conf.getInt(THREAD_WAKE_FREQUENCY, 10 * 1000);
@@ -273,14 +273,14 @@ public class HRegionServer implements HC
     sleeper = new Sleeper(this.msgInterval, this.stopRequested);
 
     this.maxScannerResultSize = conf.getLong(
-            HConstants.HBASE_CLIENT_SCANNER_MAX_RESULT_SIZE_KEY, 
+            HConstants.HBASE_CLIENT_SCANNER_MAX_RESULT_SIZE_KEY,
             HConstants.DEFAULT_HBASE_CLIENT_SCANNER_MAX_RESULT_SIZE);
-              
+
     // Task thread to process requests from Master
     this.worker = new Worker();
 
-    this.numRegionsToReport =                                        
-      conf.getInt("hbase.regionserver.numregionstoreport", 10);      
+    this.numRegionsToReport =
+      conf.getInt("hbase.regionserver.numregionstoreport", 10);
 
     this.rpcTimeout = conf.getLong("hbase.regionserver.lease.period", 60000);
 
@@ -299,7 +299,7 @@ public class HRegionServer implements HC
     this.shutdownHDFS.set(true);
 
     // Server to handle client requests
-    this.server = HBaseRPC.getServer(this, address.getBindAddress(), 
+    this.server = HBaseRPC.getServer(this, address.getBindAddress(),
       address.getPort(), conf.getInt("hbase.regionserver.handler.count", 10),
       false, conf);
     this.server.setErrorHandler(this);
@@ -331,13 +331,13 @@ public class HRegionServer implements HC
 
     // Cache flushing thread.
     this.cacheFlusher = new MemStoreFlusher(conf, this);
-    
+
     // Compaction thread
     this.compactSplitThread = new CompactSplitThread(this);
-    
+
     // Log rolling thread
     this.hlogRoller = new LogRoller(this);
-    
+
     // Background thread to check for major compactions; needed if region
     // has not gotten updates in a while.  Make it run at a lesser frequency.
     int multiplier = this.conf.getInt(THREAD_WAKE_FREQUENCY +
@@ -422,7 +422,7 @@ public class HRegionServer implements HC
 
   /**
    * The HRegionServer sticks in this loop until closed. It repeatedly checks
-   * in with the HMaster, sending heartbeats & reports, and receiving HRegion 
+   * in with the HMaster, sending heartbeats & reports, and receiving HRegion
    * load/unload instructions.
    */
   public void run() {
@@ -528,7 +528,7 @@ public class HRegionServer implements HC
                   } catch (IOException e) {
                     this.abortRequested = true;
                     this.stopRequested.set(true);
-                    e = RemoteExceptionHandler.checkIOException(e); 
+                    e = RemoteExceptionHandler.checkIOException(e);
                     LOG.fatal("error restarting server", e);
                     break;
                   }
@@ -595,7 +595,7 @@ public class HRegionServer implements HC
           }
         }
         now = System.currentTimeMillis();
-        HMsg msg = this.outboundMsgs.poll((msgInterval - (now - lastMsg)), 
+        HMsg msg = this.outboundMsgs.poll((msgInterval - (now - lastMsg)),
           TimeUnit.MILLISECONDS);
         // If we got something, add it to list of things to send.
         if (msg != null) outboundMessages.add(msg);
@@ -682,7 +682,7 @@ public class HRegionServer implements HC
       HBaseRPC.stopProxy(this.hbaseMaster);
       this.hbaseMaster = null;
     }
-    
+
     join();
     this.zooKeeperWrapper.close();
     if (this.shutdownHDFS.get()) {
@@ -827,16 +827,16 @@ public class HRegionServer implements HC
       stores += r.stores.size();
       for (Store store: r.stores.values()) {
         storefiles += store.getStorefilesCount();
-        storefileSizeMB += 
+        storefileSizeMB +=
           (int)(store.getStorefilesSize()/1024/1024);
-        storefileIndexSizeMB += 
+        storefileIndexSizeMB +=
           (int)(store.getStorefilesIndexSize()/1024/1024);
       }
     }
     return new HServerLoad.RegionLoad(name, stores, storefiles,
       storefileSizeMB, memstoreSizeMB, storefileIndexSizeMB);
   }
- 
+
   /**
    * @param regionName
    * @return An instance of RegionLoad.
@@ -911,12 +911,12 @@ public class HRegionServer implements HC
     }
     return stop;
   }
-  
-  
+
+
   /**
    * Checks to see if the file system is still accessible.
    * If not, sets abortRequested and stopRequested
-   * 
+   *
    * @return false if file system is not available
    */
   protected boolean checkFileSystem() {
@@ -940,7 +940,7 @@ public class HRegionServer implements HC
   private static class ShutdownThread extends Thread {
     private final HRegionServer instance;
     private final Thread mainThread;
-    
+
     /**
      * @param instance
      * @param mainThread
@@ -953,7 +953,7 @@ public class HRegionServer implements HC
     @Override
     public void run() {
       LOG.info("Starting shutdown thread.");
-      
+
       // tell the region server to stop
       instance.stop();
 
@@ -961,7 +961,7 @@ public class HRegionServer implements HC
       Threads.shutdown(mainThread);
 
       LOG.info("Shutdown thread complete");
-    }    
+    }
   }
 
   // We need to call HDFS shutdown when we are done shutting down
@@ -998,7 +998,7 @@ public class HRegionServer implements HC
       }
     }
   }
-  
+
   /**
    * So, HDFS caches FileSystems so when you call FileSystem.get it's fast. In
    * order to make sure things are cleaned up, it also creates a shutdown hook
@@ -1026,7 +1026,7 @@ public class HRegionServer implements HC
       }
       Runtime.getRuntime().removeShutdownHook(hdfsClientFinalizer);
       return hdfsClientFinalizer;
-      
+
     } catch (NoSuchFieldException nsfe) {
       LOG.fatal("Couldn't find field 'clientFinalizer' in FileSystem!", nsfe);
       throw new RuntimeException("Failed to suppress HDFS shutdown hook");
@@ -1037,7 +1037,7 @@ public class HRegionServer implements HC
   }
 
   /**
-   * Report the status of the server. A server is online once all the startup 
+   * Report the status of the server. A server is online once all the startup
    * is completed (setting up filesystem, starting service threads, etc.). This
    * method is designed mostly to be useful in tests.
    * @return true if online, false if not.
@@ -1045,10 +1045,10 @@ public class HRegionServer implements HC
   public boolean isOnline() {
     return isOnline;
   }
-    
+
   private HLog setupHLog() throws RegionServerRunningException,
     IOException {
-    
+
     Path logdir = new Path(rootDir, HLog.getHLogDirectoryName(this.serverInfo));
     if (LOG.isDebugEnabled()) {
       LOG.debug("Log dir " + logdir);
@@ -1062,17 +1062,17 @@ public class HRegionServer implements HC
     return newlog;
   }
 
-  // instantiate 
+  // instantiate
   protected HLog instantiateHLog(Path logdir) throws IOException {
     HLog newlog = new HLog(fs, logdir, conf, hlogRoller);
     return newlog;
   }
 
-  
+
   protected LogRoller getLogRoller() {
     return hlogRoller;
-  }  
-  
+  }
+
   /*
    * @param interval Interval since last time metrics were called.
    */
@@ -1101,7 +1101,7 @@ public class HRegionServer implements HC
         synchronized (r.stores) {
           stores += r.stores.size();
           for(Map.Entry<byte [], Store> ee: r.stores.entrySet()) {
-            Store store = ee.getValue(); 
+            Store store = ee.getValue();
             storefiles += store.getStorefilesCount();
             storefileIndexSize += store.getStorefilesIndexSize();
           }
@@ -1160,7 +1160,7 @@ public class HRegionServer implements HC
     Threads.setDaemonThreadRunning(this.workerThread, n + ".worker", handler);
     Threads.setDaemonThreadRunning(this.majorCompactionChecker,
         n + ".majorCompactionChecker", handler);
-    
+
     // Leases is not a Thread. Internally it runs a daemon thread.  If it gets
     // an unhandled exception, it will just exit.
     this.leases.setName(n + ".leaseChecker");
@@ -1190,7 +1190,7 @@ public class HRegionServer implements HC
           // update HRS server info
           this.serverInfo.setInfoPort(port);
         }
-      } 
+      }
     }
 
     // Start Server.  This service is like leases in that it internally runs
@@ -1276,7 +1276,7 @@ public class HRegionServer implements HC
     stop();
   }
 
-  /** 
+  /**
    * Wait on all threads to finish.
    * Presumption is that all closes and stops have already been called.
    */
@@ -1344,7 +1344,7 @@ public class HRegionServer implements HC
         if (LOG.isDebugEnabled())
           LOG.debug("sending initial server load: " + hsl);
         lastMsg = System.currentTimeMillis();
-        boolean startCodeOk = false; 
+        boolean startCodeOk = false;
         while(!startCodeOk) {
           serverInfo.setStartCode(System.currentTimeMillis());
           startCodeOk = zooKeeperWrapper.writeRSLocation(this.serverInfo);
@@ -1383,13 +1383,13 @@ public class HRegionServer implements HC
   private void reportClose(final HRegionInfo region, final byte[] message) {
     this.outboundMsgs.add(new HMsg(HMsg.Type.MSG_REPORT_CLOSE, region, message));
   }
-  
+
   /**
    * Add to the outbound message buffer
-   * 
-   * When a region splits, we need to tell the master that there are two new 
+   *
+   * When a region splits, we need to tell the master that there are two new
    * regions that need to be assigned.
-   * 
+   *
    * We do not need to inform the master about the old region, because we've
    * updated the meta or root regions, and the master will pick that up on its
    * next rescan of the root or meta tables.
@@ -1422,7 +1422,7 @@ public class HRegionServer implements HC
   final BlockingQueue<ToDoEntry> toDo = new LinkedBlockingQueue<ToDoEntry>();
   private Worker worker;
   private Thread workerThread;
-  
+
   /** Thread that performs long running requests from the master */
   class Worker implements Runnable {
     void stop() {
@@ -1430,7 +1430,7 @@ public class HRegionServer implements HC
         toDo.notifyAll();
       }
     }
-    
+
     public void run() {
       try {
         while(!stopRequested.get()) {
@@ -1492,12 +1492,12 @@ public class HRegionServer implements HC
                 e.msg.isType(Type.MSG_REGION_MAJOR_COMPACT),
                 e.msg.getType().name());
               break;
-              
+
             case MSG_REGION_FLUSH:
               region = getRegion(info.getRegionName());
               region.flushcache();
               break;
-              
+
             case TESTING_MSG_BLOCK_RS:
               while (!stopRequested.get()) {
                 Threads.sleep(1000);
@@ -1575,9 +1575,9 @@ public class HRegionServer implements HC
         this.lock.writeLock().unlock();
       }
     }
-    reportOpen(regionInfo); 
+    reportOpen(regionInfo);
   }
-  
+
   protected HRegion instantiateRegion(final HRegionInfo regionInfo)
       throws IOException {
     HRegion r = HRegion.newHRegion(HTableDescriptor.getTableDir(rootDir, regionInfo
@@ -1588,9 +1588,9 @@ public class HRegionServer implements HC
         addProcessingMessage(regionInfo);
       }
     });
-    return r; 
+    return r;
   }
-  
+
   /**
    * Add a MSG_REPORT_PROCESS_OPEN to the outbound queue.
    * This method is called while region is in the queue of regions to process
@@ -1644,7 +1644,7 @@ public class HRegionServer implements HC
     }
     return regionsToClose;
   }
-  
+
   /*
    * Thread to run close of a region.
    */
@@ -1655,7 +1655,7 @@ public class HRegionServer implements HC
       super(Thread.currentThread().getName() + ".regionCloser." + r.toString());
       this.r = r;
     }
-    
+
     @Override
     public void run() {
       try {
@@ -1727,7 +1727,7 @@ public class HRegionServer implements HC
   }
 
 
-  public Result getClosestRowBefore(final byte [] regionName, 
+  public Result getClosestRowBefore(final byte [] regionName,
     final byte [] row, final byte [] family)
   throws IOException {
     checkOpen();
@@ -1735,8 +1735,8 @@ public class HRegionServer implements HC
     try {
       // locate the region we're operating on
       HRegion region = getRegion(regionName);
-      // ask the region for all the data 
-      
+      // ask the region for all the data
+
       Result r = region.getClosestRowBefore(row, family);
       return r;
     } catch (Throwable t) {
@@ -1772,7 +1772,7 @@ public class HRegionServer implements HC
   throws IOException {
     if (put.getRow() == null)
       throw new IllegalArgumentException("update has null row");
-    
+
     checkOpen();
     this.requestCount.incrementAndGet();
     HRegion region = getRegion(regionName);
@@ -1793,7 +1793,7 @@ public class HRegionServer implements HC
     checkOpen();
     try {
       HRegion region = getRegion(regionName);
-      
+
       if (!region.getRegionInfo().isMetaTable()) {
         this.cacheFlusher.reclaimMemStoreMemory();
       }
@@ -1821,7 +1821,7 @@ public class HRegionServer implements HC
   }
 
   /**
-   * 
+   *
    * @param regionName
    * @param row
    * @param family
@@ -1832,12 +1832,12 @@ public class HRegionServer implements HC
    * @return true if the new put was execute, false otherwise
    */
   public boolean checkAndPut(final byte[] regionName, final byte [] row,
-      final byte [] family, final byte [] qualifier, final byte [] value, 
+      final byte [] family, final byte [] qualifier, final byte [] value,
       final Put put) throws IOException{
     //Getting actual value
     Get get = new Get(row);
     get.addColumn(family, qualifier);
-    
+
     checkOpen();
     this.requestCount.incrementAndGet();
     HRegion region = getRegion(regionName);
@@ -1853,7 +1853,7 @@ public class HRegionServer implements HC
       throw convertThrowableToIOE(cleanup(t));
     }
   }
-  
+
   //
   // remote scanner interface
   //
@@ -1878,7 +1878,7 @@ public class HRegionServer implements HC
       throw convertThrowableToIOE(cleanup(t, "Failed openScanner"));
     }
   }
-  
+
   protected long addScanner(InternalScanner s) throws LeaseStillHeldException {
     long scannerId = -1L;
     scannerId = rand.nextLong();
@@ -1909,7 +1909,7 @@ public class HRegionServer implements HC
       try {
         checkOpen();
       } catch (IOException e) {
-        // If checkOpen failed, server not running or filesystem gone, 
+        // If checkOpen failed, server not running or filesystem gone,
         // cancel this lease; filesystem is gone or we're closing or something.
         this.leases.cancelLease(scannerName);
         throw e;
@@ -1948,7 +1948,7 @@ public class HRegionServer implements HC
       }
       throw convertThrowableToIOE(cleanup(t));
     }
-  } 
+  }
 
   public void close(final long scannerId) throws IOException {
     try {
@@ -1968,17 +1968,17 @@ public class HRegionServer implements HC
     }
   }
 
-  /** 
+  /**
    * Instantiated as a scanner lease.
    * If the lease times out, the scanner is closed
    */
   private class ScannerListener implements LeaseListener {
     private final String scannerName;
-    
+
     ScannerListener(final String n) {
       this.scannerName = n;
     }
-    
+
     public void leaseExpired() {
       LOG.info("Scanner " + this.scannerName + " lease expired");
       InternalScanner s = null;
@@ -1994,7 +1994,7 @@ public class HRegionServer implements HC
       }
     }
   }
-  
+
   //
   // Methods that do the actual work for the remote API
   //
@@ -2040,7 +2040,7 @@ public class HRegionServer implements HC
     } catch (Throwable t) {
       throw convertThrowableToIOE(cleanup(t));
     }
-    
+
     // All have been processed successfully.
     return -1;
   }
@@ -2173,7 +2173,7 @@ public class HRegionServer implements HC
   public InfoServer getInfoServer() {
     return infoServer;
   }
-  
+
   /**
    * @return true if a stop has been requested.
    */
@@ -2189,7 +2189,7 @@ public class HRegionServer implements HC
   }
 
   /**
-   * 
+   *
    * @return the configuration
    */
   public HBaseConfiguration getConfiguration() {
@@ -2211,7 +2211,7 @@ public class HRegionServer implements HC
   public HRegion [] getOnlineRegionsAsArray() {
     return getOnlineRegions().toArray(new HRegion[0]);
   }
-  
+
   /**
    * @return The HRegionInfos from online regions sorted
    */
@@ -2224,10 +2224,10 @@ public class HRegionServer implements HC
     }
     return result;
   }
-  
+
   /**
-   * This method removes HRegion corresponding to hri from the Map of onlineRegions.  
-   * 
+   * This method removes HRegion corresponding to hri from the Map of onlineRegions.
+   *
    * @param hri the HRegionInfo corresponding to the HRegion to-be-removed.
    * @return the removed HRegion, or null if the HRegion was not in onlineRegions.
    */
@@ -2262,7 +2262,7 @@ public class HRegionServer implements HC
     }
     return sortedRegions;
   }
-  
+
   /**
    * @param regionName
    * @return HRegion for the passed <code>regionName</code> or null if named
@@ -2281,8 +2281,8 @@ public class HRegionServer implements HC
   public FlushRequester getFlushRequester() {
     return this.cacheFlusher;
   }
-  
-  /** 
+
+  /**
    * Protected utility method for safely obtaining an HRegion handle.
    * @param regionName Name of online {@link HRegion} to return
    * @return {@link HRegion} for <code>regionName</code>
@@ -2325,10 +2325,10 @@ public class HRegionServer implements HC
     }
     return regions.toArray(new HRegionInfo[regions.size()]);
   }
-  
-  /**  
+
+  /**
    * Called to verify that this server is up and running.
-   * 
+   *
    * @throws IOException
    */
   protected void checkOpen() throws IOException {
@@ -2340,14 +2340,14 @@ public class HRegionServer implements HC
       throw new IOException("File system not available");
     }
   }
- 
+
   /**
    * @return Returns list of non-closed regions hosted on this server.  If no
    * regions to check, returns an empty list.
    */
   protected Set<HRegion> getRegionsToCheck() {
     HashSet<HRegion> regionsToCheck = new HashSet<HRegion>();
-    //TODO: is this locking necessary? 
+    //TODO: is this locking necessary?
     lock.readLock().lock();
     try {
       regionsToCheck.addAll(this.onlineRegions.values());
@@ -2364,9 +2364,9 @@ public class HRegionServer implements HC
     return regionsToCheck;
   }
 
-  public long getProtocolVersion(final String protocol, 
+  public long getProtocolVersion(final String protocol,
       final long clientVersion)
-  throws IOException {  
+  throws IOException {
     if (protocol.equals(HRegionInterface.class.getName())) {
       return HBaseRPCProtocolVersion.versionID;
     }
@@ -2421,21 +2421,21 @@ public class HRegionServer implements HC
   public HServerInfo getServerInfo() { return this.serverInfo; }
 
   /** {@inheritDoc} */
-  public long incrementColumnValue(byte [] regionName, byte [] row, 
+  public long incrementColumnValue(byte [] regionName, byte [] row,
       byte [] family, byte [] qualifier, long amount, boolean writeToWAL)
   throws IOException {
     checkOpen();
 
     if (regionName == null) {
-      throw new IOException("Invalid arguments to incrementColumnValue " + 
+      throw new IOException("Invalid arguments to incrementColumnValue " +
       "regionName is null");
     }
     requestCount.incrementAndGet();
     try {
       HRegion region = getRegion(regionName);
-      long retval = region.incrementColumnValue(row, family, qualifier, amount, 
+      long retval = region.incrementColumnValue(row, family, qualifier, amount,
           writeToWAL);
-      
+
       return retval;
     } catch (IOException e) {
       checkFileSystem();
@@ -2452,7 +2452,7 @@ public class HRegionServer implements HC
     }
     return regions;
   }
-  
+
   /** {@inheritDoc} */
   public HServerInfo getHServerInfo() throws IOException {
     return serverInfo;
@@ -2480,7 +2480,7 @@ public class HRegionServer implements HC
   //
   // Main program and support routines
   //
-  
+
   /**
    * @param hrs
    * @return Thread the RegionServer is running in correctly named.
@@ -2506,7 +2506,7 @@ public class HRegionServer implements HC
   private static void printUsageAndExit() {
     printUsageAndExit(null);
   }
-  
+
   private static void printUsageAndExit(final String message) {
     if (message != null) {
       System.err.println(message);
@@ -2544,7 +2544,7 @@ public class HRegionServer implements HC
       printUsageAndExit();
     }
     Configuration conf = new HBaseConfiguration();
-    
+
     // Process command-line args. TODO: Better cmd-line processing
     // (but hopefully something not as painful as cli options).
     for (String cmd: args) {
@@ -2569,13 +2569,13 @@ public class HRegionServer implements HC
         }
         break;
       }
-      
+
       if (cmd.equals("stop")) {
         printUsageAndExit("To shutdown the regionserver run " +
           "bin/hbase-daemon.sh stop regionserver or send a kill signal to" +
           "the regionserver pid");
       }
-      
+
       // Print out usage if we get to here.
       printUsageAndExit();
     }

Modified: hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/regionserver/InternalScanner.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/regionserver/InternalScanner.java?rev=942184&r1=942183&r2=942184&view=diff
==============================================================================
--- hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/regionserver/InternalScanner.java (original)
+++ hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/regionserver/InternalScanner.java Fri May  7 19:17:48 2010
@@ -27,10 +27,10 @@ import org.apache.hadoop.hbase.KeyValue;
 
 /**
  * Internal scanners differ from client-side scanners in that they operate on
- * HStoreKeys and byte[] instead of RowResults. This is because they are 
+ * HStoreKeys and byte[] instead of RowResults. This is because they are
  * actually close to how the data is physically stored, and therefore it is more
- * convenient to interact with them that way. It is also much easier to merge 
- * the results across SortedMaps than RowResults. 
+ * convenient to interact with them that way. It is also much easier to merge
+ * the results across SortedMaps than RowResults.
  *
  * <p>Additionally, we need to be able to determine if the scanner is doing
  * wildcard column matches (when only a column family is specified or if a
@@ -50,7 +50,7 @@ public interface InternalScanner extends
 
   /**
    * Grab the next row's worth of values with a limit on the number of values
-   * to return. 
+   * to return.
    * @param result
    * @param limit
    * @return true if more rows exist after this one, false if scanner is done



Mime
View raw message