hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mberto...@apache.org
Subject svn commit: r1518728 - /hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/catalog/MetaEditor.java
Date Thu, 29 Aug 2013 17:52:56 GMT
Author: mbertozzi
Date: Thu Aug 29 17:52:56 2013
New Revision: 1518728

URL: http://svn.apache.org/r1518728
Log:
HBASE-9353 HTable returned by MetaReader#getMetaHTable() is not closed in MetaEditor#addRegionToMeta()

Modified:
    hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/catalog/MetaEditor.java

Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/catalog/MetaEditor.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/catalog/MetaEditor.java?rev=1518728&r1=1518727&r2=1518728&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/catalog/MetaEditor.java
(original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/catalog/MetaEditor.java
Thu Aug 29 17:52:56 2013
@@ -111,8 +111,7 @@ public class MetaEditor {
    */
   static void putToCatalogTable(final CatalogTracker ct, final Put p)
   throws IOException {
-    HTable t = MetaReader.getCatalogHTable(ct);
-    put(t, p);
+    put(MetaReader.getCatalogHTable(ct), p);
   }
 
   /**
@@ -252,7 +251,12 @@ public class MetaEditor {
    */
   public static void addRegionToMeta(CatalogTracker catalogTracker, HRegionInfo regionInfo,
       HRegionInfo splitA, HRegionInfo splitB) throws IOException {
-    addRegionToMeta(MetaReader.getMetaHTable(catalogTracker), regionInfo, splitA, splitB);
+    HTable meta = MetaReader.getMetaHTable(catalogTracker);
+    try {
+      addRegionToMeta(meta, regionInfo, splitA, splitB);
+    } finally {
+      meta.close();
+    }
   }
 
   /**
@@ -306,25 +310,29 @@ public class MetaEditor {
       HRegionInfo mergedRegion, HRegionInfo regionA, HRegionInfo regionB,
       ServerName sn) throws IOException {
     HTable meta = MetaReader.getMetaHTable(catalogTracker);
-    HRegionInfo copyOfMerged = new HRegionInfo(mergedRegion);
+    try {
+      HRegionInfo copyOfMerged = new HRegionInfo(mergedRegion);
 
-    // Put for parent
-    Put putOfMerged = makePutFromRegionInfo(copyOfMerged);
-    putOfMerged.add(HConstants.CATALOG_FAMILY, HConstants.MERGEA_QUALIFIER,
-        regionA.toByteArray());
-    putOfMerged.add(HConstants.CATALOG_FAMILY, HConstants.MERGEB_QUALIFIER,
-        regionB.toByteArray());
-
-    // Deletes for merging regions
-    Delete deleteA = makeDeleteFromRegionInfo(regionA);
-    Delete deleteB = makeDeleteFromRegionInfo(regionB);
-
-    // The merged is a new region, openSeqNum = 1 is fine.
-    addLocation(putOfMerged, sn, 1);
-
-    byte[] tableRow = Bytes.toBytes(mergedRegion.getRegionNameAsString()
-        + HConstants.DELIMITER);
-    multiMutate(meta, tableRow, putOfMerged, deleteA, deleteB);
+      // Put for parent
+      Put putOfMerged = makePutFromRegionInfo(copyOfMerged);
+      putOfMerged.add(HConstants.CATALOG_FAMILY, HConstants.MERGEA_QUALIFIER,
+          regionA.toByteArray());
+      putOfMerged.add(HConstants.CATALOG_FAMILY, HConstants.MERGEB_QUALIFIER,
+          regionB.toByteArray());
+
+      // Deletes for merging regions
+      Delete deleteA = makeDeleteFromRegionInfo(regionA);
+      Delete deleteB = makeDeleteFromRegionInfo(regionB);
+
+      // The merged is a new region, openSeqNum = 1 is fine.
+      addLocation(putOfMerged, sn, 1);
+
+      byte[] tableRow = Bytes.toBytes(mergedRegion.getRegionNameAsString()
+          + HConstants.DELIMITER);
+      multiMutate(meta, tableRow, putOfMerged, deleteA, deleteB);
+    } finally {
+      meta.close();
+    }
   }
 
   /**
@@ -342,23 +350,27 @@ public class MetaEditor {
       HRegionInfo parent, HRegionInfo splitA, HRegionInfo splitB,
       ServerName sn) throws IOException {
     HTable meta = MetaReader.getMetaHTable(catalogTracker);
-    HRegionInfo copyOfParent = new HRegionInfo(parent);
-    copyOfParent.setOffline(true);
-    copyOfParent.setSplit(true);
-
-    //Put for parent
-    Put putParent = makePutFromRegionInfo(copyOfParent);
-    addDaughtersToPut(putParent, splitA, splitB);
-
-    //Puts for daughters
-    Put putA = makePutFromRegionInfo(splitA);
-    Put putB = makePutFromRegionInfo(splitB);
+    try {
+      HRegionInfo copyOfParent = new HRegionInfo(parent);
+      copyOfParent.setOffline(true);
+      copyOfParent.setSplit(true);
+
+      //Put for parent
+      Put putParent = makePutFromRegionInfo(copyOfParent);
+      addDaughtersToPut(putParent, splitA, splitB);
+
+      //Puts for daughters
+      Put putA = makePutFromRegionInfo(splitA);
+      Put putB = makePutFromRegionInfo(splitB);
 
-    addLocation(putA, sn, 1); //these are new regions, openSeqNum = 1 is fine.
-    addLocation(putB, sn, 1);
+      addLocation(putA, sn, 1); //these are new regions, openSeqNum = 1 is fine.
+      addLocation(putB, sn, 1);
 
-    byte[] tableRow = Bytes.toBytes(parent.getRegionNameAsString() + HConstants.DELIMITER);
-    multiMutate(meta, tableRow, putParent, putA, putB);
+      byte[] tableRow = Bytes.toBytes(parent.getRegionNameAsString() + HConstants.DELIMITER);
+      multiMutate(meta, tableRow, putParent, putA, putB);
+    } finally {
+      meta.close();
+    }
   }
 
   /**



Mime
View raw message