/** * @return String made of hostname and port formatted as * per {@link Addressing#createHostAndPortStr(String, int)} */ public String getHostnamePort() { return Addressing.createHostAndPortStr(this.getHostname(), this.getPort()); }
InetSocketAddress isa = new InetSocketAddress(location.getHostname(), location.getPort()); if (isa.isUnresolved()) { LOG.warn("Failed resolve " + isa);
/** * compare the local machine hostname with region server's hostname to decide if hbase client * connects to a remote region server */ protected void checkIfRegionServerIsRemote() { isRegionServerRemote = isRemote(getLocation().getHostname()); }
lastPos = startKeys.length % realNumSplits > i ? lastPos + 1 : lastPos; String regionLocation = regionLocator.getRegionLocation(startKeys[startPos]). getHostname(); splits[i] = new TableSplit(this.table.getName(), startKeys[startPos], ((i + 1) < realNumSplits) ? startKeys[lastPos]:
@Before public void setUp() throws Exception { byte[] ROW_BEFORE = ConnectionUtils.createCloseRowBefore(ROW); Configuration conf = Mockito.mock(Configuration.class); HRegionLocation regionLocation = Mockito.mock(HRegionLocation.class); ServerName serverName = Mockito.mock(ServerName.class); Mockito.when(connection.getConfiguration()).thenReturn(conf); Mockito.when(regionLocations.size()).thenReturn(1); Mockito.when(regionLocations.getRegionLocation(0)).thenReturn(regionLocation); Mockito.when(regionLocation.getHostname()).thenReturn("localhost"); Mockito.when(regionLocation.getServerName()).thenReturn(serverName); Mockito.when(scan.includeStartRow()).thenReturn(true); Mockito.when(scan.getStartRow()).thenReturn(ROW); }
private CompletableFuture<OpenScannerResponse> callOpenScanner(HBaseRpcController controller, HRegionLocation loc, ClientService.Interface stub) { boolean isRegionServerRemote = isRemote(loc.getHostname()); incRPCCallsMetrics(scanMetrics, isRegionServerRemote); if (openScannerTries.getAndIncrement() > 1) { incRPCRetriesMetrics(scanMetrics, isRegionServerRemote); } CompletableFuture<OpenScannerResponse> future = new CompletableFuture<>(); try { ScanRequest request = RequestConverter.buildScanRequest(loc.getRegion().getRegionName(), scan, scan.getCaching(), false); stub.scan(controller, request, resp -> { if (controller.failed()) { future.completeExceptionally(controller.getFailed()); return; } future.complete(new OpenScannerResponse(loc, isRegionServerRemote, stub, controller, resp)); }); } catch (IOException e) { future.completeExceptionally(e); } return future; }
String regionHostname = hregionLocation.getHostname(); HRegionInfo regionInfo = hregionLocation.getRegionInfo(); String encodedRegionName = regionInfo.getEncodedName();
@Nullable private String checkMetaLocationAndExplain(int originalReplicaCount) throws KeeperException, IOException { List<String> metaZnodes = TEST_UTIL.getZooKeeperWatcher().getMetaReplicaNodes(); if (metaZnodes.size() == originalReplicaCount) { RegionLocations rl = ((ClusterConnection) TEST_UTIL.getConnection()) .locateRegion(TableName.META_TABLE_NAME, HConstants.EMPTY_START_ROW, false, false); for (HRegionLocation location : rl.getRegionLocations()) { if (location == null) { return "Null location found in " + rl.toString(); } if (location.getRegionInfo() == null) { return "Null regionInfo for location " + location; } if (location.getHostname() == null) { return "Null hostName for location " + location; } } return null; // OK } return "Replica count is not as expected " + originalReplicaCount + " <> " + metaZnodes.size() + "(" + metaZnodes.toString() + ")"; }
return false; if (metaLocation.getHostname() == null) { errors.reportError(ERROR_CODE.NULL_META_REGION, "META location hostName is null");
private void init() { logger.debug("Getting region locations"); TableName tableName = TableName.valueOf(hbaseScanSpec.getTableName()); try (Admin admin = formatPlugin.getConnection().getAdmin(); RegionLocator locator = formatPlugin.getConnection().getRegionLocator(tableName)) { hTableDesc = admin.getTableDescriptor(tableName); // Fetch tableStats only once and cache it. if (tableStats == null) { tableStats = new MapRDBTableStats(getHBaseConf(), hbaseScanSpec.getTableName()); } boolean foundStartRegion = false; final TreeMap<TabletFragmentInfo, String> regionsToScan = new TreeMap<TabletFragmentInfo, String>(); List<HRegionLocation> regionLocations = locator.getAllRegionLocations(); for (HRegionLocation regionLocation : regionLocations) { HRegionInfo regionInfo = regionLocation.getRegionInfo(); if (!foundStartRegion && hbaseScanSpec.getStartRow() != null && hbaseScanSpec.getStartRow().length != 0 && !regionInfo.containsRow(hbaseScanSpec.getStartRow())) { continue; } foundStartRegion = true; regionsToScan.put(new TabletFragmentInfo(regionInfo), regionLocation.getHostname()); if (hbaseScanSpec.getStopRow() != null && hbaseScanSpec.getStopRow().length != 0 && regionInfo.containsRow(hbaseScanSpec.getStopRow())) { break; } } setRegionsToScan(regionsToScan); } catch (Exception e) { throw new DrillRuntimeException("Error getting region info for table: " + hbaseScanSpec.getTableName(), e); } HBaseUtils.verifyColumns(columns, hTableDesc); }
public static String getRegionLocation(HRegionLocation location, Log log) throws IOException { InetSocketAddress isa = new InetSocketAddress(location.getHostname(), location.getPort()); if (isa.isUnresolved()) { log.warn("Failed resolve " + isa); } InetAddress regionAddress = isa.getAddress(); String regionLocation = null; try { regionLocation = reverseDNS(regionAddress); } catch (NamingException e) { log.warn("Cannot resolve the host name for " + regionAddress + " because of " + e); regionLocation = location.getHostname(); } return regionLocation; }
/** * compare the local machine hostname with region server's hostname to decide if hbase client * connects to a remote region server */ protected void checkIfRegionServerIsRemote() { isRegionServerRemote = isRemote(getLocation().getHostname()); }
/** * @return String made of hostname and port formatted as * per {@link Addressing#createHostAndPortStr(String, int)} */ public String getHostnamePort() { return Addressing.createHostAndPortStr(this.getHostname(), this.getPort()); }
@Before public void setUp() throws Exception { byte[] ROW_BEFORE = ConnectionUtils.createCloseRowBefore(ROW); Configuration conf = Mockito.mock(Configuration.class); HRegionLocation regionLocation = Mockito.mock(HRegionLocation.class); ServerName serverName = Mockito.mock(ServerName.class); Mockito.when(connection.getConfiguration()).thenReturn(conf); Mockito.when(regionLocations.size()).thenReturn(1); Mockito.when(regionLocations.getRegionLocation(0)).thenReturn(regionLocation); Mockito.when(regionLocation.getHostname()).thenReturn("localhost"); Mockito.when(regionLocation.getServerName()).thenReturn(serverName); Mockito.when(scan.includeStartRow()).thenReturn(true); Mockito.when(scan.getStartRow()).thenReturn(ROW); }
private CompletableFuture<OpenScannerResponse> callOpenScanner(HBaseRpcController controller, HRegionLocation loc, ClientService.Interface stub) { boolean isRegionServerRemote = isRemote(loc.getHostname()); incRPCCallsMetrics(scanMetrics, isRegionServerRemote); if (openScannerTries > 1) { incRPCRetriesMetrics(scanMetrics, isRegionServerRemote); } openScannerTries++; CompletableFuture<OpenScannerResponse> future = new CompletableFuture<>(); try { ScanRequest request = RequestConverter.buildScanRequest(loc.getRegionInfo().getRegionName(), scan, scan.getCaching(), false); stub.scan(controller, request, resp -> { if (controller.failed()) { future.completeExceptionally(controller.getFailed()); return; } future.complete(new OpenScannerResponse(loc, isRegionServerRemote, stub, controller, resp)); }); } catch (IOException e) { future.completeExceptionally(e); } return future; }
); String regionLocation = location.getHostname();
); String regionLocation = location.getHostname();
assertNotNull(location); ServerName anySource = ServerName.valueOf(location.getHostname(), location.getPort() - 1, 0L);
/** * compare the local machine hostname with region server's hostname * to decide if hbase client connects to a remote region server * @throws UnknownHostException. */ private void checkIfRegionServerIsRemote() throws UnknownHostException { String myAddress = DNS.getDefaultHost("default", "default"); if (this.location.getHostname().equalsIgnoreCase(myAddress)) { isRegionServerRemote = false; } else { isRegionServerRemote = true; } }
/** * compare the local machine hostname with region server's hostname to decide if hbase client * connects to a remote region server */ protected void checkIfRegionServerIsRemote() { isRegionServerRemote = isRemote(getLocation().getHostname()); }