hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mberto...@apache.org
Subject svn commit: r1449400 - in /hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase: master/handler/CreateTableHandler.java util/ModifyRegionUtils.java
Date Sat, 23 Feb 2013 20:02:52 GMT
Author: mbertozzi
Date: Sat Feb 23 20:02:52 2013
New Revision: 1449400

URL: http://svn.apache.org/r1449400
Log:
HBASE-7911 Remove duplicated code from CreateTableHandler

Modified:
    hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/CreateTableHandler.java
    hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/util/ModifyRegionUtils.java

Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/CreateTableHandler.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/CreateTableHandler.java?rev=1449400&r1=1449399&r2=1449400&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/CreateTableHandler.java
(original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/CreateTableHandler.java
Sat Feb 23 20:02:52 2013
@@ -55,6 +55,7 @@ import org.apache.hadoop.hbase.master.Ta
 import org.apache.hadoop.hbase.master.TableLockManager.TableLock;
 import org.apache.hadoop.hbase.regionserver.HRegion;
 import org.apache.hadoop.hbase.util.FSTableDescriptors;
+import org.apache.hadoop.hbase.util.ModifyRegionUtils;
 import org.apache.hadoop.hbase.util.Threads;
 import org.apache.zookeeper.KeeperException;
 
@@ -255,59 +256,7 @@ public class CreateTableHandler extends 
   protected List<HRegionInfo> handleCreateHdfsRegions(final Path tableRootDir,
     final String tableName)
       throws IOException {
-    int regionNumber = newRegions.length;
-    ThreadPoolExecutor regionOpenAndInitThreadPool = getRegionOpenAndInitThreadPool(
-        "RegionOpenAndInitThread-" + tableName, regionNumber);
-    CompletionService<HRegion> completionService = new ExecutorCompletionService<HRegion>(
-        regionOpenAndInitThreadPool);
-
-    List<HRegionInfo> regionInfos = new ArrayList<HRegionInfo>();
-    for (final HRegionInfo newRegion : newRegions) {
-      completionService.submit(new Callable<HRegion>() {
-        public HRegion call() throws IOException {
-
-          // 1. Create HRegion
-          HRegion region = HRegion.createHRegion(newRegion,
-              tableRootDir, conf, hTableDescriptor, null,
-              false, true);
-          // 2. Close the new region to flush to disk. Close log file too.
-          region.close();
-          return region;
-        }
-      });
-    }
-    try {
-      // 3. wait for all regions to finish creation
-      for (int i = 0; i < regionNumber; i++) {
-        Future<HRegion> future = completionService.take();
-        HRegion region = future.get();
-        regionInfos.add(region.getRegionInfo());
-      }
-    } catch (InterruptedException e) {
-      throw new InterruptedIOException(e.getMessage());
-    } catch (ExecutionException e) {
-      throw new IOException(e.getCause());
-    } finally {
-      regionOpenAndInitThreadPool.shutdownNow();
-    }
-
-    return regionInfos;
-  }
-
-  protected ThreadPoolExecutor getRegionOpenAndInitThreadPool(
-      final String threadNamePrefix, int regionNumber) {
-    int maxThreads = Math.min(regionNumber, conf.getInt(
-        "hbase.hregion.open.and.init.threads.max", 10));
-    ThreadPoolExecutor openAndInitializeThreadPool = Threads
-    .getBoundedCachedThreadPool(maxThreads, 30L, TimeUnit.SECONDS,
-        new ThreadFactory() {
-          private int count = 1;
-
-          public Thread newThread(Runnable r) {
-            Thread t = new Thread(r, threadNamePrefix + "-" + count++);
-            return t;
-          }
-        });
-    return openAndInitializeThreadPool;
+    return ModifyRegionUtils.createRegions(conf, tableRootDir,
+        hTableDescriptor, newRegions, null);
   }
 }

Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/util/ModifyRegionUtils.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/util/ModifyRegionUtils.java?rev=1449400&r1=1449399&r2=1449400&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/util/ModifyRegionUtils.java
(original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/util/ModifyRegionUtils.java
Sat Feb 23 20:02:52 2013
@@ -106,8 +106,6 @@ public abstract class ModifyRegionUtils 
           HRegion region = HRegion.createHRegion(newRegion,
               rootDir, conf, hTableDescriptor, null,
               false, true);
-          HRegion.writeRegioninfoOnFilesystem(region.getRegionInfo(), region.getRegionDir(),
-            region.getFilesystem(), conf);
           try {
             // 2. Custom user code to interact with the created region
             if (task != null) {
@@ -176,26 +174,4 @@ public abstract class ModifyRegionUtils 
       throw new InterruptedIOException(e.getMessage());
     }
   }
-
-  /**
-   * Remove specified regions by removing them from file-system and .META.
-   * (The regions must be offline).
-   *
-   * @param fs {@link FileSystem} on which to delete the region directory
-   * @param catalogTracker the catalog tracker
-   * @param regions list of {@link HRegionInfo} to delete.
-   */
-  public static void deleteRegions(final Configuration conf, final FileSystem fs,
-      final CatalogTracker catalogTracker, final List<HRegionInfo> regions) throws
IOException {
-    if (regions != null && regions.size() > 0) {
-      List<Delete> deletes = new ArrayList<Delete>(regions.size());
-      for (HRegionInfo hri: regions) {
-        deletes.add(new Delete(hri.getRegionName()));
-        
-        // "Delete" region from FS
-        HFileArchiver.archiveRegion(conf, fs, hri);
-      }
-      MetaEditor.deleteFromMetaTable(catalogTracker, deletes);
-    }
-  }
 }



Mime
View raw message