phoenix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jamestay...@apache.org
Subject [19/23] phoenix git commit: Remove statics in OmidTransactionProcessor (but still could use more work)
Date Tue, 12 Jun 2018 04:49:04 GMT
Remove statics in OmidTransactionProcessor (but still could use more work)


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/57a1f11a
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/57a1f11a
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/57a1f11a

Branch: refs/heads/omid2
Commit: 57a1f11ae4aa02633e95436e7b32945d3803ac65
Parents: a220bc5
Author: James Taylor <jtaylor@salesforce.com>
Authored: Thu May 31 10:13:24 2018 -0700
Committer: James Taylor <jtaylor@salesforce.com>
Committed: Thu May 31 10:13:24 2018 -0700

----------------------------------------------------------------------
 .../coprocessor/OmidTransactionalProcessor.java |  4 ++-
 .../transaction/OmidTransactionProvider.java    | 28 +++++++++++++-------
 .../phoenix/query/QueryServicesTestImpl.java    |  5 +++-
 3 files changed, 26 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/57a1f11a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/OmidTransactionalProcessor.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/OmidTransactionalProcessor.java
b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/OmidTransactionalProcessor.java
index db3f622..b84b5ae 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/OmidTransactionalProcessor.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/OmidTransactionalProcessor.java
@@ -24,7 +24,9 @@ import org.apache.phoenix.transaction.OmidTransactionProvider;
 public class OmidTransactionalProcessor extends DelegateRegionObserver {
 
     public OmidTransactionalProcessor() {
-        super(new OmidSnapshotFilter(OmidTransactionProvider.commitTableClient));
+        // Hack for testing - retrieves the commit table client from the singleton OmidTransactionProvider
+        // TODO: use real commit table and get port from config
+        super(new OmidSnapshotFilter(OmidTransactionProvider.getInstance().getCommitTableClient()));
     }
 
 }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/57a1f11a/phoenix-core/src/main/java/org/apache/phoenix/transaction/OmidTransactionProvider.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/transaction/OmidTransactionProvider.java
b/phoenix-core/src/main/java/org/apache/phoenix/transaction/OmidTransactionProvider.java
index 5f9af99..01ebb88 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/transaction/OmidTransactionProvider.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/transaction/OmidTransactionProvider.java
@@ -20,7 +20,6 @@ package org.apache.phoenix.transaction;
 import java.io.IOException;
 import java.sql.SQLException;
 import java.util.Arrays;
