yonigottesman commented on a change in pull request #58: [OMID-134] - 
transactionManager is thread safe.
URL: https://github.com/apache/incubator-omid/pull/58#discussion_r261122311
 
 

 ##########
 File path: 
hbase-client/src/main/java/org/apache/omid/transaction/HBaseSyncPostCommitter.java
 ##########
 @@ -51,29 +53,34 @@
     private final Timer commitTableUpdateTimer;
     private final Timer shadowCellsUpdateTimer;
     private static final int MAX_BATCH_SIZE=1000;
+    private final Connection connection;
 
-
-    public HBaseSyncPostCommitter(MetricsRegistry metrics, CommitTable.Client 
commitTableClient) {
+    public HBaseSyncPostCommitter(MetricsRegistry metrics, CommitTable.Client 
commitTableClient,
+                                  Connection connection) {
         this.metrics = metrics;
         this.commitTableClient = commitTableClient;
 
         this.commitTableUpdateTimer = metrics.timer(name("omid", "tm", 
"hbase", "commitTableUpdate", "latency"));
         this.shadowCellsUpdateTimer = metrics.timer(name("omid", "tm", 
"hbase", "shadowCellsUpdate", "latency"));
+        this.connection = connection;
     }
 
-    private void flushMutations(Table table, List<Mutation> mutations) throws 
IOException, InterruptedException {
-        table.batch(mutations, new Object[mutations.size()]);
+    private void flushMutations(TableName tableName, List<Mutation> mutations) 
throws IOException, InterruptedException {
+        try (Table table = connection.getTable(tableName)){
+            table.batch(mutations, new Object[mutations.size()]);
+        }
+
     }
 
     private void addShadowCell(HBaseCellId cell, HBaseTransaction tx, 
SettableFuture<Void> updateSCFuture,
-                               Map<Table,List<Mutation>> mutations) throws 
IOException, InterruptedException {
+                               Map<TableName,List<Mutation>> mutations) throws 
IOException, InterruptedException {
         Put put = new Put(cell.getRow());
         put.addColumn(cell.getFamily(),
                 CellUtils.addShadowCellSuffixPrefix(cell.getQualifier(), 0, 
cell.getQualifier().length),
                 cell.getTimestamp(),
                 Bytes.toBytes(tx.getCommitTimestamp()));
 
-        Table table = cell.getTable().getHTable();
+        TableName table = cell.getTable().getHTable().getName();
 
 Review comment:
   CellId can keep tableName and not table

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to