Java Code Examples for org.apache.hadoop.hbase.ServerName#isSameAddress()
The following examples show how to use
org.apache.hadoop.hbase.ServerName#isSameAddress() .
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: FavoredNodeAssignmentHelper.java From hbase with Apache License 2.0 | 6 votes |
public void initialize() { for (ServerName sn : this.servers) { String rackName = getRackOfServer(sn); List<ServerName> serverList = this.rackToRegionServerMap.get(rackName); if (serverList == null) { serverList = Lists.newArrayList(); // Add the current rack to the unique rack list this.uniqueRackList.add(rackName); this.rackToRegionServerMap.put(rackName, serverList); } for (ServerName serverName : serverList) { if (ServerName.isSameAddress(sn, serverName)) { // The server is already present, ignore. break; } } serverList.add((sn)); this.regionServerToRackMap.put(sn.getHostname(), rackName); } }
Example 2
Source File: FavoredStochasticBalancer.java From hbase with Apache License 2.0 | 6 votes |
private List<ServerName> getOnlineFavoredNodes(List<ServerName> onlineServers, List<ServerName> serversWithoutStartCodes) { if (serversWithoutStartCodes == null) { return null; } else { List<ServerName> result = Lists.newArrayList(); for (ServerName sn : serversWithoutStartCodes) { for (ServerName online : onlineServers) { if (ServerName.isSameAddress(sn, online)) { result.add(online); } } } return result; } }
Example 3
Source File: HRegionServer.java From hbase with Apache License 2.0 | 6 votes |
@Override public boolean removeRegion(final HRegion r, ServerName destination) { HRegion toReturn = this.onlineRegions.remove(r.getRegionInfo().getEncodedName()); metricsRegionServerImpl.requestsCountCache.remove(r.getRegionInfo().getEncodedName()); if (destination != null) { long closeSeqNum = r.getMaxFlushedSeqId(); if (closeSeqNum == HConstants.NO_SEQNUM) { // No edits in WAL for this region; get the sequence number when the region was opened. closeSeqNum = r.getOpenSeqNum(); if (closeSeqNum == HConstants.NO_SEQNUM) closeSeqNum = 0; } boolean selfMove = ServerName.isSameAddress(destination, this.getServerName()); addToMovedRegions(r.getRegionInfo().getEncodedName(), destination, closeSeqNum, selfMove); if (selfMove) { this.regionServerAccounting.getRetainedRegionRWRequestsCnt().put(r.getRegionInfo().getEncodedName() , new Pair<>(r.getReadRequestsCount(), r.getWriteRequestsCount())); } } this.regionFavoredNodesMap.remove(r.getRegionInfo().getEncodedName()); configurationManager.deregisterObserver(r); return toReturn != null; }
Example 4
Source File: TestFavoredStochasticLoadBalancer.java From hbase with Apache License 2.0 | 6 votes |
private void stopServersAndWaitUntilProcessed(List<ServerName> currentFN) throws Exception { for (ServerName sn : currentFN) { for (JVMClusterUtil.RegionServerThread rst : cluster.getLiveRegionServerThreads()) { if (ServerName.isSameAddress(sn, rst.getRegionServer().getServerName())) { LOG.info("Shutting down server: " + sn); cluster.stopRegionServer(rst.getRegionServer().getServerName()); cluster.waitForRegionServerToStop(rst.getRegionServer().getServerName(), 60000); } } } // Wait until dead servers are processed. TEST_UTIL.waitFor(60000, new Waiter.Predicate<Exception>() { @Override public boolean evaluate() throws Exception { return !master.getServerManager().areDeadServersInProgress(); } }); assertEquals("Not all servers killed", SLAVES - currentFN.size(), cluster.getLiveRegionServerThreads().size()); }
Example 5
Source File: RSGroupableBalancerTestBase.java From hbase with Apache License 2.0 | 6 votes |
protected void updateLoad( ArrayListMultimap<String, ServerAndLoad> previousLoad, final ServerName sn, final int diff) { for (String groupName : previousLoad.keySet()) { ServerAndLoad newSAL = null; ServerAndLoad oldSAL = null; for (ServerAndLoad sal : previousLoad.get(groupName)) { if (ServerName.isSameAddress(sn, sal.getServerName())) { oldSAL = sal; newSAL = new ServerAndLoad(sn, sal.getLoad() + diff); break; } } if (newSAL != null) { previousLoad.remove(groupName, oldSAL); previousLoad.put(groupName, newSAL); break; } } }
Example 6
Source File: FavoredNodesPlan.java From hbase with Apache License 2.0 | 5 votes |
/** * Return the position of the server in the favoredNodes list. Assumes the * favoredNodes list is of size 3. * @return position */ public static Position getFavoredServerPosition( List<ServerName> favoredNodes, ServerName server) { if (favoredNodes == null || server == null || favoredNodes.size() != FavoredNodeAssignmentHelper.FAVORED_NODES_NUM) { return null; } for (Position p : Position.values()) { if (ServerName.isSameAddress(favoredNodes.get(p.ordinal()),server)) { return p; } } return null; }
Example 7
Source File: FavoredNodeLoadBalancer.java From hbase with Apache License 2.0 | 5 votes |
private ServerName availableServersContains(List<ServerName> servers, ServerName favoredNode) { for (ServerName server : servers) { if (ServerName.isSameAddress(favoredNode, server)) { return server; } } return null; }
Example 8
Source File: FavoredStochasticBalancer.java From hbase with Apache License 2.0 | 5 votes |
private ServerName getServerFromFavoredNode(List<ServerName> servers, ServerName fn) { for (ServerName server : servers) { if (ServerName.isSameAddress(fn, server)) { return server; } } return null; }
Example 9
Source File: ServerManager.java From hbase with Apache License 2.0 | 5 votes |
/** * Assumes onlineServers is locked. * @return ServerName with matching hostname and port. */ private ServerName findServerWithSameHostnamePortWithLock( final ServerName serverName) { ServerName end = ServerName.valueOf(serverName.getHostname(), serverName.getPort(), Long.MAX_VALUE); ServerName r = onlineServers.lowerKey(end); if (r != null) { if (ServerName.isSameAddress(r, serverName)) { return r; } } return null; }
Example 10
Source File: DeadServer.java From hbase with Apache License 2.0 | 5 votes |
/** * @param newServerName Server to match port and hostname against. * @param deadServerIterator Iterator primed so can call 'next' on it. * @return True if <code>newServerName</code> and current primed * iterator ServerName have same host and port and we removed old server * from iterator and from processing list. */ private boolean cleanOldServerName(ServerName newServerName, Iterator<ServerName> deadServerIterator) { ServerName sn = deadServerIterator.next(); if (ServerName.isSameAddress(sn, newServerName)) { // Remove from dead servers list. Don't remove from the processing list -- // let the SCP do it when it is done. deadServerIterator.remove(); return true; } return false; }
Example 11
Source File: TestFavoredStochasticBalancerPickers.java From hbase with Apache License 2.0 | 5 votes |
private List<RegionInfo> getRegionsThatCanBeMoved(TableName tableName, ServerName serverName) { List<RegionInfo> regions = Lists.newArrayList(); RegionStates rst = cluster.getMaster().getAssignmentManager().getRegionStates(); FavoredNodesManager fnm = cluster.getMaster().getFavoredNodesManager(); for (RegionInfo regionInfo : fnm.getRegionsOfFavoredNode(serverName)) { if (regionInfo.getTable().equals(tableName) && !ServerName.isSameAddress(rst.getRegionServerOfRegion(regionInfo), serverName)) { regions.add(regionInfo); } } return regions; }
Example 12
Source File: TestFavoredStochasticBalancerPickers.java From hbase with Apache License 2.0 | 5 votes |
private boolean doesMatchExcludeNodes(List<ServerName> excludeNodes, ServerName sn) { for (ServerName excludeSN : excludeNodes) { if (ServerName.isSameAddress(sn, excludeSN)) { return true; } } return false; }
Example 13
Source File: TestFavoredStochasticLoadBalancer.java From hbase with Apache License 2.0 | 5 votes |
@Test public void testRandomAssignmentWithNoFavNodes() throws Exception { final String tableName = "testRandomAssignmentWithNoFavNodes"; TableDescriptorBuilder.ModifyableTableDescriptor tableDescriptor = new TableDescriptorBuilder.ModifyableTableDescriptor(TableName.valueOf(tableName)); tableDescriptor.setColumnFamily( new ColumnFamilyDescriptorBuilder.ModifyableColumnFamilyDescriptor( HConstants.CATALOG_FAMILY)); admin.createTable(tableDescriptor); TEST_UTIL.waitTableAvailable(tableDescriptor.getTableName()); RegionInfo hri = admin.getRegions(TableName.valueOf(tableName)).get(0); FavoredNodesManager fnm = master.getFavoredNodesManager(); fnm.deleteFavoredNodesForRegions(Lists.newArrayList(hri)); assertNull("Favored nodes not found null after delete", fnm.getFavoredNodes(hri)); LoadBalancer balancer = master.getLoadBalancer(); ServerName destination = balancer.randomAssignment(hri, Lists.newArrayList(admin .getClusterMetrics(EnumSet.of(Option.LIVE_SERVERS)).getLiveServerMetrics() .keySet().stream().collect(Collectors.toList()))); assertNotNull(destination); List<ServerName> favoredNodes = fnm.getFavoredNodes(hri); assertNotNull(favoredNodes); boolean containsFN = false; for (ServerName sn : favoredNodes) { if (ServerName.isSameAddress(destination, sn)) { containsFN = true; } } assertTrue("Destination server does not belong to favored nodes.", containsFN); }
Example 14
Source File: TestRegionPlacement2.java From hbase with Apache License 2.0 | 5 votes |
private List<ServerName> removeMatchingServers(ServerName serverWithoutStartCode, List<ServerName> servers) { List<ServerName> serversToRemove = new ArrayList<>(); for (ServerName s : servers) { if (ServerName.isSameAddress(s, serverWithoutStartCode)) { serversToRemove.add(s); } } servers.removeAll(serversToRemove); return serversToRemove; }