HBASE-15778 replace master.am and master.sm direct access with getter calls

This commit is contained in:
Matteo Bertozzi 2016-05-07 05:19:15 -07:00
parent 513ca3483f
commit 99e2deb86f
6 changed files with 33 additions and 32 deletions

View File

@ -260,7 +260,7 @@ public class HMaster extends HRegionServer implements MasterServices {
LoadBalancerTracker loadBalancerTracker;
// Tracker for split and merge state
SplitOrMergeTracker splitOrMergeTracker;
private SplitOrMergeTracker splitOrMergeTracker;
// Tracker for region normalizer state
private RegionNormalizerTracker regionNormalizerTracker;
@ -274,10 +274,10 @@ public class HMaster extends HRegionServer implements MasterServices {
private MasterWalManager walManager;
// server manager to deal with region server info
volatile ServerManager serverManager;
private volatile ServerManager serverManager;
// manager of assignment nodes in zookeeper
AssignmentManager assignmentManager;
private AssignmentManager assignmentManager;
// buffer for "fatal error" notices from region servers
// in the cluster. This is only used for assisting
@ -299,7 +299,7 @@ public class HMaster extends HRegionServer implements MasterServices {
private final ProcedureEvent serverCrashProcessingEnabled =
new ProcedureEvent("server crash processing");
LoadBalancer balancer;
private LoadBalancer balancer;
private RegionNormalizer normalizer;
private BalancerChore balancerChore;
private RegionNormalizerChore normalizerChore;

View File

@ -165,7 +165,7 @@ public class MasterRpcServices extends RSRpcServices
}
try {
if (mode == BalanceSwitchMode.SYNC) {
synchronized (master.balancer) {
synchronized (master.getLoadBalancer()) {
master.loadBalancerTracker.setBalancerOn(newValue);
}
} else {
@ -232,7 +232,8 @@ public class MasterRpcServices extends RSRpcServices
throw new ServiceException(ioe);
}
byte[] encodedRegionName = request.getRegionName().toByteArray();
RegionStoreSequenceIds ids = master.serverManager.getLastFlushedSequenceId(encodedRegionName);
RegionStoreSequenceIds ids = master.getServerManager()
.getLastFlushedSequenceId(encodedRegionName);
return ResponseConverter.buildGetLastFlushedSequenceIdResponse(ids);
}
@ -243,8 +244,8 @@ public class MasterRpcServices extends RSRpcServices
master.checkServiceStarted();
ClusterStatusProtos.ServerLoad sl = request.getLoad();
ServerName serverName = ProtobufUtil.toServerName(request.getServer());
ServerLoad oldLoad = master.serverManager.getLoad(serverName);
master.serverManager.regionServerReport(serverName, new ServerLoad(sl));
ServerLoad oldLoad = master.getServerManager().getLoad(serverName);
master.getServerManager().regionServerReport(serverName, new ServerLoad(sl));
if (sl != null && master.metricsMaster != null) {
// Up our metrics.
master.metricsMaster.incrementRequests(sl.getTotalNumberOfRequests()
@ -266,7 +267,7 @@ public class MasterRpcServices extends RSRpcServices
request.getPort(), request.getServerStartCode());
// if regionserver passed hostname to use,
// then use it instead of doing a reverse DNS lookup
ServerName rs = master.serverManager.regionServerStartup(request, ia);
ServerName rs = master.getServerManager().regionServerStartup(request, ia);
// Send back some config info
RegionServerStartupResponse.Builder resp = createConfigurationSubset();
@ -326,7 +327,7 @@ public class MasterRpcServices extends RSRpcServices
LOG.warn("assignRegion specifier type: expected: " + RegionSpecifierType.REGION_NAME
+ " actual: " + type);
}
RegionStates regionStates = master.assignmentManager.getRegionStates();
RegionStates regionStates = master.getAssignmentManager().getRegionStates();
HRegionInfo regionInfo = regionStates.getRegionInfo(regionName);
if (regionInfo == null) throw new UnknownRegionException(Bytes.toString(regionName));
if (master.cpHost != null) {
@ -336,7 +337,7 @@ public class MasterRpcServices extends RSRpcServices
}
LOG.info(master.getClientIdAuditPrefix()
+ " assign " + regionInfo.getRegionNameAsString());
master.assignmentManager.assign(regionInfo, true);
master.getAssignmentManager().assign(regionInfo, true);
if (master.cpHost != null) {
master.cpHost.postAssign(regionInfo);
}
@ -503,7 +504,7 @@ public class MasterRpcServices extends RSRpcServices
+ request.getRegionA().getType() + ", region_b="
+ request.getRegionB().getType());
}
RegionStates regionStates = master.assignmentManager.getRegionStates();
RegionStates regionStates = master.getAssignmentManager().getRegionStates();
RegionState regionStateA = regionStates.getRegionState(Bytes.toString(encodedNameOfRegionA));
RegionState regionStateB = regionStates.getRegionState(Bytes.toString(encodedNameOfRegionB));
if (regionStateA == null || regionStateB == null) {
@ -767,7 +768,7 @@ public class MasterRpcServices extends RSRpcServices
try {
master.checkInitialized();
Pair<Integer,Integer> pair = master.assignmentManager.getReopenStatus(tableName);
Pair<Integer,Integer> pair = master.getAssignmentManager().getReopenStatus(tableName);
GetSchemaAlterStatusResponse.Builder ret = GetSchemaAlterStatusResponse.newBuilder();
ret.setYetToUpdateRegions(pair.getFirst());
ret.setTotalRegions(pair.getSecond());
@ -1155,7 +1156,7 @@ public class MasterRpcServices extends RSRpcServices
master.cpHost.preRegionOffline(hri);
}
LOG.info(master.getClientIdAuditPrefix() + " offline " + hri.getRegionNameAsString());
master.assignmentManager.regionOffline(hri);
master.getAssignmentManager().regionOffline(hri);
if (master.cpHost != null) {
master.cpHost.postRegionOffline(hri);
}
@ -1301,7 +1302,7 @@ public class MasterRpcServices extends RSRpcServices
}
LOG.debug(master.getClientIdAuditPrefix() + " unassign " + hri.getRegionNameAsString()
+ " in current location if it is online and reassign.force=" + force);
master.assignmentManager.unassign(hri);
master.getAssignmentManager().unassign(hri);
if (master.cpHost != null) {
master.cpHost.postUnassign(hri, force);
}
@ -1320,16 +1321,16 @@ public class MasterRpcServices extends RSRpcServices
RegionStateTransition rt = req.getTransition(0);
TableName tableName = ProtobufUtil.toTableName(
rt.getRegionInfo(0).getTableName());
RegionStates regionStates = master.assignmentManager.getRegionStates();
RegionStates regionStates = master.getAssignmentManager().getRegionStates();
if (!(TableName.META_TABLE_NAME.equals(tableName)
&& regionStates.getRegionState(HRegionInfo.FIRST_META_REGIONINFO) != null)
&& !master.assignmentManager.isFailoverCleanupDone()) {
&& !master.getAssignmentManager().isFailoverCleanupDone()) {
// Meta region is assigned before master finishes the
// failover cleanup. So no need this check for it
throw new PleaseHoldException("Master is rebuilding user regions");
}
ServerName sn = ProtobufUtil.toServerName(req.getServer());
String error = master.assignmentManager.onRegionTransition(sn, rt);
String error = master.getAssignmentManager().onRegionTransition(sn, rt);
ReportRegionStateTransitionResponse.Builder rrtr =
ReportRegionStateTransitionResponse.newBuilder();
if (error != null) {

View File

@ -234,7 +234,7 @@ public class TestAssignmentManagerOnCluster {
MetaTableAccessor.addRegionToMeta(meta, hri);
master = TEST_UTIL.getHBaseCluster().getMaster();
Set<ServerName> onlineServers = master.serverManager.getOnlineServers().keySet();
Set<ServerName> onlineServers = master.getServerManager().getOnlineServers().keySet();
assertFalse("There should be some servers online", onlineServers.isEmpty());
// Use the first server as the destination server
@ -243,7 +243,7 @@ public class TestAssignmentManagerOnCluster {
// Created faked dead server that is still online in master
deadServer = ServerName.valueOf(destServer.getHostname(),
destServer.getPort(), destServer.getStartcode() - 100L);
master.serverManager.recordNewServerWithLock(deadServer, ServerLoad.EMPTY_SERVERLOAD);
master.getServerManager().recordNewServerWithLock(deadServer, ServerLoad.EMPTY_SERVERLOAD);
final AssignmentManager am = master.getAssignmentManager();
RegionPlan plan = new RegionPlan(hri, null, deadServer);
@ -260,7 +260,7 @@ public class TestAssignmentManagerOnCluster {
assertFalse("Region should be assigned", am.getRegionStates().isRegionInTransition(hri));
} finally {
if (deadServer != null) {
master.serverManager.expireServer(deadServer);
master.getServerManager().expireServer(deadServer);
}
TEST_UTIL.deleteTable(table);
@ -1337,7 +1337,7 @@ public class TestAssignmentManagerOnCluster {
public void enableSSH(boolean enabled) {
this.enabled.set(enabled);
if (enabled) {
serverManager.processQueuedDeadServers();
getServerManager().processQueuedDeadServers();
}
}
}

View File

@ -101,7 +101,7 @@ public class TestMaster {
LOG.info("Splitting table");
TEST_UTIL.getHBaseAdmin().split(TABLENAME);
LOG.info("Waiting for split result to be about to open");
RegionStates regionStates = m.assignmentManager.getRegionStates();
RegionStates regionStates = m.getAssignmentManager().getRegionStates();
while (regionStates.getRegionsOfTable(TABLENAME).size() <= 1) {
Thread.sleep(100);
}

View File

@ -277,7 +277,7 @@ public class TestMasterNoCluster {
InterruptedException, KeeperException, CoordinatedStateException {
super.initializeZKBasedSystemTrackers();
// Record a newer server in server manager at first
serverManager.recordNewServerWithLock(newServer, ServerLoad.EMPTY_SERVERLOAD);
getServerManager().recordNewServerWithLock(newServer, ServerLoad.EMPTY_SERVERLOAD);
List<ServerName> onlineServers = new ArrayList<ServerName>();
onlineServers.add(deadServer);
@ -310,7 +310,7 @@ public class TestMasterNoCluster {
LOG.info("Master is initialized");
assertFalse("The dead server should not be pulled in",
master.serverManager.isServerOnline(deadServer));
master.getServerManager().isServerOnline(deadServer));
} finally {
master.stopMaster();
master.join();

View File

@ -160,7 +160,7 @@ public class TestRegionPlacement {
// Check when a RS stops, the regions get assigned to their secondary/tertiary
killRandomServerAndVerifyAssignment();
// also verify that the AssignmentVerificationReport has the correct information
reports = rp.verifyRegionPlacement(false);
report = reports.get(0);
@ -179,7 +179,7 @@ public class TestRegionPlacement {
RegionPlacementMaintainer.printAssignmentPlan(currentPlan);
}
private void killRandomServerAndVerifyAssignment()
private void killRandomServerAndVerifyAssignment()
throws IOException, InterruptedException, KeeperException {
ServerName serverToKill = null;
int killIndex = 0;
@ -216,15 +216,15 @@ public class TestRegionPlacement {
entry.getValue()[1] + " " + entry.getValue()[2]);
}
}
int orig = TEST_UTIL.getHBaseCluster().getMaster().assignmentManager.getNumRegionsOpened();
int orig = TEST_UTIL.getHBaseCluster().getMaster().getAssignmentManager().getNumRegionsOpened();
TEST_UTIL.getHBaseCluster().stopRegionServer(serverToKill);
TEST_UTIL.getHBaseCluster().waitForRegionServerToStop(serverToKill, 60000);
int curr = TEST_UTIL.getHBaseCluster().getMaster().assignmentManager.getNumRegionsOpened();
int curr = TEST_UTIL.getHBaseCluster().getMaster().getAssignmentManager().getNumRegionsOpened();
while (curr - orig < regionsToVerify.size()) {
LOG.debug("Waiting for " + regionsToVerify.size() + " to come online " +
" Current #regions " + curr + " Original #regions " + orig);
Thread.sleep(200);
curr = TEST_UTIL.getHBaseCluster().getMaster().assignmentManager.getNumRegionsOpened();
curr = TEST_UTIL.getHBaseCluster().getMaster().getAssignmentManager().getNumRegionsOpened();
}
// now verify
for (Map.Entry<HRegionInfo, Pair<ServerName, ServerName>> entry : regionsToVerify.entrySet()) {
@ -369,7 +369,7 @@ public class TestRegionPlacement {
throws InterruptedException, IOException {
MiniHBaseCluster cluster = TEST_UTIL.getHBaseCluster();
HMaster m = cluster.getMaster();
int lastRegionOpenedCount = m.assignmentManager.getNumRegionsOpened();
int lastRegionOpenedCount = m.getAssignmentManager().getNumRegionsOpened();
// get the assignments start to execute
m.balance();
@ -378,7 +378,7 @@ public class TestRegionPlacement {
int attempt = 0;
int currentRegionOpened, regionMovement;
do {
currentRegionOpened = m.assignmentManager.getNumRegionsOpened();
currentRegionOpened = m.getAssignmentManager().getNumRegionsOpened();
regionMovement= currentRegionOpened - lastRegionOpenedCount;
LOG.debug("There are " + regionMovement + "/" + expected +
" regions moved after " + attempt + " attempts");