-import java.util.Random;
 
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hbase.coprocessor.RegionObserver;
@@ -46,18 +45,20 @@ import com.google.inject.Injector;
 
 public class OmidTransactionProvider implements PhoenixTransactionProvider {
     private static final OmidTransactionProvider INSTANCE = new OmidTransactionProvider();
+    public static final String OMID_TSO_PORT = "phoenix.omid.tso.port";
+    public static final String OMID_TSO_CONFLICT_MAP_SIZE = "phoenix.omid.tso.conflict.map.size";
+    public static final String OMID_TSO_TIMESTAMP_TYPE = "phoenix.omid.tso.timestamp.type";
+    public static final int DEFAULT_OMID_TSO_CONFLICT_MAP_SIZE = 1000;
+    public static final String DEFAULT_OMID_TSO_TIMESTAMP_TYPE = "WORLD_TIME";
 
-    private static HBaseTransactionManager transactionManager = null;
-
-    private Random rand = new Random();
-    public static CommitTable.Client commitTableClient = null;
+    private HBaseTransactionManager transactionManager = null;
+    private volatile CommitTable.Client commitTableClient = null;
 
     public static final OmidTransactionProvider getInstance() {
         return INSTANCE;
     }
 
     private OmidTransactionProvider() {
-        ;
     }
 
     @Override
@@ -104,16 +105,25 @@ public class OmidTransactionProvider implements PhoenixTransactionProvider
{
         public void close() throws IOException {}
     }
 
+    // For testing only
+    public CommitTable.Client getCommitTableClient() {
+        return commitTableClient;
+    }
+    
     @Override
     public PhoenixTransactionService getTransactionService(Configuration config, ConnectionInfo
connectionInfo) throws  SQLException{
         TSOServerConfig tsoConfig = new TSOServerConfig();
         TSOServer tso;
 
-        int  port = rand.nextInt(65534) + 1;
+        String portStr = config.get(OMID_TSO_PORT);
+        if (portStr == null) {
+            throw new IllegalArgumentException(OMID_TSO_PORT + " config parameter must be
bound");
+        }
+        int  port = Integer.parseInt(portStr);
 
         tsoConfig.setPort(port);
-        tsoConfig.setConflictMapSize(1000);
-        tsoConfig.setTimestampType("WORLD_TIME");
+        tsoConfig.setConflictMapSize(config.getInt(OMID_TSO_CONFLICT_MAP_SIZE, DEFAULT_OMID_TSO_CONFLICT_MAP_SIZE));
+        tsoConfig.setTimestampType(config.get(OMID_TSO_TIMESTAMP_TYPE, DEFAULT_OMID_TSO_TIMESTAMP_TYPE));
 
         Injector injector = Guice.createInjector(new TSOMockModule(tsoConfig));
         tso = injector.getInstance(TSOServer.class);

http://git-wip-us.apache.org/repos/asf/phoenix/blob/57a1f11a/phoenix-core/src/test/java/org/apache/phoenix/query/QueryServicesTestImpl.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/test/java/org/apache/phoenix/query/QueryServicesTestImpl.java
b/phoenix-core/src/test/java/org/apache/phoenix/query/QueryServicesTestImpl.java
index e279074..841abb6 100644
--- a/phoenix-core/src/test/java/org/apache/phoenix/query/QueryServicesTestImpl.java
+++ b/phoenix-core/src/test/java/org/apache/phoenix/query/QueryServicesTestImpl.java
@@ -22,6 +22,7 @@ import static org.apache.phoenix.query.QueryServicesOptions.withDefaults;
 
 import org.apache.curator.shaded.com.google.common.io.Files;
 import org.apache.hadoop.hbase.regionserver.wal.IndexedWALEditCodec;
+import org.apache.phoenix.transaction.OmidTransactionProvider;
 import org.apache.phoenix.util.PhoenixRuntime;
 import org.apache.phoenix.util.ReadOnlyProps;
 import org.apache.tephra.TxConstants;
@@ -124,7 +125,7 @@ public final class QueryServicesTestImpl extends BaseQueryServicesImpl
{
                 .setDefaultIndexPopulationWaitTime(DEFAULT_INDEX_POPULATION_WAIT_TIME)
                 .setIndexRebuildTaskInitialDelay(DEFAULT_INDEX_REBUILD_TASK_INITIAL_DELAY)
                 .set(AGGREGATE_CHUNK_SIZE_INCREASE_ATTRIB, DEFAULT_AGGREGATE_CHUNK_SIZE_INCREASE)
-                // setup default configs for Tephra
+                // setup default test configs for Tephra
                 .set(TxConstants.Manager.CFG_DO_PERSIST, false)
                 .set(TxConstants.Service.CFG_DATA_TX_CLIENT_RETRY_STRATEGY, "n-times")
                 .set(TxConstants.Service.CFG_DATA_TX_CLIENT_ATTEMPTS, 1)
@@ -132,6 +133,8 @@ public final class QueryServicesTestImpl extends BaseQueryServicesImpl
{
                 .set(TxConstants.Manager.CFG_TX_SNAPSHOT_DIR, Files.createTempDir().getAbsolutePath())
                 .set(TxConstants.Manager.CFG_TX_TIMEOUT, DEFAULT_TXN_TIMEOUT_SECONDS)
                 .set(TxConstants.Manager.CFG_TX_SNAPSHOT_INTERVAL, 5L)
+                // setup default test configs for Omid
+                .set(OmidTransactionProvider.OMID_TSO_PORT, Networks.getRandomPort())
                 ;
     }
     


Mime
View raw message