[2/9] phoenix git commit: PHOENIX-4519 - Index rebuild MR jobs not created for "alter index rebuild async" rebuilds
PHOENIX-4519 - Index rebuild MR jobs not created for "alter index rebuild async" rebuilds Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/352c4205 Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/352c4205 Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/352c4205 Branch: refs/heads/4.14-cdh5.13 Commit: 352c42054f5a95d6162854feffeaec3c23b4a074 Parents: 13901c3 Author: Geoffrey Authored: Fri Sep 7 00:18:09 2018 +0100 Committer: pboado Committed: Mon Dec 3 20:32:35 2018 + -- .../end2end/index/PhoenixMRJobSubmitterIT.java | 113 +++ .../index/automation/PhoenixMRJobSubmitter.java | 16 ++- .../apache/phoenix/schema/MetaDataClient.java | 2 +- 3 files changed, 126 insertions(+), 5 deletions(-) -- http://git-wip-us.apache.org/repos/asf/phoenix/blob/352c4205/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/PhoenixMRJobSubmitterIT.java -- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/PhoenixMRJobSubmitterIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/PhoenixMRJobSubmitterIT.java new file mode 100644 index 000..7cc3aa0 --- /dev/null +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/PhoenixMRJobSubmitterIT.java @@ -0,0 +1,113 @@ +/* + * 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.index; + +import org.apache.phoenix.end2end.BaseUniqueNamesOwnClusterIT; +import org.apache.phoenix.end2end.NeedsOwnMiniClusterTest; +import org.apache.phoenix.mapreduce.index.automation.PhoenixAsyncIndex; +import org.apache.phoenix.mapreduce.index.automation.PhoenixMRJobSubmitter; +import org.apache.phoenix.schema.MetaDataClient; +import org.apache.phoenix.schema.PIndexState; +import org.apache.phoenix.util.ReadOnlyProps; +import org.apache.phoenix.util.RunUntilFailure; +import org.apache.phoenix.util.TestUtil; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.experimental.categories.Category; +import org.junit.runner.RunWith; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.util.Map; + +@Category(NeedsOwnMiniClusterTest.class) +public class PhoenixMRJobSubmitterIT extends BaseUniqueNamesOwnClusterIT { + + private static String REQUEST_INDEX_REBUILD_SQL = "ALTER INDEX %s ON %s REBUILD ASYNC"; + + @BeforeClass + public static void setUp() throws Exception { +setUpTestDriver(ReadOnlyProps.EMPTY_PROPS); + + } + + @Test + public void testGetCandidateJobs() throws Exception { +String tableName = "TBL_" + generateUniqueName(); +String asyncIndexName = "IDX_" + generateUniqueName(); +String needsRebuildIndexName = "IDX_" + generateUniqueName(); +String tableDDL = "CREATE TABLE " + tableName + TestUtil.TEST_TABLE_SCHEMA; +String asyncIndexDDL = "CREATE INDEX " + asyncIndexName + " ON " + tableName + " (a.varchar_col1) ASYNC"; +String needsRebuildIndexDDL = "CREATE INDEX " + needsRebuildIndexName + " ON " + tableName + " (a.char_col1)"; +long rebuildTimestamp = 100L; + +createTestTable(getUrl(), tableDDL); + +createTestTable(getUrl(), needsRebuildIndexDDL); +Connection conn = null; +PreparedStatement stmt = null; +try { + conn = DriverManager.getConnection(getUrl()); + TestUtil.assertIndexState(conn, needsRebuildIndexName, PIndexState.ACTIVE, 0L); + + //first make sure that we don't return an active index + PhoenixMRJobSubmitter submitter = new PhoenixMRJobSubmitter(getUtility().getConfiguration()); + Map candidateMap = submitter.getCandidateJobs(conn); + Assert.assertNotNull(candidateMap); + Assert.assertEquals(0, candidateMap.size()); + + //create an index with ASYNC that will need building via MapReduce + createTestTable(getUrl(), asyncIndexDDL); + TestUtil.assertIndexState(conn, asyncIndexName, PIndexState.BUILDING, 0L); + +
[2/9] phoenix git commit: PHOENIX-4519 - Index rebuild MR jobs not created for "alter index rebuild async" rebuilds
PHOENIX-4519 - Index rebuild MR jobs not created for "alter index rebuild async" rebuilds Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/5b65a5fe Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/5b65a5fe Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/5b65a5fe Branch: refs/heads/4.14-cdh5.12 Commit: 5b65a5fe55129a0588df38dd1a50a29fccb1f6fe Parents: 459518f Author: Geoffrey Authored: Fri Sep 7 00:18:09 2018 +0100 Committer: pboado Committed: Mon Dec 3 20:26:59 2018 + -- .../end2end/index/PhoenixMRJobSubmitterIT.java | 113 +++ .../index/automation/PhoenixMRJobSubmitter.java | 16 ++- .../apache/phoenix/schema/MetaDataClient.java | 2 +- 3 files changed, 126 insertions(+), 5 deletions(-) -- http://git-wip-us.apache.org/repos/asf/phoenix/blob/5b65a5fe/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/PhoenixMRJobSubmitterIT.java -- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/PhoenixMRJobSubmitterIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/PhoenixMRJobSubmitterIT.java new file mode 100644 index 000..7cc3aa0 --- /dev/null +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/PhoenixMRJobSubmitterIT.java @@ -0,0 +1,113 @@ +/* + * 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.index; + +import org.apache.phoenix.end2end.BaseUniqueNamesOwnClusterIT; +import org.apache.phoenix.end2end.NeedsOwnMiniClusterTest; +import org.apache.phoenix.mapreduce.index.automation.PhoenixAsyncIndex; +import org.apache.phoenix.mapreduce.index.automation.PhoenixMRJobSubmitter; +import org.apache.phoenix.schema.MetaDataClient; +import org.apache.phoenix.schema.PIndexState; +import org.apache.phoenix.util.ReadOnlyProps; +import org.apache.phoenix.util.RunUntilFailure; +import org.apache.phoenix.util.TestUtil; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.experimental.categories.Category; +import org.junit.runner.RunWith; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.util.Map; + +@Category(NeedsOwnMiniClusterTest.class) +public class PhoenixMRJobSubmitterIT extends BaseUniqueNamesOwnClusterIT { + + private static String REQUEST_INDEX_REBUILD_SQL = "ALTER INDEX %s ON %s REBUILD ASYNC"; + + @BeforeClass + public static void setUp() throws Exception { +setUpTestDriver(ReadOnlyProps.EMPTY_PROPS); + + } + + @Test + public void testGetCandidateJobs() throws Exception { +String tableName = "TBL_" + generateUniqueName(); +String asyncIndexName = "IDX_" + generateUniqueName(); +String needsRebuildIndexName = "IDX_" + generateUniqueName(); +String tableDDL = "CREATE TABLE " + tableName + TestUtil.TEST_TABLE_SCHEMA; +String asyncIndexDDL = "CREATE INDEX " + asyncIndexName + " ON " + tableName + " (a.varchar_col1) ASYNC"; +String needsRebuildIndexDDL = "CREATE INDEX " + needsRebuildIndexName + " ON " + tableName + " (a.char_col1)"; +long rebuildTimestamp = 100L; + +createTestTable(getUrl(), tableDDL); + +createTestTable(getUrl(), needsRebuildIndexDDL); +Connection conn = null; +PreparedStatement stmt = null; +try { + conn = DriverManager.getConnection(getUrl()); + TestUtil.assertIndexState(conn, needsRebuildIndexName, PIndexState.ACTIVE, 0L); + + //first make sure that we don't return an active index + PhoenixMRJobSubmitter submitter = new PhoenixMRJobSubmitter(getUtility().getConfiguration()); + Map candidateMap = submitter.getCandidateJobs(conn); + Assert.assertNotNull(candidateMap); + Assert.assertEquals(0, candidateMap.size()); + + //create an index with ASYNC that will need building via MapReduce + createTestTable(getUrl(), asyncIndexDDL); + TestUtil.assertIndexState(conn, asyncIndexName, PIndexState.BUILDING, 0L); + +
[2/9] phoenix git commit: PHOENIX-4519 - Index rebuild MR jobs not created for "alter index rebuild async" rebuilds
PHOENIX-4519 - Index rebuild MR jobs not created for "alter index rebuild async" rebuilds Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/a9706bb2 Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/a9706bb2 Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/a9706bb2 Branch: refs/heads/4.14-cdh5.14 Commit: a9706bb294c9781ff9687cbcb8737b3c4870e665 Parents: 3b00c16 Author: Geoffrey Authored: Fri Sep 7 00:18:09 2018 +0100 Committer: Pedro Boado Committed: Mon Dec 3 08:36:48 2018 + -- .../end2end/index/PhoenixMRJobSubmitterIT.java | 113 +++ .../index/automation/PhoenixMRJobSubmitter.java | 16 ++- .../apache/phoenix/schema/MetaDataClient.java | 2 +- 3 files changed, 126 insertions(+), 5 deletions(-) -- http://git-wip-us.apache.org/repos/asf/phoenix/blob/a9706bb2/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/PhoenixMRJobSubmitterIT.java -- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/PhoenixMRJobSubmitterIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/PhoenixMRJobSubmitterIT.java new file mode 100644 index 000..7cc3aa0 --- /dev/null +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/PhoenixMRJobSubmitterIT.java @@ -0,0 +1,113 @@ +/* + * 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.index; + +import org.apache.phoenix.end2end.BaseUniqueNamesOwnClusterIT; +import org.apache.phoenix.end2end.NeedsOwnMiniClusterTest; +import org.apache.phoenix.mapreduce.index.automation.PhoenixAsyncIndex; +import org.apache.phoenix.mapreduce.index.automation.PhoenixMRJobSubmitter; +import org.apache.phoenix.schema.MetaDataClient; +import org.apache.phoenix.schema.PIndexState; +import org.apache.phoenix.util.ReadOnlyProps; +import org.apache.phoenix.util.RunUntilFailure; +import org.apache.phoenix.util.TestUtil; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.experimental.categories.Category; +import org.junit.runner.RunWith; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.util.Map; + +@Category(NeedsOwnMiniClusterTest.class) +public class PhoenixMRJobSubmitterIT extends BaseUniqueNamesOwnClusterIT { + + private static String REQUEST_INDEX_REBUILD_SQL = "ALTER INDEX %s ON %s REBUILD ASYNC"; + + @BeforeClass + public static void setUp() throws Exception { +setUpTestDriver(ReadOnlyProps.EMPTY_PROPS); + + } + + @Test + public void testGetCandidateJobs() throws Exception { +String tableName = "TBL_" + generateUniqueName(); +String asyncIndexName = "IDX_" + generateUniqueName(); +String needsRebuildIndexName = "IDX_" + generateUniqueName(); +String tableDDL = "CREATE TABLE " + tableName + TestUtil.TEST_TABLE_SCHEMA; +String asyncIndexDDL = "CREATE INDEX " + asyncIndexName + " ON " + tableName + " (a.varchar_col1) ASYNC"; +String needsRebuildIndexDDL = "CREATE INDEX " + needsRebuildIndexName + " ON " + tableName + " (a.char_col1)"; +long rebuildTimestamp = 100L; + +createTestTable(getUrl(), tableDDL); + +createTestTable(getUrl(), needsRebuildIndexDDL); +Connection conn = null; +PreparedStatement stmt = null; +try { + conn = DriverManager.getConnection(getUrl()); + TestUtil.assertIndexState(conn, needsRebuildIndexName, PIndexState.ACTIVE, 0L); + + //first make sure that we don't return an active index + PhoenixMRJobSubmitter submitter = new PhoenixMRJobSubmitter(getUtility().getConfiguration()); + Map candidateMap = submitter.getCandidateJobs(conn); + Assert.assertNotNull(candidateMap); + Assert.assertEquals(0, candidateMap.size()); + + //create an index with ASYNC that will need building via MapReduce + createTestTable(getUrl(), asyncIndexDDL); + TestUtil.assertIndexState(conn, asyncIndexName, PIndexState.BUILDING, 0L); + +