You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by ja...@apache.org on 2018/11/16 05:22:38 UTC

phoenix git commit: Bind port later and immediately before use for Omid

Repository: phoenix
Updated Branches:
  refs/heads/omid2 960527661 -> acaa07012


Bind port later and immediately before use for Omid


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

Branch: refs/heads/omid2
Commit: acaa07012baeeaf742362f400ea1724ea3d26030
Parents: 9605276
Author: James Taylor <ja...@apache.org>
Authored: Thu Nov 15 21:22:31 2018 -0800
Committer: James Taylor <ja...@apache.org>
Committed: Thu Nov 15 21:22:31 2018 -0800

----------------------------------------------------------------------
 .../phoenix/transaction/OmidTransactionProvider.java  |  8 ++++++--
 .../java/org/apache/phoenix/util/TransactionUtil.java | 14 ++++++++++++++
 .../apache/phoenix/query/QueryServicesTestImpl.java   |  7 ++-----
 .../test/java/org/apache/phoenix/util/TestUtil.java   | 14 --------------
 pom.xml                                               |  2 +-
 5 files changed, 23 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/acaa0701/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 610a5d1..c4769b7 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
@@ -41,6 +41,7 @@ import org.apache.phoenix.exception.SQLExceptionInfo;
 import org.apache.phoenix.jdbc.PhoenixConnection;
 import org.apache.phoenix.jdbc.PhoenixEmbeddedDriver.ConnectionInfo;
 import org.apache.phoenix.transaction.TransactionFactory.Provider;
+import org.apache.phoenix.util.TransactionUtil;
 
 import com.google.inject.Guice;
 import com.google.inject.Injector;
@@ -123,11 +124,14 @@ public class OmidTransactionProvider implements PhoenixTransactionProvider {
         TSOServerConfig tsoConfig = new TSOServerConfig();
         TSOServer tso;
 
+        int port;
         String portStr = config.get(OMID_TSO_PORT);
         if (portStr == null) {
-            throw new IllegalArgumentException(OMID_TSO_PORT + " config parameter must be bound");
+            // setup default test configs for Omid
+            port = TransactionUtil.getRandomPort();
+        } else {
+            port = Integer.parseInt(portStr);
         }
-        int  port = Integer.parseInt(portStr);
 
         tsoConfig.setPort(port);
         tsoConfig.setConflictMapSize(config.getInt(OMID_TSO_CONFLICT_MAP_SIZE, DEFAULT_OMID_TSO_CONFLICT_MAP_SIZE));

http://git-wip-us.apache.org/repos/asf/phoenix/blob/acaa0701/phoenix-core/src/main/java/org/apache/phoenix/util/TransactionUtil.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/util/TransactionUtil.java b/phoenix-core/src/main/java/org/apache/phoenix/util/TransactionUtil.java
index dee02d1..9a352c0 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/util/TransactionUtil.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/util/TransactionUtil.java
@@ -18,6 +18,7 @@
 package org.apache.phoenix.util;
 
 import java.io.IOException;
+import java.net.ServerSocket;
 import java.sql.SQLException;
 import java.util.List;
 import java.util.Map;
@@ -152,4 +153,17 @@ public class TransactionUtil {
         }
         return mutation;
 	}
+
+    /**
+     * Find a random free port in localhost for binding.
+     * @return A port number or -1 for failure.
+     */
+    public static int getRandomPort() {
+        try (ServerSocket socket = new ServerSocket(0)) {
+            socket.setReuseAddress(true);
+            return socket.getLocalPort();
+        } catch (IOException e) {
+            return -1;
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/acaa0701/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 49fb8e8..db9a8c9 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,10 +22,9 @@ 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.phoenix.util.TestUtil;
+import org.apache.phoenix.util.TransactionUtil;
 import org.apache.tephra.TxConstants;
 
 
@@ -129,12 +128,10 @@ public final class QueryServicesTestImpl extends BaseQueryServicesImpl {
                 .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)
-                .set(TxConstants.Service.CFG_DATA_TX_BIND_PORT, TestUtil.getRandomPort())
+                .set(TxConstants.Service.CFG_DATA_TX_BIND_PORT, TransactionUtil.getRandomPort())
                 .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, TestUtil.getRandomPort())
                 ;
     }
     

http://git-wip-us.apache.org/repos/asf/phoenix/blob/acaa0701/phoenix-core/src/test/java/org/apache/phoenix/util/TestUtil.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/test/java/org/apache/phoenix/util/TestUtil.java b/phoenix-core/src/test/java/org/apache/phoenix/util/TestUtil.java
index f3faa0c..f0a26b9 100644
--- a/phoenix-core/src/test/java/org/apache/phoenix/util/TestUtil.java
+++ b/phoenix-core/src/test/java/org/apache/phoenix/util/TestUtil.java
@@ -36,7 +36,6 @@ import static org.junit.Assert.fail;
 import java.io.File;
 import java.io.IOException;
 import java.math.BigDecimal;
-import java.net.ServerSocket;
 import java.sql.Connection;
 import java.sql.Date;
 import java.sql.DriverManager;
@@ -1106,17 +1105,4 @@ public class TestUtil {
         }
         return filteredData;
     }
-    
-    /**
-     * Find a random free port in localhost for binding.
-     * @return A port number or -1 for failure.
-     */
-    public static int getRandomPort() {
-        try (ServerSocket socket = new ServerSocket(0)) {
-            socket.setReuseAddress(true);
-            return socket.getLocalPort();
-        } catch (IOException e) {
-            return -1;
-        }
-    }
 }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/acaa0701/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 8613fe9..b2d2c64 100644
--- a/pom.xml
+++ b/pom.xml
@@ -123,7 +123,7 @@
 
     <!-- Plugin options -->
     <numForkedUT>4</numForkedUT>
-    <numForkedIT>4</numForkedIT>
+    <numForkedIT>8</numForkedIT>
     <it.failIfNoSpecifiedTests>false</it.failIfNoSpecifiedTests>
     <surefire.failIfNoSpecifiedTests>false</surefire.failIfNoSpecifiedTests>