You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by je...@apache.org on 2014/03/05 23:54:58 UTC
[12/50] [abbrv] git commit: PHOENIX-100 Relax compatibility check to
only check that the major version matches between the client and server jars
(JamesTaylor)
PHOENIX-100 Relax compatibility check to only check that the major version matches between the client and server jars (JamesTaylor)
Project: http://git-wip-us.apache.org/repos/asf/incubator-phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-phoenix/commit/4e044a77
Tree: http://git-wip-us.apache.org/repos/asf/incubator-phoenix/tree/4e044a77
Diff: http://git-wip-us.apache.org/repos/asf/incubator-phoenix/diff/4e044a77
Branch: refs/heads/4.0
Commit: 4e044a77ef4fa54c365a2a4f20d7ec272a7b6a98
Parents: c0757e3
Author: James Taylor <ja...@apache.org>
Authored: Mon Mar 3 01:27:23 2014 -0800
Committer: James Taylor <ja...@apache.org>
Committed: Mon Mar 3 01:27:23 2014 -0800
----------------------------------------------------------------------
.../org/apache/phoenix/util/MetaDataUtil.java | 29 +++++++++++++++-----
.../apache/phoenix/util/MetaDataUtilTest.java | 14 ++++++----
2 files changed, 30 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-phoenix/blob/4e044a77/phoenix-core/src/main/java/org/apache/phoenix/util/MetaDataUtil.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/util/MetaDataUtil.java b/phoenix-core/src/main/java/org/apache/phoenix/util/MetaDataUtil.java
index e080d83..adf7f98 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/util/MetaDataUtil.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/util/MetaDataUtil.java
@@ -52,18 +52,20 @@ public class MetaDataUtil {
public static final String VIEW_INDEX_ID_COLUMN_NAME = "_INDEX_ID";
public static boolean areClientAndServerCompatible(long version) {
- // A server and client with the same major and minor version number must be compatible.
- // So it's important that we roll the PHOENIX_MAJOR_VERSION or PHOENIX_MINOR_VERSION
- // when we make an incompatible change.
- return areClientAndServerCompatible(MetaDataUtil.decodePhoenixVersion(version), MetaDataProtocol.PHOENIX_MAJOR_VERSION, MetaDataProtocol.PHOENIX_MINOR_VERSION);
+ // As of 3.0, we allow a client and server to differ for the minor version.
+ // Care has to be taken to upgrade the server before the client, as otherwise
+ // the client may call expressions that don't yet exist on the server.
+ // Differing by the patch version has always been allowed.
+ // Only differing by the major version is not allowed.
+ return areClientAndServerCompatible(MetaDataUtil.decodePhoenixVersion(version), MetaDataProtocol.PHOENIX_MAJOR_VERSION);
}
- // For testing
- static boolean areClientAndServerCompatible(int version, int pMajor, int pMinor) {
+ // Default scope for testing
+ static boolean areClientAndServerCompatible(int version, int pMajor) {
// A server and client with the same major and minor version number must be compatible.
// So it's important that we roll the PHOENIX_MAJOR_VERSION or PHOENIX_MINOR_VERSION
// when we make an incompatible change.
- return MetaDataUtil.encodeMaxPatchVersion(pMajor, pMinor) >= version && MetaDataUtil.encodeMinPatchVersion(pMajor, pMinor) <= version;
+ return MetaDataUtil.encodeMaxMinorVersion(pMajor) >= version && MetaDataUtil.encodeMinMinorVersion(pMajor) <= version;
}
// Given the encoded integer representing the phoenix version in the encoded version value.
@@ -144,6 +146,19 @@ public class MetaDataUtil {
return version;
}
+ public static int encodeMaxMinorVersion(int major) {
+ int version = 0;
+ version |= (major << Byte.SIZE * 2);
+ version |= 0xFFFF;
+ return version;
+ }
+
+ public static int encodeMinMinorVersion(int major) {
+ int version = 0;
+ version |= (major << Byte.SIZE * 2);
+ return version;
+ }
+
public static void getTenantIdAndSchemaAndTableName(List<Mutation> tableMetadata, byte[][] rowKeyMetaData) {
Mutation m = getTableHeaderRow(tableMetadata);
getVarChars(m.getRow(), 3, rowKeyMetaData);
http://git-wip-us.apache.org/repos/asf/incubator-phoenix/blob/4e044a77/phoenix-core/src/test/java/org/apache/phoenix/util/MetaDataUtilTest.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/test/java/org/apache/phoenix/util/MetaDataUtilTest.java b/phoenix-core/src/test/java/org/apache/phoenix/util/MetaDataUtilTest.java
index 95f245e..235358e 100644
--- a/phoenix-core/src/test/java/org/apache/phoenix/util/MetaDataUtilTest.java
+++ b/phoenix-core/src/test/java/org/apache/phoenix/util/MetaDataUtilTest.java
@@ -44,12 +44,14 @@ public class MetaDataUtilTest {
@Test
public void testCompatibility() {
- assertTrue(MetaDataUtil.areClientAndServerCompatible(MetaDataUtil.encodeVersion(1,2,1), 1, 2));
- assertTrue(MetaDataUtil.areClientAndServerCompatible(MetaDataUtil.encodeVersion(1,2,10), 1, 2));
- assertTrue(MetaDataUtil.areClientAndServerCompatible(MetaDataUtil.encodeVersion(1,2,0), 1, 2));
- assertTrue(MetaDataUtil.areClientAndServerCompatible(MetaDataUtil.encodeVersion(1,2,255), 1, 2));
- assertFalse(MetaDataUtil.areClientAndServerCompatible(MetaDataUtil.encodeVersion(2,2,0), 2, 1));
- assertFalse(MetaDataUtil.areClientAndServerCompatible(MetaDataUtil.encodeVersion(3,1,10), 4, 2));
+ assertTrue(MetaDataUtil.areClientAndServerCompatible(MetaDataUtil.encodeVersion(1,2,1), 1));
+ assertTrue(MetaDataUtil.areClientAndServerCompatible(MetaDataUtil.encodeVersion(1,2,10), 1));
+ assertTrue(MetaDataUtil.areClientAndServerCompatible(MetaDataUtil.encodeVersion(1,2,0), 1));
+ assertTrue(MetaDataUtil.areClientAndServerCompatible(MetaDataUtil.encodeVersion(1,2,255), 1));
+ assertTrue(MetaDataUtil.areClientAndServerCompatible(MetaDataUtil.encodeVersion(2,2,0), 2));
+ assertTrue(MetaDataUtil.areClientAndServerCompatible(MetaDataUtil.encodeVersion(2,10,36), 2));
+ assertFalse(MetaDataUtil.areClientAndServerCompatible(MetaDataUtil.encodeVersion(3,1,10), 4));
+ assertFalse(MetaDataUtil.areClientAndServerCompatible(MetaDataUtil.encodeVersion(3,1,10), 2));
}
/**