HBASE-16190 IntegrationTestDDLMasterFailover failed with IllegalArgumentException: n must be positive (Romil Choksi and Heng Chen)

This commit is contained in:
Enis Soztutar 2016-07-07 16:34:08 -07:00
parent e9f5db7213
commit 17edca6346
1 changed files with 14 additions and 10 deletions

View File

@ -25,13 +25,17 @@ import java.util.Set;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.hadoop.hbase.io.encoding.DataBlockEncoding;
import org.apache.commons.lang.RandomStringUtils; import org.apache.commons.lang.RandomStringUtils;
import org.apache.commons.lang.math.RandomUtils; import org.apache.commons.lang.math.RandomUtils;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.client.*; import org.apache.hadoop.hbase.client.Admin;
import org.apache.hadoop.hbase.client.Connection;
import org.apache.hadoop.hbase.client.ConnectionFactory;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.Table;
import org.apache.hadoop.hbase.io.encoding.DataBlockEncoding;
import org.apache.hadoop.hbase.testclassification.IntegrationTests; import org.apache.hadoop.hbase.testclassification.IntegrationTests;
import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.HBaseFsck; import org.apache.hadoop.hbase.util.HBaseFsck;
@ -246,12 +250,12 @@ public class IntegrationTestDDLMasterFailover extends IntegrationTestBase {
// NamespaceAction has implemented selectNamespace() shared by multiple namespace Actions // NamespaceAction has implemented selectNamespace() shared by multiple namespace Actions
protected NamespaceDescriptor selectNamespace( protected NamespaceDescriptor selectNamespace(
ConcurrentHashMap<String, NamespaceDescriptor> namespaceMap) { ConcurrentHashMap<String, NamespaceDescriptor> namespaceMap) {
// randomly select namespace from namespaceMap
if (namespaceMap.isEmpty()) {
return null;
}
// synchronization to prevent removal from multiple threads // synchronization to prevent removal from multiple threads
synchronized (namespaceMap) { synchronized (namespaceMap) {
// randomly select namespace from namespaceMap
if (namespaceMap.isEmpty()) {
return null;
}
ArrayList<String> namespaceList = new ArrayList<String>(namespaceMap.keySet()); ArrayList<String> namespaceList = new ArrayList<String>(namespaceMap.keySet());
String randomKey = namespaceList.get(RandomUtils.nextInt(namespaceList.size())); String randomKey = namespaceList.get(RandomUtils.nextInt(namespaceList.size()));
NamespaceDescriptor randomNsd = namespaceMap.get(randomKey); NamespaceDescriptor randomNsd = namespaceMap.get(randomKey);
@ -386,12 +390,12 @@ public class IntegrationTestDDLMasterFailover extends IntegrationTestBase {
// TableAction has implemented selectTable() shared by multiple table Actions // TableAction has implemented selectTable() shared by multiple table Actions
protected HTableDescriptor selectTable(ConcurrentHashMap<TableName, HTableDescriptor> tableMap) protected HTableDescriptor selectTable(ConcurrentHashMap<TableName, HTableDescriptor> tableMap)
{ {
// randomly select table from tableMap
if (tableMap.isEmpty()){
return null;
}
// synchronization to prevent removal from multiple threads // synchronization to prevent removal from multiple threads
synchronized (tableMap){ synchronized (tableMap){
// randomly select table from tableMap
if (tableMap.isEmpty()) {
return null;
}
ArrayList<TableName> tableList = new ArrayList<TableName>(tableMap.keySet()); ArrayList<TableName> tableList = new ArrayList<TableName>(tableMap.keySet());
TableName randomKey = tableList.get(RandomUtils.nextInt(tableList.size())); TableName randomKey = tableList.get(RandomUtils.nextInt(tableList.size()));
HTableDescriptor randomHtd = tableMap.get(randomKey); HTableDescriptor randomHtd = tableMap.get(randomKey);