You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by ma...@apache.org on 2016/12/27 18:29:42 UTC

[19/50] [abbrv] phoenix git commit: PHOENIX-3482 Provide a work around for HBASE-17096

PHOENIX-3482 Provide a work around for HBASE-17096


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

Branch: refs/heads/calcite
Commit: 7cdd7ca00574a6d815d367be883952bc30d006fc
Parents: 164abe4
Author: Samarth <sa...@salesforce.com>
Authored: Wed Nov 16 17:57:35 2016 -0800
Committer: Samarth <sa...@salesforce.com>
Committed: Wed Nov 16 17:57:35 2016 -0800

----------------------------------------------------------------------
 .../query/ConnectionQueryServicesImpl.java      | 27 +++++++++++---------
 1 file changed, 15 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/7cdd7ca0/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java b/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
index cb2b82d..db4801d 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
@@ -78,7 +78,6 @@ import org.apache.hadoop.hbase.NamespaceDescriptor;
 import org.apache.hadoop.hbase.TableExistsException;
 import org.apache.hadoop.hbase.TableName;
 import org.apache.hadoop.hbase.client.Append;
-import org.apache.hadoop.hbase.client.Delete;
 import org.apache.hadoop.hbase.client.HBaseAdmin;
 import org.apache.hadoop.hbase.client.HConnection;
 import org.apache.hadoop.hbase.client.HTableInterface;
@@ -86,10 +85,8 @@ import org.apache.hadoop.hbase.client.Increment;
 import org.apache.hadoop.hbase.client.Mutation;
 import org.apache.hadoop.hbase.client.Put;
 import org.apache.hadoop.hbase.client.Result;
-import org.apache.hadoop.hbase.client.RowMutations;
 import org.apache.hadoop.hbase.client.coprocessor.Batch;
 import org.apache.hadoop.hbase.coprocessor.MultiRowMutationEndpoint;
-import org.apache.hadoop.hbase.filter.CompareFilter.CompareOp;
 import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
 import org.apache.hadoop.hbase.ipc.BlockingRpcCallback;
 import org.apache.hadoop.hbase.ipc.PhoenixRpcSchedulerFactory;
@@ -279,7 +276,8 @@ public class ConnectionQueryServicesImpl extends DelegateQueryServices implement
     private final boolean isAutoUpgradeEnabled;
     private final AtomicBoolean upgradeRequired = new AtomicBoolean(false);
     private static final byte[] UPGRADE_MUTEX = "UPGRADE_MUTEX".getBytes();
-    private static final byte[] UPGRADE_MUTEX_VALUE = UPGRADE_MUTEX; 
+    private static final byte[] UPGRADE_MUTEX_LOCKED = "UPGRADE_MUTEX_LOCKED".getBytes();
+    private static final byte[] UPGRADE_MUTEX_UNLOCKED = "UPGRADE_MUTEX_UNLOCKED".getBytes();
 
     private static interface FeatureSupported {
         boolean isSupported(ConnectionQueryServices services);
@@ -2984,6 +2982,11 @@ public class ConnectionQueryServicesImpl extends DelegateQueryServices implement
                 columnDesc.setTimeToLive(TTL_FOR_MUTEX); // Let mutex expire after some time
                 tableDesc.addFamily(columnDesc);
                 admin.createTable(tableDesc);
+                try (HTableInterface sysMutexTable = getTable(PhoenixDatabaseMetaData.SYSTEM_MUTEX_NAME_BYTES)) {
+                    Put put = new Put(rowToLock);
+                    put.addColumn(PhoenixDatabaseMetaData.SYSTEM_MUTEX_FAMILY_NAME_BYTES, UPGRADE_MUTEX, UPGRADE_MUTEX_UNLOCKED);
+                    sysMutexTable.put(put);
+                }
             } catch (TableExistsException e) {
                 // Ignore
             }
@@ -2991,11 +2994,11 @@ public class ConnectionQueryServicesImpl extends DelegateQueryServices implement
         try (HTableInterface sysMutexTable = getTable(PhoenixDatabaseMetaData.SYSTEM_MUTEX_NAME_BYTES)) {
             byte[] family = PhoenixDatabaseMetaData.SYSTEM_MUTEX_FAMILY_NAME_BYTES;
             byte[] qualifier = UPGRADE_MUTEX;
-            byte[] oldValue = null;
-            byte[] newValue = UPGRADE_MUTEX_VALUE;
+            byte[] oldValue = UPGRADE_MUTEX_UNLOCKED;
+            byte[] newValue = UPGRADE_MUTEX_LOCKED;
             Put put = new Put(rowToLock);
             put.addColumn(family, qualifier, newValue);
-            boolean acquired = sysMutexTable.checkAndPut(rowToLock, family, qualifier, oldValue, put);
+            boolean acquired =  sysMutexTable.checkAndPut(rowToLock, family, qualifier, oldValue, put);
             if (!acquired) { throw new UpgradeInProgressException(getVersion(currentServerSideTableTimestamp),
                     getVersion(MIN_SYSTEM_TABLE_TIMESTAMP)); }
             return true;
@@ -3008,11 +3011,11 @@ public class ConnectionQueryServicesImpl extends DelegateQueryServices implement
         try (HTableInterface sysMutexTable = getTable(PhoenixDatabaseMetaData.SYSTEM_MUTEX_NAME_BYTES)) {
             byte[] family = PhoenixDatabaseMetaData.SYSTEM_MUTEX_FAMILY_NAME_BYTES;
             byte[] qualifier = UPGRADE_MUTEX;
-            byte[] expectedValue = UPGRADE_MUTEX_VALUE;
-            Delete delete = new Delete(mutexRowKey);
-            RowMutations mutations = new RowMutations(mutexRowKey);
-            mutations.add(delete);
-            released = sysMutexTable.checkAndMutate(mutexRowKey, family, qualifier, CompareOp.EQUAL, expectedValue, mutations);
+            byte[] expectedValue = UPGRADE_MUTEX_LOCKED;
+            byte[] newValue = UPGRADE_MUTEX_UNLOCKED;
+            Put put = new Put(mutexRowKey);
+            put.addColumn(family, qualifier, newValue);
+            released = sysMutexTable.checkAndPut(mutexRowKey, family, qualifier, expectedValue, put);
         } catch (Exception e) {
             logger.warn("Release of upgrade mutex failed", e);
         }