Author: stack Date: Mon Apr 26 17:53:19 2010 New Revision: 938154 URL: http://svn.apache.org/viewvc?rev=938154&view=rev Log: Remove of mistaken commit
Modified: hadoop/hbase/branches/0.20_pre_durability/src/contrib/transactional/src/java/org/apache/hadoop/hbase/client/transactional/HBaseBackedTransactionLogger.java hadoop/hbase/branches/0.20_pre_durability/src/contrib/transactional/src/java/org/apache/hadoop/hbase/regionserver/tableindexed/IndexedRegion.java Modified: hadoop/hbase/branches/0.20_pre_durability/src/contrib/transactional/src/java/org/apache/hadoop/hbase/client/transactional/HBaseBackedTransactionLogger.java URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.20_pre_durability/src/contrib/transactional/src/java/org/apache/hadoop/hbase/client/transactional/HBaseBackedTransactionLogger.java?rev=938154&r1=938153&r2=938154&view=diff ============================================================================== --- hadoop/hbase/branches/0.20_pre_durability/src/contrib/transactional/src/java/org/apache/hadoop/hbase/client/transactional/HBaseBackedTransactionLogger.java (original) +++ hadoop/hbase/branches/0.20_pre_durability/src/contrib/transactional/src/java/org/apache/hadoop/hbase/client/transactional/HBaseBackedTransactionLogger.java Mon Apr 26 17:53:19 2010 @@ -30,7 +30,6 @@ import org.apache.hadoop.hbase.client.De import org.apache.hadoop.hbase.client.Get; import org.apache.hadoop.hbase.client.HBaseAdmin; import org.apache.hadoop.hbase.client.HTable; -import org.apache.hadoop.hbase.client.HTablePool; import org.apache.hadoop.hbase.client.Put; import org.apache.hadoop.hbase.client.Result; import org.apache.hadoop.hbase.util.Bytes; @@ -64,19 +63,8 @@ public class HBaseBackedTransactionLogge } private Random random = new Random(); - private HTablePool tablePool = new HTablePool(); + private HTable table; - private HTable getTable() { - return tablePool.getTable(TABLE_NAME); - } - - private void putTable(HTable t) { - if (t == null) { - return; - } - tablePool.putTable(t); - } - public HBaseBackedTransactionLogger() throws IOException { initTable(); } @@ -87,6 +75,8 @@ public class HBaseBackedTransactionLogge if (!admin.tableExists(TABLE_NAME)) { throw new RuntimeException("Table not created. Call createTable() first"); } + this.table = new HTable(TABLE_NAME); + } public long createNewTransactionLog() { @@ -95,11 +85,7 @@ public class HBaseBackedTransactionLogge do { id = random.nextLong(); - try { existing = getStatusForTransaction(id); - } catch (IOException e) { - throw new RuntimeException(e); - } } while (existing != null); setStatusForTransaction(id, TransactionStatus.PENDING); @@ -107,8 +93,7 @@ public class HBaseBackedTransactionLogge return id; } - public TransactionStatus getStatusForTransaction(long transactionId) throws IOException { - HTable table = getTable(); + public TransactionStatus getStatusForTransaction(long transactionId) { try { Result result = table.get(new Get(getRow(transactionId))); if (result == null || result.isEmpty()) { @@ -123,8 +108,6 @@ public class HBaseBackedTransactionLogge } catch (IOException e) { throw new RuntimeException(e); - }finally { - putTable(table); } } @@ -137,26 +120,20 @@ public class HBaseBackedTransactionLogge Put update = new Put(getRow(transactionId)); update.add(STATUS_COLUMN_BYTES, HConstants.LATEST_TIMESTAMP, Bytes.toBytes(status.name())); - HTable table = getTable(); try { table.put(update); } catch (IOException e) { throw new RuntimeException(e); - } finally { - putTable(table); } } public void forgetTransaction(long transactionId) { Delete delete = new Delete(getRow(transactionId)); - - HTable table = getTable(); + try { table.delete(delete); } catch (IOException e) { throw new RuntimeException(e); - }finally { - putTable(table); } } Modified: hadoop/hbase/branches/0.20_pre_durability/src/contrib/transactional/src/java/org/apache/hadoop/hbase/regionserver/tableindexed/IndexedRegion.java URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.20_pre_durability/src/contrib/transactional/src/java/org/apache/hadoop/hbase/regionserver/tableindexed/IndexedRegion.java?rev=938154&r1=938153&r2=938154&view=diff ============================================================================== --- hadoop/hbase/branches/0.20_pre_durability/src/contrib/transactional/src/java/org/apache/hadoop/hbase/regionserver/tableindexed/IndexedRegion.java (original) +++ hadoop/hbase/branches/0.20_pre_durability/src/contrib/transactional/src/java/org/apache/hadoop/hbase/regionserver/tableindexed/IndexedRegion.java Mon Apr 26 17:53:19 2010 @@ -44,7 +44,6 @@ import org.apache.hadoop.hbase.Leases; import org.apache.hadoop.hbase.client.Delete; import org.apache.hadoop.hbase.client.Get; import org.apache.hadoop.hbase.client.HTable; -import org.apache.hadoop.hbase.client.HTablePool; import org.apache.hadoop.hbase.client.Put; import org.apache.hadoop.hbase.client.Result; import org.apache.hadoop.hbase.client.tableindexed.IndexSpecification; @@ -60,7 +59,7 @@ class IndexedRegion extends Transactiona private final HBaseConfiguration conf; private final IndexedTableDescriptor indexTableDescriptor; - private final HTablePool tablePool; + private Map<IndexSpecification, HTable> indexSpecToTable = new HashMap<IndexSpecification, HTable>(); public IndexedRegion(final Path basedir, final HLog log, final FileSystem fs, final HBaseConfiguration conf, final HRegionInfo regionInfo, @@ -68,20 +67,17 @@ class IndexedRegion extends Transactiona super(basedir, log, fs, conf, regionInfo, flushListener, trxLeases); this.indexTableDescriptor = new IndexedTableDescriptor(regionInfo.getTableDesc()); this.conf = conf; - this.tablePool = new HTablePool(); } - private HTable getIndexTable(IndexSpecification index) + private synchronized HTable getIndexTable(IndexSpecification index) throws IOException { - return tablePool.getTable(index.getIndexedTableName(super + HTable indexTable = indexSpecToTable.get(index); + if (indexTable == null) { + indexTable = new HTable(conf, index.getIndexedTableName(super .getRegionInfo().getTableDesc().getName())); - } - - private void putTable(HTable t) { - if (t==null) { - return; + indexSpecToTable.put(index, indexTable); } - tablePool.putTable(t); + return indexTable; } private Collection<IndexSpecification> getIndexes() {