phoenix git commit: PHOENIX-4162 Disallow transition from DISABLE to INACTIVE when INDEX_DISABLE_TIMESTAMP is zero

2017-09-06 Thread jamestaylor
Repository: phoenix
Updated Branches:
  refs/heads/4.x-HBase-1.2 3ae9f552a -> 0718e01e1


PHOENIX-4162 Disallow transition from DISABLE to INACTIVE when 
INDEX_DISABLE_TIMESTAMP is zero


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

Branch: refs/heads/4.x-HBase-1.2
Commit: 0718e01e10f25a25ffeb9954439d240dc7fe9ff2
Parents: 3ae9f55
Author: James Taylor 
Authored: Tue Sep 5 18:52:02 2017 -0700
Committer: James Taylor 
Committed: Wed Sep 6 00:29:39 2017 -0700

--
 .../phoenix/end2end/MetaDataEndPointIT.java | 55 +++
 .../end2end/index/PartialIndexRebuilderIT.java  | 12 ++--
 .../coprocessor/MetaDataEndpointImpl.java   | 70 ++--
 3 files changed, 98 insertions(+), 39 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/0718e01e/phoenix-core/src/it/java/org/apache/phoenix/end2end/MetaDataEndPointIT.java
--
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/MetaDataEndPointIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/MetaDataEndPointIT.java
new file mode 100644
index 000..08b8cc6
--- /dev/null
+++ 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/MetaDataEndPointIT.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.phoenix.end2end;
+
+import static org.junit.Assert.assertEquals;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+
+import org.apache.hadoop.hbase.client.HTableInterface;
+import org.apache.phoenix.coprocessor.MetaDataProtocol.MutationCode;
+import org.apache.phoenix.jdbc.PhoenixConnection;
+import org.apache.phoenix.jdbc.PhoenixDatabaseMetaData;
+import org.apache.phoenix.schema.PIndexState;
+import org.apache.phoenix.util.EnvironmentEdgeManager;
+import org.apache.phoenix.util.IndexUtil;
+import org.apache.phoenix.util.SchemaUtil;
+import org.junit.Test;
+
+public class MetaDataEndPointIT extends ParallelStatsDisabledIT {
+@Test
+   public void testUpdateIndexState() throws Throwable {
+String schemaName = generateUniqueName();
+String tableName = generateUniqueName();
+String indexName1 = generateUniqueName();
+final String fullTableName = SchemaUtil.getTableName(schemaName, 
tableName);
+String fullIndexName1 = SchemaUtil.getTableName(schemaName, 
indexName1);
+try (Connection conn = DriverManager.getConnection(getUrl())) {
+conn.createStatement().execute("CREATE TABLE " + fullTableName + 
"(k INTEGER PRIMARY KEY, v1 INTEGER, v2 INTEGER) COLUMN_ENCODED_BYTES = 0, 
STORE_NULLS=true, GUIDE_POSTS_WIDTH=1000");
+conn.createStatement().execute("CREATE INDEX " + indexName1 + " ON 
" + fullTableName + " (v1) INCLUDE (v2)");
+conn.commit();
+HTableInterface metaTable = 
conn.unwrap(PhoenixConnection.class).getQueryServices().getTable(PhoenixDatabaseMetaData.SYSTEM_CATALOG_NAME_BYTES);
+MutationCode code = IndexUtil.updateIndexState(fullIndexName1, 0L, 
metaTable, PIndexState.DISABLE).getMutationCode();
+assertEquals(MutationCode.TABLE_ALREADY_EXISTS, code);
+long ts = EnvironmentEdgeManager.currentTimeMillis();
+code = IndexUtil.updateIndexState(fullIndexName1, ts, metaTable, 
PIndexState.INACTIVE).getMutationCode();
+assertEquals(MutationCode.UNALLOWED_TABLE_MUTATION, code);
+}
+   }
+}

http://git-wip-us.apache.org/repos/asf/phoenix/blob/0718e01e/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/PartialIndexRebuilderIT.java
--
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/PartialIndexRebuilderIT.java
 

phoenix git commit: PHOENIX-4162 Disallow transition from DISABLE to INACTIVE when INDEX_DISABLE_TIMESTAMP is zero

2017-09-06 Thread jamestaylor
Repository: phoenix
Updated Branches:
  refs/heads/4.x-HBase-1.1 7151d610e -> 9e5cb5d2e


PHOENIX-4162 Disallow transition from DISABLE to INACTIVE when 
INDEX_DISABLE_TIMESTAMP is zero


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

Branch: refs/heads/4.x-HBase-1.1
Commit: 9e5cb5d2e7957a005a63616370cddf837c53792d
Parents: 7151d61
Author: James Taylor 
Authored: Tue Sep 5 18:52:02 2017 -0700
Committer: James Taylor 
Committed: Wed Sep 6 00:28:21 2017 -0700

--
 .../phoenix/end2end/MetaDataEndPointIT.java | 55 +++
 .../end2end/index/PartialIndexRebuilderIT.java  | 12 ++--
 .../coprocessor/MetaDataEndpointImpl.java   | 70 ++--
 3 files changed, 98 insertions(+), 39 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/9e5cb5d2/phoenix-core/src/it/java/org/apache/phoenix/end2end/MetaDataEndPointIT.java
--
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/MetaDataEndPointIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/MetaDataEndPointIT.java
new file mode 100644
index 000..08b8cc6
--- /dev/null
+++ 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/MetaDataEndPointIT.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.phoenix.end2end;
+
+import static org.junit.Assert.assertEquals;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+
+import org.apache.hadoop.hbase.client.HTableInterface;
+import org.apache.phoenix.coprocessor.MetaDataProtocol.MutationCode;
+import org.apache.phoenix.jdbc.PhoenixConnection;
+import org.apache.phoenix.jdbc.PhoenixDatabaseMetaData;
+import org.apache.phoenix.schema.PIndexState;
+import org.apache.phoenix.util.EnvironmentEdgeManager;
+import org.apache.phoenix.util.IndexUtil;
+import org.apache.phoenix.util.SchemaUtil;
+import org.junit.Test;
+
+public class MetaDataEndPointIT extends ParallelStatsDisabledIT {
+@Test
+   public void testUpdateIndexState() throws Throwable {
+String schemaName = generateUniqueName();
+String tableName = generateUniqueName();
+String indexName1 = generateUniqueName();
+final String fullTableName = SchemaUtil.getTableName(schemaName, 
tableName);
+String fullIndexName1 = SchemaUtil.getTableName(schemaName, 
indexName1);
+try (Connection conn = DriverManager.getConnection(getUrl())) {
+conn.createStatement().execute("CREATE TABLE " + fullTableName + 
"(k INTEGER PRIMARY KEY, v1 INTEGER, v2 INTEGER) COLUMN_ENCODED_BYTES = 0, 
STORE_NULLS=true, GUIDE_POSTS_WIDTH=1000");
+conn.createStatement().execute("CREATE INDEX " + indexName1 + " ON 
" + fullTableName + " (v1) INCLUDE (v2)");
+conn.commit();
+HTableInterface metaTable = 
conn.unwrap(PhoenixConnection.class).getQueryServices().getTable(PhoenixDatabaseMetaData.SYSTEM_CATALOG_NAME_BYTES);
+MutationCode code = IndexUtil.updateIndexState(fullIndexName1, 0L, 
metaTable, PIndexState.DISABLE).getMutationCode();
+assertEquals(MutationCode.TABLE_ALREADY_EXISTS, code);
+long ts = EnvironmentEdgeManager.currentTimeMillis();
+code = IndexUtil.updateIndexState(fullIndexName1, ts, metaTable, 
PIndexState.INACTIVE).getMutationCode();
+assertEquals(MutationCode.UNALLOWED_TABLE_MUTATION, code);
+}
+   }
+}

http://git-wip-us.apache.org/repos/asf/phoenix/blob/9e5cb5d2/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/PartialIndexRebuilderIT.java
--
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/PartialIndexRebuilderIT.java
 

phoenix git commit: PHOENIX-4162 Disallow transition from DISABLE to INACTIVE when INDEX_DISABLE_TIMESTAMP is zero

2017-09-06 Thread jamestaylor
Repository: phoenix
Updated Branches:
  refs/heads/4.x-HBase-0.98 c5fe17624 -> 94ef3eb3b


PHOENIX-4162 Disallow transition from DISABLE to INACTIVE when 
INDEX_DISABLE_TIMESTAMP is zero


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

Branch: refs/heads/4.x-HBase-0.98
Commit: 94ef3eb3b360b8f8802c95fc618087aeef1dcf38
Parents: c5fe176
Author: James Taylor 
Authored: Tue Sep 5 18:52:02 2017 -0700
Committer: James Taylor 
Committed: Wed Sep 6 00:26:53 2017 -0700

--
 .../phoenix/end2end/MetaDataEndPointIT.java | 55 +++
 .../end2end/index/PartialIndexRebuilderIT.java  | 12 ++--
 .../coprocessor/MetaDataEndpointImpl.java   | 70 ++--
 3 files changed, 98 insertions(+), 39 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/94ef3eb3/phoenix-core/src/it/java/org/apache/phoenix/end2end/MetaDataEndPointIT.java
--
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/MetaDataEndPointIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/MetaDataEndPointIT.java
new file mode 100644
index 000..08b8cc6
--- /dev/null
+++ 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/MetaDataEndPointIT.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.phoenix.end2end;
+
+import static org.junit.Assert.assertEquals;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+
+import org.apache.hadoop.hbase.client.HTableInterface;
+import org.apache.phoenix.coprocessor.MetaDataProtocol.MutationCode;
+import org.apache.phoenix.jdbc.PhoenixConnection;
+import org.apache.phoenix.jdbc.PhoenixDatabaseMetaData;
+import org.apache.phoenix.schema.PIndexState;
+import org.apache.phoenix.util.EnvironmentEdgeManager;
+import org.apache.phoenix.util.IndexUtil;
+import org.apache.phoenix.util.SchemaUtil;
+import org.junit.Test;
+
+public class MetaDataEndPointIT extends ParallelStatsDisabledIT {
+@Test
+   public void testUpdateIndexState() throws Throwable {
+String schemaName = generateUniqueName();
+String tableName = generateUniqueName();
+String indexName1 = generateUniqueName();
+final String fullTableName = SchemaUtil.getTableName(schemaName, 
tableName);
+String fullIndexName1 = SchemaUtil.getTableName(schemaName, 
indexName1);
+try (Connection conn = DriverManager.getConnection(getUrl())) {
+conn.createStatement().execute("CREATE TABLE " + fullTableName + 
"(k INTEGER PRIMARY KEY, v1 INTEGER, v2 INTEGER) COLUMN_ENCODED_BYTES = 0, 
STORE_NULLS=true, GUIDE_POSTS_WIDTH=1000");
+conn.createStatement().execute("CREATE INDEX " + indexName1 + " ON 
" + fullTableName + " (v1) INCLUDE (v2)");
+conn.commit();
+HTableInterface metaTable = 
conn.unwrap(PhoenixConnection.class).getQueryServices().getTable(PhoenixDatabaseMetaData.SYSTEM_CATALOG_NAME_BYTES);
+MutationCode code = IndexUtil.updateIndexState(fullIndexName1, 0L, 
metaTable, PIndexState.DISABLE).getMutationCode();
+assertEquals(MutationCode.TABLE_ALREADY_EXISTS, code);
+long ts = EnvironmentEdgeManager.currentTimeMillis();
+code = IndexUtil.updateIndexState(fullIndexName1, ts, metaTable, 
PIndexState.INACTIVE).getMutationCode();
+assertEquals(MutationCode.UNALLOWED_TABLE_MUTATION, code);
+}
+   }
+}

http://git-wip-us.apache.org/repos/asf/phoenix/blob/94ef3eb3/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/PartialIndexRebuilderIT.java
--
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/PartialIndexRebuilderIT.java