HBASE-13041 TestEnableTableHandler should not call AssignmentManager#assign concurrently with master (Andrey Stepachev)
This commit is contained in:
parent
0d880c99b5
commit
d3621d24de
|
@ -18,8 +18,13 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.hadoop.hbase.master.handler;
|
package org.apache.hadoop.hbase.master.handler;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.google.common.base.Predicate;
|
||||||
|
import com.google.common.collect.Iterables;
|
||||||
|
import com.google.common.collect.Iterators;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
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.hbase.HConstants;
|
import org.apache.hadoop.hbase.HConstants;
|
||||||
|
@ -81,7 +86,6 @@ public class TestEnableTableHandler {
|
||||||
|
|
||||||
admin.enableTable(tableName);
|
admin.enableTable(tableName);
|
||||||
TEST_UTIL.waitTableEnabled(tableName);
|
TEST_UTIL.waitTableEnabled(tableName);
|
||||||
|
|
||||||
// disable once more
|
// disable once more
|
||||||
admin.disableTable(tableName);
|
admin.disableTable(tableName);
|
||||||
|
|
||||||
|
@ -91,21 +95,36 @@ public class TestEnableTableHandler {
|
||||||
rs.getRegionServer().stop("stop");
|
rs.getRegionServer().stop("stop");
|
||||||
cluster.waitForRegionServerToStop(rs.getRegionServer().getServerName(), 10000);
|
cluster.waitForRegionServerToStop(rs.getRegionServer().getServerName(), 10000);
|
||||||
|
|
||||||
EnableTableHandler handler =
|
LOG.debug("Now enabling table " + tableName);
|
||||||
new EnableTableHandler(m, tableName, m.getAssignmentManager(), m.getTableLockManager(),
|
|
||||||
true);
|
|
||||||
handler.prepare();
|
|
||||||
handler.process();
|
|
||||||
|
|
||||||
|
admin.enableTable(tableName);
|
||||||
assertTrue(admin.isTableEnabled(tableName));
|
assertTrue(admin.isTableEnabled(tableName));
|
||||||
|
|
||||||
JVMClusterUtil.RegionServerThread rs2 = cluster.startRegionServer();
|
JVMClusterUtil.RegionServerThread rs2 = cluster.startRegionServer();
|
||||||
m.getAssignmentManager().assign(admin.getTableRegions(tableName));
|
cluster.waitForRegionServerToStart(rs2.getRegionServer().getServerName().getHostname(),
|
||||||
|
rs2.getRegionServer().getServerName().getPort(), 60000);
|
||||||
|
|
||||||
|
List<HRegionInfo> regions = TEST_UTIL.getHBaseAdmin().getTableRegions(tableName);
|
||||||
|
assertEquals(1, regions.size());
|
||||||
|
for (HRegionInfo region : regions) {
|
||||||
|
TEST_UTIL.getHBaseAdmin().assign(region.getEncodedNameAsBytes());
|
||||||
|
}
|
||||||
|
LOG.debug("Waiting for table assigned " + tableName);
|
||||||
TEST_UTIL.waitUntilAllRegionsAssigned(tableName);
|
TEST_UTIL.waitUntilAllRegionsAssigned(tableName);
|
||||||
List<HRegionInfo> onlineRegions = admin.getOnlineRegions(
|
List<HRegionInfo> onlineRegions = admin.getOnlineRegions(
|
||||||
rs2.getRegionServer().getServerName());
|
rs2.getRegionServer().getServerName());
|
||||||
assertEquals(1, onlineRegions.size());
|
ArrayList<HRegionInfo> tableRegions = filterTableRegions(tableName, onlineRegions);
|
||||||
assertEquals(tableName, onlineRegions.get(0).getTable());
|
assertEquals(1, tableRegions.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
private ArrayList<HRegionInfo> filterTableRegions(final TableName tableName,
|
||||||
|
List<HRegionInfo> onlineRegions) {
|
||||||
|
return Lists.newArrayList(Iterables.filter(onlineRegions, new Predicate<HRegionInfo>() {
|
||||||
|
@Override
|
||||||
|
public boolean apply(HRegionInfo input) {
|
||||||
|
return input.getTable().equals(tableName);
|
||||||
|
}
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue