Java Code Examples for org.apache.hadoop.hbase.ServerName#equals()
The following examples show how to use
org.apache.hadoop.hbase.ServerName#equals() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RestartRsHoldingMetaAction.java From hbase with Apache License 2.0 | 6 votes |
@Override public void perform() throws Exception { getLogger().info("Performing action: Restart region server holding META"); ServerName server = cluster.getServerHoldingMeta(); if (server == null) { getLogger().warn("No server is holding hbase:meta right now."); return; } ClusterMetrics clusterStatus = cluster.getClusterMetrics(); if (server.equals(clusterStatus.getMasterName())) { // Master holds the meta, so restart the master. restartMaster(server, sleepTime); } else { restartRs(server, sleepTime); } }
Example 2
Source File: TestRegionServerReportForDuty.java From hbase with Apache License 2.0 | 6 votes |
@Override protected synchronized ServerName createRegionServerStatusStub(boolean refresh) { sn = super.createRegionServerStatusStub(refresh); rpcStubCreatedFlag = true; // Wait for master switch over. Only do this for the second region server. while (!masterChanged) { ServerName newSn = super.getMasterAddressTracker().getMasterAddress(true); if (newSn != null && !newSn.equals(sn)) { masterChanged = true; break; } try { Thread.sleep(SLEEP_INTERVAL); } catch (InterruptedException e) { return null; } LOG.debug("Waiting for master switch over ... "); } return sn; }
Example 3
Source File: TestClusterRestartFailover.java From hbase with Apache License 2.0 | 6 votes |
@Override public List<RegionInfo> getRegionsOnServer(ServerName serverName) { List<RegionInfo> regions = super.getRegionsOnServer(serverName); // ServerCrashProcedure will call this method, so wait the CountDownLatch here if (SCP_LATCH != null && SERVER_FOR_TEST != null && serverName.equals(SERVER_FOR_TEST)) { try { LOG.info("ServerCrashProcedure wait the CountDownLatch here"); SCP_LATCH.await(); LOG.info("Continue the ServerCrashProcedure"); SCP_LATCH = null; } catch (InterruptedException e) { throw new RuntimeException(e); } } return regions; }
Example 4
Source File: TestWakeUpUnexpectedProcedure.java From hbase with Apache License 2.0 | 6 votes |
@Override public boolean isServerOnline(ServerName serverName) { ServerName toKill = SERVER_TO_KILL; if (toKill != null && toKill.equals(serverName)) { for (StackTraceElement ele : new Exception().getStackTrace()) { // halt it is called from RSProcedureDispatcher, to delay the remoteCallFailed. if ("scheduleForRetry".equals(ele.getMethodName())) { if (RESUME_IS_SERVER_ONLINE != null) { try { RESUME_IS_SERVER_ONLINE.await(); } catch (InterruptedException e) { throw new RuntimeException(e); } } break; } } } return super.isServerOnline(serverName); }
Example 5
Source File: BaseMRIOTest.java From spliceengine with GNU Affero General Public License v3.0 | 5 votes |
protected static ServerName getNotIn(Collection<ServerName> allServers, ServerName regionServer) { ServerName firstNonMatch = null; for (ServerName sn : allServers) { if (! sn.equals(regionServer)) { firstNonMatch = sn; break; } } return firstNonMatch; }
Example 6
Source File: TestRSGroupsBase.java From hbase with Apache License 2.0 | 5 votes |
protected int getNumServers() throws IOException { ClusterMetrics status = ADMIN.getClusterMetrics(EnumSet.of(Option.MASTER, Option.LIVE_SERVERS)); ServerName masterName = status.getMasterName(); int count = 0; for (ServerName sn : status.getLiveServerMetrics().keySet()) { if (!sn.equals(masterName)) { count++; } } return count; }
Example 7
Source File: AssignmentTestingUtil.java From hbase with Apache License 2.0 | 5 votes |
public static boolean isServerHoldingMeta(final HBaseTestingUtility util, final ServerName serverName) throws Exception { for (RegionInfo hri: getMetaRegions(util)) { if (serverName.equals(getServerHoldingRegion(util, hri))) { return true; } } return false; }
Example 8
Source File: RestartRandomRsExceptMetaAction.java From hbase with Apache License 2.0 | 5 votes |
@Override public void perform() throws Exception { int tries = 10; while (tries-- > 0 && getCurrentServers().length > 1) { ServerName server = PolicyBasedChaosMonkey.selectRandomItem(getCurrentServers()); ServerName metaServer = cluster.getServerHoldingMeta(); if (server != null && !server.equals(metaServer)) { restartRs(server, sleepTime); break; } } }
Example 9
Source File: TestRegionObserverInterface.java From hbase with Apache License 2.0 | 5 votes |
@Test public void testPreWALRestoreSkip() throws Exception { LOG.info(TestRegionObserverInterface.class.getName() + "." + name.getMethodName()); TableName tableName = TableName.valueOf(SimpleRegionObserver.TABLE_SKIPPED); Table table = util.createTable(tableName, new byte[][] { A, B, C }); try (RegionLocator locator = util.getConnection().getRegionLocator(tableName)) { JVMClusterUtil.RegionServerThread rs1 = cluster.startRegionServer(); ServerName sn2 = rs1.getRegionServer().getServerName(); String regEN = locator.getAllRegionLocations().get(0).getRegion().getEncodedName(); util.getAdmin().move(Bytes.toBytes(regEN), sn2); while (!sn2.equals(locator.getAllRegionLocations().get(0).getServerName())) { Thread.sleep(100); } Put put = new Put(ROW); put.addColumn(A, A, A); put.addColumn(B, B, B); put.addColumn(C, C, C); table.put(put); cluster.killRegionServer(rs1.getRegionServer().getServerName()); Threads.sleep(20000); // just to be sure that the kill has fully started. util.waitUntilAllRegionsAssigned(tableName); } verifyMethodResult(SimpleRegionObserver.class, new String[] { "getCtPreWALRestore", "getCtPostWALRestore", }, tableName, new Integer[] { 0, 0 }); util.deleteTable(tableName); table.close(); }
Example 10
Source File: MajorCompactor.java From hbase with Apache License 2.0 | 5 votes |
public void compactAllRegions() throws Exception { List<Future<?>> futures = Lists.newArrayList(); while (clusterCompactionQueues.hasWorkItems() || !futuresComplete(futures)) { while (clusterCompactionQueues.atCapacity()) { LOG.debug("Waiting for servers to complete Compactions"); Thread.sleep(sleepForMs); } Optional<ServerName> serverToProcess = clusterCompactionQueues.getLargestQueueFromServersNotCompacting(); if (serverToProcess.isPresent() && clusterCompactionQueues.hasWorkItems()) { ServerName serverName = serverToProcess.get(); // check to see if the region has moved... if so we have to enqueue it again with // the proper serverName MajorCompactionRequest request = clusterCompactionQueues.reserveForCompaction(serverName); ServerName currentServer = connection.getRegionLocator(tableName) .getRegionLocation(request.getRegion().getStartKey()).getServerName(); if (!currentServer.equals(serverName)) { // add it back to the queue with the correct server it should be picked up in the future. LOG.info("Server changed for region: " + request.getRegion().getEncodedName() + " from: " + serverName + " to: " + currentServer + " re-queuing request"); clusterCompactionQueues.addToCompactionQueue(currentServer, request); clusterCompactionQueues.releaseCompaction(serverName); } else { LOG.info("Firing off compaction request for server: " + serverName + ", " + request + " total queue size left: " + clusterCompactionQueues .getCompactionRequestsLeftToFinish()); futures.add(executor.submit(new Compact(serverName, request))); } } else { // haven't assigned anything so we sleep. Thread.sleep(sleepForMs); } } LOG.info("All compactions have completed"); }
Example 11
Source File: RegionMover.java From hbase with Apache License 2.0 | 5 votes |
/** * Returns true if passed region is still on serverName when we look at hbase:meta. * @return true if region is hosted on serverName otherwise false */ private boolean isSameServer(RegionInfo region, ServerName serverName) throws IOException { ServerName serverForRegion = getServerNameForRegion(region); if (serverForRegion != null && serverForRegion.equals(serverName)) { return true; } return false; }
Example 12
Source File: MasterMetaBootstrap.java From hbase with Apache License 2.0 | 5 votes |
/** * For assigning hbase:meta replicas only. * TODO: The way this assign runs, nothing but chance to stop all replicas showing up on same * server as the hbase:meta region. */ void assignMetaReplicas() throws IOException, InterruptedException, KeeperException { int numReplicas = master.getConfiguration().getInt(HConstants.META_REPLICAS_NUM, HConstants.DEFAULT_META_REPLICA_NUM); if (numReplicas <= 1) { // No replicaas to assign. Return. return; } final AssignmentManager assignmentManager = master.getAssignmentManager(); if (!assignmentManager.isMetaLoaded()) { throw new IllegalStateException("hbase:meta must be initialized first before we can " + "assign out its replicas"); } ServerName metaServername = MetaTableLocator.getMetaRegionLocation(this.master.getZooKeeper()); for (int i = 1; i < numReplicas; i++) { // Get current meta state for replica from zk. RegionState metaState = MetaTableLocator.getMetaRegionState(master.getZooKeeper(), i); RegionInfo hri = RegionReplicaUtil.getRegionInfoForReplica( RegionInfoBuilder.FIRST_META_REGIONINFO, i); LOG.debug(hri.getRegionNameAsString() + " replica region state from zookeeper=" + metaState); if (metaServername.equals(metaState.getServerName())) { metaState = null; LOG.info(hri.getRegionNameAsString() + " old location is same as current hbase:meta location; setting location as null..."); } // These assigns run inline. All is blocked till they complete. Only interrupt is shutting // down hosting server which calls AM#stop. if (metaState != null && metaState.getServerName() != null) { // Try to retain old assignment. assignmentManager.assignAsync(hri, metaState.getServerName()); } else { assignmentManager.assignAsync(hri); } } unassignExcessMetaReplica(numReplicas); }
Example 13
Source File: HMaster.java From hbase with Apache License 2.0 | 5 votes |
/** * Remove decommission marker (previously called 'draining') from a region server to allow regions * assignments. Load regions onto the server asynchronously if a list of regions is given * @param server Region server to remove decommission marker from. */ public void recommissionRegionServer(final ServerName server, final List<byte[]> encodedRegionNames) throws IOException { // Remove the server from decommissioned (draining) server list. String parentZnode = getZooKeeper().getZNodePaths().drainingZNode; String node = ZNodePaths.joinZNode(parentZnode, server.getServerName()); try { ZKUtil.deleteNodeFailSilent(getZooKeeper(), node); } catch (KeeperException ke) { throw new HBaseIOException( this.zooKeeper.prefix("Unable to recommission '" + server.getServerName() + "'."), ke); } this.serverManager.removeServerFromDrainList(server); // Load the regions onto the server if we are given a list of regions. if (encodedRegionNames == null || encodedRegionNames.isEmpty()) { return; } if (!this.serverManager.isServerOnline(server)) { return; } for (byte[] encodedRegionName : encodedRegionNames) { RegionState regionState = assignmentManager.getRegionStates().getRegionState(Bytes.toString(encodedRegionName)); if (regionState == null) { LOG.warn("Unknown region " + Bytes.toStringBinary(encodedRegionName)); continue; } RegionInfo hri = regionState.getRegion(); if (server.equals(regionState.getServerName())) { LOG.info("Skipping move of region " + hri.getRegionNameAsString() + " because region already assigned to the same server " + server + "."); continue; } RegionPlan rp = new RegionPlan(hri, regionState.getServerName(), server); this.assignmentManager.moveAsync(rp); } }
Example 14
Source File: AssignmentManager.java From hbase with Apache License 2.0 | 5 votes |
private void acceptPlan(final HashMap<RegionInfo, RegionStateNode> regions, final Map<ServerName, List<RegionInfo>> plan) throws HBaseIOException { final ProcedureEvent<?>[] events = new ProcedureEvent[regions.size()]; final long st = System.currentTimeMillis(); if (plan == null) { throw new HBaseIOException("unable to compute plans for regions=" + regions.size()); } if (plan.isEmpty()) return; int evcount = 0; for (Map.Entry<ServerName, List<RegionInfo>> entry: plan.entrySet()) { final ServerName server = entry.getKey(); for (RegionInfo hri: entry.getValue()) { final RegionStateNode regionNode = regions.get(hri); regionNode.setRegionLocation(server); if (server.equals(LoadBalancer.BOGUS_SERVER_NAME) && regionNode.isSystemTable()) { assignQueueLock.lock(); try { pendingAssignQueue.add(regionNode); } finally { assignQueueLock.unlock(); } }else { events[evcount++] = regionNode.getProcedureEvent(); } } } ProcedureEvent.wakeEvents(getProcedureScheduler(), events); final long et = System.currentTimeMillis(); if (LOG.isTraceEnabled()) { LOG.trace("ASSIGN ACCEPT " + events.length + " -> " + StringUtils.humanTimeDiff(et - st)); } }
Example 15
Source File: ServerManager.java From hbase with Apache License 2.0 | 4 votes |
synchronized long expireServer(final ServerName serverName, boolean force) { // THIS server is going down... can't handle our own expiration. if (serverName.equals(master.getServerName())) { if (!(master.isAborted() || master.isStopped())) { master.stop("We lost our znode?"); } return Procedure.NO_PROC_ID; } if (this.deadservers.isDeadServer(serverName)) { LOG.warn("Expiration called on {} but already in DeadServer", serverName); return Procedure.NO_PROC_ID; } moveFromOnlineToDeadServers(serverName); // If server is in draining mode, remove corresponding znode // In some tests, the mocked HM may not have ZK Instance, hence null check if (master.getZooKeeper() != null) { String drainingZnode = ZNodePaths .joinZNode(master.getZooKeeper().getZNodePaths().drainingZNode, serverName.getServerName()); try { ZKUtil.deleteNodeFailSilent(master.getZooKeeper(), drainingZnode); } catch (KeeperException e) { LOG.warn("Error deleting the draining znode for stopping server " + serverName.getServerName(), e); } } // If cluster is going down, yes, servers are going to be expiring; don't // process as a dead server if (isClusterShutdown()) { LOG.info("Cluster shutdown set; " + serverName + " expired; onlineServers=" + this.onlineServers.size()); if (this.onlineServers.isEmpty()) { master.stop("Cluster shutdown set; onlineServer=0"); } return Procedure.NO_PROC_ID; } LOG.info("Processing expiration of " + serverName + " on " + this.master.getServerName()); long pid = master.getAssignmentManager().submitServerCrash(serverName, true, force); // Tell our listeners that a server was removed if (!this.listeners.isEmpty()) { this.listeners.stream().forEach(l -> l.serverRemoved(serverName)); } // trigger a persist of flushedSeqId if (flushedSeqIdFlusher != null) { flushedSeqIdFlusher.triggerNow(); } return pid; }
Example 16
Source File: AssignmentManager.java From hbase with Apache License 2.0 | 4 votes |
private boolean isCarryingRegion(final ServerName serverName, final RegionInfo regionInfo) { // TODO: check for state? final RegionStateNode node = regionStates.getRegionStateNode(regionInfo); return(node != null && serverName.equals(node.getRegionLocation())); }
Example 17
Source File: TestMetaShutdownHandler.java From hbase with Apache License 2.0 | 4 votes |
/** * This test will test the expire handling of a meta-carrying * region server. * After HBaseMiniCluster is up, we will delete the ephemeral * node of the meta-carrying region server, which will trigger * the expire of this region server on the master. * On the other hand, we will slow down the abort process on * the region server so that it is still up during the master SSH. * We will check that the master SSH is still successfully done. */ @Test public void testExpireMetaRegionServer() throws Exception { MiniHBaseCluster cluster = TEST_UTIL.getHBaseCluster(); HMaster master = cluster.getMaster(); RegionStates regionStates = master.getAssignmentManager().getRegionStates(); ServerName metaServerName = regionStates.getRegionServerOfRegion(RegionInfoBuilder.FIRST_META_REGIONINFO); if (master.getServerName().equals(metaServerName) || metaServerName == null || !metaServerName.equals(cluster.getServerHoldingMeta())) { // Move meta off master metaServerName = cluster.getLiveRegionServerThreads().get(0).getRegionServer().getServerName(); master.move(RegionInfoBuilder.FIRST_META_REGIONINFO.getEncodedNameAsBytes(), Bytes.toBytes(metaServerName.getServerName())); TEST_UTIL.waitUntilNoRegionsInTransition(60000); metaServerName = regionStates.getRegionServerOfRegion(RegionInfoBuilder.FIRST_META_REGIONINFO); } RegionState metaState = MetaTableLocator.getMetaRegionState(master.getZooKeeper()); assertEquals("Wrong state for meta!", RegionState.State.OPEN, metaState.getState()); assertNotEquals("Meta is on master!", metaServerName, master.getServerName()); // Delete the ephemeral node of the meta-carrying region server. // This is trigger the expire of this region server on the master. String rsEphemeralNodePath = ZNodePaths.joinZNode(master.getZooKeeper().getZNodePaths().rsZNode, metaServerName.toString()); ZKUtil.deleteNode(master.getZooKeeper(), rsEphemeralNodePath); LOG.info("Deleted the znode for the RegionServer hosting hbase:meta; waiting on SSH"); // Wait for SSH to finish final ServerManager serverManager = master.getServerManager(); final ServerName priorMetaServerName = metaServerName; TEST_UTIL.waitFor(120000, 200, new Waiter.Predicate<Exception>() { @Override public boolean evaluate() throws Exception { return !serverManager.isServerOnline(priorMetaServerName) && !serverManager.areDeadServersInProgress(); } }); LOG.info("Past wait on RIT"); TEST_UTIL.waitUntilNoRegionsInTransition(60000); // Now, make sure meta is assigned assertTrue("Meta should be assigned", regionStates.isRegionOnline(RegionInfoBuilder.FIRST_META_REGIONINFO)); // Now, make sure meta is registered in zk metaState = MetaTableLocator.getMetaRegionState(master.getZooKeeper()); assertEquals("Meta should not be in transition", RegionState.State.OPEN, metaState.getState()); assertEquals("Meta should be assigned", metaState.getServerName(), regionStates.getRegionServerOfRegion(RegionInfoBuilder.FIRST_META_REGIONINFO)); assertNotEquals("Meta should be assigned on a different server", metaState.getServerName(), metaServerName); }
Example 18
Source File: FavoredNodeLoadBalancer.java From hbase with Apache License 2.0 | 4 votes |
@Override public List<RegionPlan> balanceTable(TableName tableName, Map<ServerName, List<RegionInfo>> loadOfOneTable) { // TODO. Look at is whether Stochastic loadbalancer can be integrated with this List<RegionPlan> plans = new ArrayList<>(); // perform a scan of the meta to get the latest updates (if any) SnapshotOfRegionAssignmentFromMeta snaphotOfRegionAssignment = new SnapshotOfRegionAssignmentFromMeta(super.services.getConnection()); try { snaphotOfRegionAssignment.initialize(); } catch (IOException ie) { LOG.warn("Not running balancer since exception was thrown " + ie); return plans; } // This is not used? Findbugs says so: Map<ServerName, ServerName> // serverNameToServerNameWithoutCode = new HashMap<>(); Map<ServerName, ServerName> serverNameWithoutCodeToServerName = new HashMap<>(); ServerManager serverMgr = super.services.getServerManager(); for (ServerName sn : serverMgr.getOnlineServersList()) { ServerName s = ServerName.valueOf(sn.getHostname(), sn.getPort(), ServerName.NON_STARTCODE); // FindBugs complains about useless store! serverNameToServerNameWithoutCode.put(sn, s); serverNameWithoutCodeToServerName.put(s, sn); } for (Map.Entry<ServerName, List<RegionInfo>> entry : loadOfOneTable.entrySet()) { ServerName currentServer = entry.getKey(); // get a server without the startcode for the currentServer ServerName currentServerWithoutStartCode = ServerName.valueOf(currentServer.getHostname(), currentServer.getPort(), ServerName.NON_STARTCODE); List<RegionInfo> list = entry.getValue(); for (RegionInfo region : list) { if (!FavoredNodesManager.isFavoredNodeApplicable(region)) { continue; } List<ServerName> favoredNodes = fnm.getFavoredNodes(region); if (favoredNodes == null || favoredNodes.get(0).equals(currentServerWithoutStartCode)) { continue; // either favorednodes does not exist or we are already on the primary node } ServerName destination = null; // check whether the primary is available destination = serverNameWithoutCodeToServerName.get(favoredNodes.get(0)); if (destination == null) { // check whether the region is on secondary/tertiary if (currentServerWithoutStartCode.equals(favoredNodes.get(1)) || currentServerWithoutStartCode.equals(favoredNodes.get(2))) { continue; } // the region is currently on none of the favored nodes // get it on one of them if possible ServerMetrics l1 = super.services.getServerManager() .getLoad(serverNameWithoutCodeToServerName.get(favoredNodes.get(1))); ServerMetrics l2 = super.services.getServerManager() .getLoad(serverNameWithoutCodeToServerName.get(favoredNodes.get(2))); if (l1 != null && l2 != null) { if (l1.getRegionMetrics().size() > l2.getRegionMetrics().size()) { destination = serverNameWithoutCodeToServerName.get(favoredNodes.get(2)); } else { destination = serverNameWithoutCodeToServerName.get(favoredNodes.get(1)); } } else if (l1 != null) { destination = serverNameWithoutCodeToServerName.get(favoredNodes.get(1)); } else if (l2 != null) { destination = serverNameWithoutCodeToServerName.get(favoredNodes.get(2)); } } if (destination != null) { RegionPlan plan = new RegionPlan(region, currentServer, destination); plans.add(plan); } } } return plans; }
Example 19
Source File: PhoenixServerRpcIT.java From phoenix with Apache License 2.0 | 4 votes |
/** * Verifies that the given tables each have a single region and are on * different region servers. If they are on the same server moves tableName2 * to the other region server. */ private void ensureTablesOnDifferentRegionServers(String tableName1, String tableName2) throws Exception { byte[] table1 = Bytes.toBytes(tableName1); byte[] table2 = Bytes.toBytes(tableName2); Admin admin = driver.getConnectionQueryServices(getUrl(), TEST_PROPERTIES).getAdmin(); HBaseTestingUtility util = getUtility(); MiniHBaseCluster cluster = util.getHBaseCluster(); HMaster master = cluster.getMaster(); AssignmentManager am = master.getAssignmentManager(); // verify there is only a single region for data table List<RegionInfo> tableRegions = admin.getRegions(TableName.valueOf(table1)); assertEquals("Expected single region for " + table1, tableRegions.size(), 1); RegionInfo hri1 = tableRegions.get(0); // verify there is only a single region for index table tableRegions = admin.getRegions(TableName.valueOf(table2)); RegionInfo hri2 = tableRegions.get(0); assertEquals("Expected single region for " + table2, tableRegions.size(), 1); ServerName serverName1 = am.getRegionStates().getRegionServerOfRegion(hri1); ServerName serverName2 = am.getRegionStates().getRegionServerOfRegion(hri2); // if data table and index table are on same region server, move the index table to the other region server if (serverName1.equals(serverName2)) { HRegionServer server1 = util.getHBaseCluster().getRegionServer(0); HRegionServer server2 = util.getHBaseCluster().getRegionServer(1); HRegionServer dstServer = null; HRegionServer srcServer = null; if (server1.getServerName().equals(serverName2)) { dstServer = server2; srcServer = server1; } else { dstServer = server1; srcServer = server2; } byte[] encodedRegionNameInBytes = hri2.getEncodedNameAsBytes(); admin.move(encodedRegionNameInBytes, Bytes.toBytes(dstServer.getServerName().getServerName())); while (dstServer.getOnlineRegion(hri2.getRegionName()) == null || dstServer.getRegionsInTransitionInRS().containsKey(encodedRegionNameInBytes) || srcServer.getRegionsInTransitionInRS().containsKey(encodedRegionNameInBytes) || master.getAssignmentManager().getRegionStates().isRegionInTransition(hri2)) { // wait for the move to be finished Thread.sleep(1); } } hri1 = admin.getRegions(TableName.valueOf(table1)).get(0); serverName1 = am.getRegionStates().getRegionServerOfRegion(hri1); hri2 = admin.getRegions(TableName.valueOf(table2)).get(0); serverName2 = am.getRegionStates().getRegionServerOfRegion(hri2); // verify index and data tables are on different servers assertNotEquals("Tables " + tableName1 + " and " + tableName2 + " should be on different region servers", serverName1, serverName2); }
Example 20
Source File: IndexLoadBalancer.java From phoenix with Apache License 2.0 | 4 votes |
private ServerName getServerNameFromMap(HRegionInfo regionInfo, List<ServerName> onlineServers) { TableName tableName = regionInfo.getTable(); TableName mappedTable = getMappedTableToColocate(regionInfo.getTable()); ImmutableBytesWritable startKey = new ImmutableBytesWritable(regionInfo.getStartKey()); synchronized (this.colocationInfo) { Map<ImmutableBytesWritable, ServerName> correspondingTableKeys = this.colocationInfo.get(mappedTable); Map<ImmutableBytesWritable, ServerName> actualTableKeys = this.colocationInfo.get(tableName); if (null != correspondingTableKeys) { if (correspondingTableKeys.containsKey(startKey)) { ServerName previousServer = null; if (null != actualTableKeys) { previousServer = actualTableKeys.get(startKey); } ServerName sn = correspondingTableKeys.get(startKey); if (null != previousServer) { // if servername of index region and user region are same in colocationInfo // clean // previous plans and return null if (previousServer.equals(sn)) { correspondingTableKeys.remove(startKey); actualTableKeys.remove(startKey); if (LOG.isDebugEnabled()) { LOG .debug("Both user region plan and corresponding index region plan " + "in colocation info are same. Hence clearing the plans to select new plan" + " for the region " + regionInfo.getRegionNameAsString() + "."); } return null; } } if (sn != null && onlineServers.contains(sn)) { if (LOG.isDebugEnabled()) { LOG.debug("Updating the region plan of the region " + regionInfo.getRegionNameAsString() + " with server " + sn); } regionOnline(regionInfo, sn); return sn; } else if (sn != null) { if (LOG.isDebugEnabled()) { LOG.debug("The location " + sn + " of region with start key" + Bytes.toStringBinary(regionInfo.getStartKey()) + " is not in online. Selecting other region server."); } return null; } } } else { if (LOG.isDebugEnabled()) { LOG.debug("No region plans in colocationInfo for table " + mappedTable); } } return null; } }