HBASE-25022 Remove 'hbase.testing.nocluster' config (#2394)
Signed-off-by: Guanghao Zhang <zghao@apache.org>
This commit is contained in:
parent
79eee6affc
commit
b0c6305686
|
@ -578,14 +578,9 @@ public class HMaster extends HRegionServer implements MasterServices {
|
|||
}
|
||||
}
|
||||
|
||||
// Some unit tests don't need a cluster, so no zookeeper at all
|
||||
if (!conf.getBoolean("hbase.testing.nocluster", false)) {
|
||||
this.metaRegionLocationCache = new MetaRegionLocationCache(this.zooKeeper);
|
||||
this.activeMasterManager = createActiveMasterManager(zooKeeper, serverName, this);
|
||||
} else {
|
||||
this.metaRegionLocationCache = null;
|
||||
this.activeMasterManager = null;
|
||||
}
|
||||
|
||||
cachedClusterId = new CachedClusterId(this, conf);
|
||||
} catch (Throwable t) {
|
||||
// Make sure we log the exception. HMaster is often started via reflection and the
|
||||
|
@ -614,7 +609,6 @@ public class HMaster extends HRegionServer implements MasterServices {
|
|||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
if (!conf.getBoolean("hbase.testing.nocluster", false)) {
|
||||
Threads.setDaemonThreadRunning(new Thread(() -> {
|
||||
try {
|
||||
int infoPort = putUpJettyServer();
|
||||
|
@ -629,7 +623,6 @@ public class HMaster extends HRegionServer implements MasterServices {
|
|||
}
|
||||
}
|
||||
}), getName() + ":becomeActiveMaster");
|
||||
}
|
||||
// Fall in here even if we have been aborted. Need to run the shutdown services and
|
||||
// the super run call will do this for us.
|
||||
super.run();
|
||||
|
|
|
@ -643,10 +643,9 @@ public class HRegionServer extends Thread implements
|
|||
setupWindows(getConfiguration(), getConfigurationManager());
|
||||
|
||||
// Some unit tests don't need a cluster, so no zookeeper at all
|
||||
if (!conf.getBoolean("hbase.testing.nocluster", false)) {
|
||||
// Open connection to zookeeper and set primary watcher
|
||||
zooKeeper = new ZKWatcher(conf, getProcessName() + ":" +
|
||||
rpcServices.isa.getPort(), this, canCreateBaseZNode());
|
||||
zooKeeper = new ZKWatcher(conf, getProcessName() + ":" + rpcServices.isa.getPort(), this,
|
||||
canCreateBaseZNode());
|
||||
// If no master in cluster, skip trying to track one or look for a cluster status.
|
||||
if (!this.masterless) {
|
||||
if (conf.getBoolean(HBASE_SPLIT_WAL_COORDINATED_BY_ZK,
|
||||
|
@ -663,11 +662,6 @@ public class HRegionServer extends Thread implements
|
|||
masterAddressTracker = null;
|
||||
clusterStatusTracker = null;
|
||||
}
|
||||
} else {
|
||||
zooKeeper = null;
|
||||
masterAddressTracker = null;
|
||||
clusterStatusTracker = null;
|
||||
}
|
||||
this.rpcServices.start(zooKeeper);
|
||||
// This violates 'no starting stuff in Constructor' but Master depends on the below chore
|
||||
// and executor being created and takes a different startup route. Lots of overlap between HRS
|
||||
|
|
|
@ -105,6 +105,7 @@ import org.apache.hadoop.hbase.log.HBaseMarkers;
|
|||
import org.apache.hadoop.hbase.master.HMaster;
|
||||
import org.apache.hadoop.hbase.master.MasterRpcServices;
|
||||
import org.apache.hadoop.hbase.namequeues.NamedQueuePayload;
|
||||
import org.apache.hadoop.hbase.namequeues.NamedQueueRecorder;
|
||||
import org.apache.hadoop.hbase.namequeues.request.NamedQueueGetRequest;
|
||||
import org.apache.hadoop.hbase.namequeues.response.NamedQueueGetResponse;
|
||||
import org.apache.hadoop.hbase.net.Address;
|
||||
|
@ -127,7 +128,6 @@ import org.apache.hadoop.hbase.regionserver.handler.OpenMetaHandler;
|
|||
import org.apache.hadoop.hbase.regionserver.handler.OpenPriorityRegionHandler;
|
||||
import org.apache.hadoop.hbase.regionserver.handler.OpenRegionHandler;
|
||||
import org.apache.hadoop.hbase.regionserver.handler.UnassignRegionHandler;
|
||||
import org.apache.hadoop.hbase.namequeues.NamedQueueRecorder;
|
||||
import org.apache.hadoop.hbase.security.Superusers;
|
||||
import org.apache.hadoop.hbase.security.User;
|
||||
import org.apache.hadoop.hbase.security.access.AccessChecker;
|
||||
|
@ -1421,7 +1421,6 @@ public class RSRpcServices implements HBaseRPCErrorHandler,
|
|||
} else {
|
||||
accessChecker = new NoopAccessChecker(getConfiguration());
|
||||
}
|
||||
if (!getConfiguration().getBoolean("hbase.testing.nocluster", false) && zkWatcher != null) {
|
||||
zkPermissionWatcher =
|
||||
new ZKPermissionWatcher(zkWatcher, accessChecker.getAuthManager(), getConfiguration());
|
||||
try {
|
||||
|
@ -1429,7 +1428,6 @@ public class RSRpcServices implements HBaseRPCErrorHandler,
|
|||
} catch (KeeperException e) {
|
||||
LOG.error("ZooKeeper permission watcher initialization failed", e);
|
||||
}
|
||||
}
|
||||
this.scannerIdGenerator = new ScannerIdGenerator(this.regionServer.serverName);
|
||||
rpcServer.start();
|
||||
}
|
||||
|
|
|
@ -70,8 +70,6 @@ import org.junit.Test;
|
|||
import org.junit.experimental.categories.Category;
|
||||
import org.junit.rules.TestName;
|
||||
import org.mockito.Mockito;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@Category({CoprocessorTests.class, MediumTests.class})
|
||||
public class TestCoprocessorInterface {
|
||||
|
@ -81,8 +79,7 @@ public class TestCoprocessorInterface {
|
|||
HBaseClassTestRule.forClass(TestCoprocessorInterface.class);
|
||||
|
||||
@Rule public TestName name = new TestName();
|
||||
private static final Logger LOG = LoggerFactory.getLogger(TestCoprocessorInterface.class);
|
||||
private static final HBaseTestingUtility TEST_UTIL = HBaseTestingUtility.createLocalHTU();
|
||||
private static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
|
||||
static final Path DIR = TEST_UTIL.getDataTestDir();
|
||||
|
||||
private static class CustomScanner implements RegionScanner {
|
||||
|
@ -396,7 +393,7 @@ public class TestCoprocessorInterface {
|
|||
r.setCoprocessorHost(host);
|
||||
|
||||
for (Class<?> implClass : implClasses) {
|
||||
host.load((Class<? extends RegionCoprocessor>) implClass, Coprocessor.PRIORITY_USER, conf);
|
||||
host.load(implClass.asSubclass(RegionCoprocessor.class), Coprocessor.PRIORITY_USER, conf);
|
||||
}
|
||||
// we need to manually call pre- and postOpen here since the
|
||||
// above load() is not the real case for CP loading. A CP is
|
||||
|
@ -432,7 +429,7 @@ public class TestCoprocessorInterface {
|
|||
r.setCoprocessorHost(host);
|
||||
|
||||
for (Class<?> implClass : implClasses) {
|
||||
host.load((Class<? extends RegionCoprocessor>) implClass, Coprocessor.PRIORITY_USER, conf);
|
||||
host.load(implClass.asSubclass(RegionCoprocessor.class), Coprocessor.PRIORITY_USER, conf);
|
||||
Coprocessor c = host.findCoprocessor(implClass.getName());
|
||||
assertNotNull(c);
|
||||
}
|
||||
|
@ -453,8 +450,6 @@ public class TestCoprocessorInterface {
|
|||
// below. After adding all data, the first region is 1.3M
|
||||
TEST_UTIL.getConfiguration().setLong(HConstants.HREGION_MAX_FILESIZE,
|
||||
1024 * 128);
|
||||
TEST_UTIL.getConfiguration().setBoolean("hbase.testing.nocluster",
|
||||
true);
|
||||
TEST_UTIL.getConfiguration().setBoolean(CoprocessorHost.ABORT_ON_ERROR_KEY, false);
|
||||
|
||||
return TEST_UTIL.getConfiguration();
|
||||
|
|
|
@ -20,9 +20,7 @@ package org.apache.hadoop.hbase.regionserver;
|
|||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.io.IOException;
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.hbase.HBaseClassTestRule;
|
||||
import org.apache.hadoop.hbase.HBaseConfiguration;
|
||||
import org.apache.hadoop.hbase.HBaseTestingUtility;
|
||||
import org.apache.hadoop.hbase.HConstants;
|
||||
import org.apache.hadoop.hbase.TableName;
|
||||
|
@ -33,7 +31,8 @@ import org.apache.hadoop.hbase.security.User;
|
|||
import org.apache.hadoop.hbase.testclassification.MediumTests;
|
||||
import org.apache.hadoop.hbase.testclassification.RegionServerTests;
|
||||
import org.apache.hadoop.hbase.util.Bytes;
|
||||
import org.junit.Before;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Test;
|
||||
import org.junit.experimental.categories.Category;
|
||||
|
@ -59,23 +58,26 @@ public class TestPriorityRpc {
|
|||
public static final HBaseClassTestRule CLASS_RULE =
|
||||
HBaseClassTestRule.forClass(TestPriorityRpc.class);
|
||||
|
||||
private Configuration conf;
|
||||
private HRegionServer regionServer = null;
|
||||
private PriorityFunction priority = null;
|
||||
private static final HBaseTestingUtility UTIL = new HBaseTestingUtility();
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
conf = HBaseConfiguration.create();
|
||||
conf.setBoolean("hbase.testing.nocluster", true); // No need to do ZK
|
||||
final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility(conf);
|
||||
TEST_UTIL.getDataTestDir(this.getClass().getName());
|
||||
regionServer = HRegionServer.constructRegionServer(HRegionServer.class, conf);
|
||||
priority = regionServer.rpcServices.getPriority();
|
||||
private static HRegionServer RS = null;
|
||||
private static PriorityFunction PRIORITY = null;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
UTIL.startMiniCluster(1);
|
||||
RS = UTIL.getHBaseCluster().getRegionServer(0);
|
||||
PRIORITY = RS.rpcServices.getPriority();
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDown() throws IOException {
|
||||
UTIL.shutdownMiniCluster();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testQosFunctionForMeta() throws IOException {
|
||||
priority = regionServer.rpcServices.getPriority();
|
||||
PRIORITY = RS.rpcServices.getPriority();
|
||||
RequestHeader.Builder headerBuilder = RequestHeader.newBuilder();
|
||||
//create a rpc request that has references to hbase:meta region and also
|
||||
//uses one of the known argument classes (known argument classes are
|
||||
|
@ -105,9 +107,9 @@ public class TestPriorityRpc {
|
|||
Mockito.when(mockRegionInfo.getTable())
|
||||
.thenReturn(RegionInfoBuilder.FIRST_META_REGIONINFO.getTable());
|
||||
// Presume type.
|
||||
((AnnotationReadingPriorityFunction)priority).setRegionServer(mockRS);
|
||||
((AnnotationReadingPriorityFunction)PRIORITY).setRegionServer(mockRS);
|
||||
assertEquals(
|
||||
HConstants.SYSTEMTABLE_QOS, priority.getPriority(header, getRequest, createSomeUser()));
|
||||
HConstants.SYSTEMTABLE_QOS, PRIORITY.getPriority(header, getRequest, createSomeUser()));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -119,7 +121,7 @@ public class TestPriorityRpc {
|
|||
RequestHeader.Builder headerBuilder = RequestHeader.newBuilder();
|
||||
headerBuilder.setMethodName("foo");
|
||||
RequestHeader header = headerBuilder.build();
|
||||
PriorityFunction qosFunc = regionServer.rpcServices.getPriority();
|
||||
PriorityFunction qosFunc = RS.rpcServices.getPriority();
|
||||
assertEquals(HConstants.NORMAL_QOS, qosFunc.getPriority(header, null, createSomeUser()));
|
||||
}
|
||||
|
||||
|
@ -143,8 +145,8 @@ public class TestPriorityRpc {
|
|||
Mockito.when(mockRegionInfo.getTable())
|
||||
.thenReturn(TableName.valueOf("testQosFunctionForScanMethod"));
|
||||
// Presume type.
|
||||
((AnnotationReadingPriorityFunction)priority).setRegionServer(mockRS);
|
||||
final int qos = priority.getPriority(header, scanRequest, createSomeUser());
|
||||
((AnnotationReadingPriorityFunction)PRIORITY).setRegionServer(mockRS);
|
||||
final int qos = PRIORITY.getPriority(header, scanRequest, createSomeUser());
|
||||
assertEquals(Integer.toString(qos), qos, HConstants.NORMAL_QOS);
|
||||
|
||||
//build a scan request with scannerID
|
||||
|
@ -161,11 +163,11 @@ public class TestPriorityRpc {
|
|||
.thenReturn(RegionInfoBuilder.FIRST_META_REGIONINFO.getTable());
|
||||
|
||||
// Presume type.
|
||||
((AnnotationReadingPriorityFunction)priority).setRegionServer(mockRS);
|
||||
((AnnotationReadingPriorityFunction)PRIORITY).setRegionServer(mockRS);
|
||||
|
||||
assertEquals(
|
||||
HConstants.SYSTEMTABLE_QOS,
|
||||
priority.getPriority(header, scanRequest, createSomeUser()));
|
||||
PRIORITY.getPriority(header, scanRequest, createSomeUser()));
|
||||
|
||||
//the same as above but with non-meta region
|
||||
// make isSystemTable return false
|
||||
|
@ -173,10 +175,11 @@ public class TestPriorityRpc {
|
|||
.thenReturn(TableName.valueOf("testQosFunctionForScanMethod"));
|
||||
assertEquals(
|
||||
HConstants.NORMAL_QOS,
|
||||
priority.getPriority(header, scanRequest, createSomeUser()));
|
||||
PRIORITY.getPriority(header, scanRequest, createSomeUser()));
|
||||
}
|
||||
|
||||
private User createSomeUser() {
|
||||
return User.createUserForTesting(conf, "someuser", new String[] { "somegroup" });
|
||||
private static User createSomeUser() {
|
||||
return User.createUserForTesting(UTIL.getConfiguration(), "someuser",
|
||||
new String[] { "somegroup" });
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue