Repository: phoenix Updated Branches: refs/heads/4.x-HBase-0.98 08e2a29f6 -> 1ab9e7dfb
PHOENIX-4132 TestIndexWriter hangs on 1.8 JRE Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/1ab9e7df Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/1ab9e7df Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/1ab9e7df Branch: refs/heads/4.x-HBase-0.98 Commit: 1ab9e7dfb619db1f500ae80b22505baf967eaf34 Parents: 08e2a29 Author: Samarth Jain <[email protected]> Authored: Tue Aug 29 13:36:35 2017 -0700 Committer: Samarth Jain <[email protected]> Committed: Tue Aug 29 13:36:35 2017 -0700 ---------------------------------------------------------------------- .../hbase/index/write/TestIndexWriter.java | 25 ++++++++++++-------- .../index/write/TestParalleIndexWriter.java | 4 ++-- .../write/TestParalleWriterIndexCommitter.java | 4 ++-- 3 files changed, 19 insertions(+), 14 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/phoenix/blob/1ab9e7df/phoenix-core/src/test/java/org/apache/phoenix/hbase/index/write/TestIndexWriter.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/test/java/org/apache/phoenix/hbase/index/write/TestIndexWriter.java b/phoenix-core/src/test/java/org/apache/phoenix/hbase/index/write/TestIndexWriter.java index d219f4c..88e4a96 100644 --- a/phoenix-core/src/test/java/org/apache/phoenix/hbase/index/write/TestIndexWriter.java +++ b/phoenix-core/src/test/java/org/apache/phoenix/hbase/index/write/TestIndexWriter.java @@ -52,6 +52,7 @@ import org.apache.phoenix.hbase.index.StubAbortable; import org.apache.phoenix.hbase.index.TableName; import org.apache.phoenix.hbase.index.exception.IndexWriteException; import org.apache.phoenix.hbase.index.exception.SingleIndexWriteFailureException; +import org.apache.phoenix.hbase.index.table.HTableInterfaceReference; import org.apache.phoenix.hbase.index.util.ImmutableBytesPtr; import org.junit.Rule; import org.junit.Test; @@ -59,6 +60,9 @@ import org.mockito.Mockito; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; +import com.google.common.collect.LinkedListMultimap; +import com.google.common.collect.Multimap; + public class TestIndexWriter { private static final Log LOG = LogFactory.getLog(TestIndexWriter.class); @Rule @@ -159,17 +163,9 @@ public class TestIndexWriter { ExecutorService exec = Executors.newFixedThreadPool(1); Map<ImmutableBytesPtr, HTableInterface> tables = new HashMap<ImmutableBytesPtr, HTableInterface>(); FakeTableFactory factory = new FakeTableFactory(tables); - // updates to two different tables byte[] tableName = Bytes.add(this.testName.getTableName(), new byte[] { 1, 2, 3, 4 }); - Put m = new Put(row); - m.add(Bytes.toBytes("family"), Bytes.toBytes("qual"), null); byte[] tableName2 = this.testName.getTableName();// this will sort after the first tablename - List<Pair<Mutation, byte[]>> indexUpdates = new ArrayList<Pair<Mutation, byte[]>>(); - indexUpdates.add(new Pair<Mutation, byte[]>(m, tableName)); - indexUpdates.add(new Pair<Mutation, byte[]>(m, tableName2)); - indexUpdates.add(new Pair<Mutation, byte[]>(m, tableName2)); - // first table will fail HTableInterface table = Mockito.mock(HTableInterface.class); Mockito.when(table.batch(Mockito.anyList())).thenThrow( @@ -209,8 +205,17 @@ public class TestIndexWriter { policy.setup(stop, abort); IndexWriter writer = new IndexWriter(committer, policy); try { - writer.write(indexUpdates); - fail("Should not have successfully completed all index writes"); + Put m = new Put(row); + m.add(Bytes.toBytes("family"), Bytes.toBytes("qual"), null); + HTableInterfaceReference ht1 = new HTableInterfaceReference(new ImmutableBytesPtr(tableName)); + HTableInterfaceReference ht2 = new HTableInterfaceReference(new ImmutableBytesPtr(tableName2)); + // We need to apply updates first for table1 and then table2. + Multimap<HTableInterfaceReference, Mutation> indexUpdates = LinkedListMultimap.create(); + indexUpdates.put(ht1, m); + indexUpdates.put(ht2, m); + indexUpdates.put(ht2, m); + writer.write(indexUpdates, false); + fail("Should not have successfully completed all index writes"); } catch (SingleIndexWriteFailureException s) { LOG.info("Correctly got a failure to reach the index", s); // should have correctly gotten the correct abort, so let the next task execute http://git-wip-us.apache.org/repos/asf/phoenix/blob/1ab9e7df/phoenix-core/src/test/java/org/apache/phoenix/hbase/index/write/TestParalleIndexWriter.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/test/java/org/apache/phoenix/hbase/index/write/TestParalleIndexWriter.java b/phoenix-core/src/test/java/org/apache/phoenix/hbase/index/write/TestParalleIndexWriter.java index 8e4e7db..e62af7a 100644 --- a/phoenix-core/src/test/java/org/apache/phoenix/hbase/index/write/TestParalleIndexWriter.java +++ b/phoenix-core/src/test/java/org/apache/phoenix/hbase/index/write/TestParalleIndexWriter.java @@ -20,7 +20,7 @@ package org.apache.phoenix.hbase.index.write; import static org.junit.Assert.assertTrue; import java.util.Collections; -import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ExecutorService; @@ -87,7 +87,7 @@ public class TestParalleIndexWriter { Stoppable stop = Mockito.mock(Stoppable.class); ExecutorService exec = Executors.newFixedThreadPool(1); Map<ImmutableBytesPtr, HTableInterface> tables = - new HashMap<ImmutableBytesPtr, HTableInterface>(); + new LinkedHashMap<ImmutableBytesPtr, HTableInterface>(); FakeTableFactory factory = new FakeTableFactory(tables); RegionCoprocessorEnvironment e =Mockito.mock(RegionCoprocessorEnvironment.class); Configuration conf =new Configuration(); http://git-wip-us.apache.org/repos/asf/phoenix/blob/1ab9e7df/phoenix-core/src/test/java/org/apache/phoenix/hbase/index/write/TestParalleWriterIndexCommitter.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/test/java/org/apache/phoenix/hbase/index/write/TestParalleWriterIndexCommitter.java b/phoenix-core/src/test/java/org/apache/phoenix/hbase/index/write/TestParalleWriterIndexCommitter.java index e737aa7..789e7a1 100644 --- a/phoenix-core/src/test/java/org/apache/phoenix/hbase/index/write/TestParalleWriterIndexCommitter.java +++ b/phoenix-core/src/test/java/org/apache/phoenix/hbase/index/write/TestParalleWriterIndexCommitter.java @@ -20,7 +20,7 @@ package org.apache.phoenix.hbase.index.write; import static org.junit.Assert.assertTrue; import java.util.Collections; -import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ExecutorService; @@ -91,7 +91,7 @@ public class TestParalleWriterIndexCommitter { Stoppable stop = Mockito.mock(Stoppable.class); ExecutorService exec = Executors.newFixedThreadPool(1); Map<ImmutableBytesPtr, HTableInterface> tables = - new HashMap<ImmutableBytesPtr, HTableInterface>(); + new LinkedHashMap<ImmutableBytesPtr, HTableInterface>(); FakeTableFactory factory = new FakeTableFactory(tables); ImmutableBytesPtr tableName = new ImmutableBytesPtr(this.test.getTableName());
