/** * Get a new region server at random from this peer * @return * @throws IOException */ private HRegionInterface getRS() throws IOException { if (this.currentPeers.size() == 0) { throw new IOException(this.peerClusterZnode + " has 0 region servers"); } ServerName address = currentPeers.get(random.nextInt(this.currentPeers.size())); return this.conn.getHRegionConnection(address.getHostname(), address.getPort()); }
/** * @param sn * @return * @throws IOException * @throws RetriesExhaustedException wrapping a ConnectException if failed * putting up proxy. */ private HRegionInterface getServerConnection(final ServerName sn) throws IOException { HRegionInterface hri = this.serverConnections.get(sn); if (hri == null) { LOG.debug("New connection to " + sn.toString()); hri = this.connection.getHRegionConnection(sn.getHostname(), sn.getPort()); this.serverConnections.put(sn, hri); } return hri; }
/** * Stop the designated regionserver * @param hostnamePort Hostname and port delimited by a <code>:</code> as in * <code>example.org:1234</code> * @throws IOException if a remote or network exception occurs */ public synchronized void stopRegionServer(final String hostnamePort) throws IOException { String hostname = Addressing.parseHostname(hostnamePort); int port = Addressing.parsePort(hostnamePort); HRegionInterface rs = this.connection.getHRegionConnection(hostname, port); rs.stop("Called by admin client " + this.connection.toString()); }
private void split(final ServerName sn, final HRegionInfo hri, byte[] splitPoint) throws IOException { HRegionInterface rs = this.connection.getHRegionConnection(sn.getHostname(), sn.getPort()); rs.splitRegion(hri, splitPoint); }
private void flush(final ServerName sn, final HRegionInfo hri) throws IOException { HRegionInterface rs = this.connection.getHRegionConnection(sn.getHostname(), sn.getPort()); rs.flushRegion(hri); }
/** * Connect to the server hosting region with row from tablename. * @param reload Set this to true if connection should re-find the region * @throws IOException e */ public void connect(final boolean reload) throws IOException { this.location = connection.getRegionLocation(tableName, row, reload); this.server = connection.getHRegionConnection(location.getHostname(), location.getPort()); }
private void compact(final ServerName sn, final HRegionInfo hri, final boolean major, final byte [] family) throws IOException { HRegionInterface rs = this.connection.getHRegionConnection(sn.getHostname(), sn.getPort()); if (family != null) { try { rs.compactRegion(hri, major, family); } catch (IOException ioe) { String notFoundMsg = "java.lang.NoSuchMethodException: org.apache.hadoop.hbase.ipc.HRegionInterface." + "compactRegion(org.apache.hadoop.hbase.HRegionInfo, boolean, [B)"; if (ioe.getMessage().contains(notFoundMsg)) { throw new IOException("per-column family compaction not supported on this version " + "of the HBase server. You may still compact at the table or region level by " + "omitting the column family name. Alternatively, you can upgrade the HBase server"); } throw ioe; } } else { rs.compactRegion(hri, major); } }
protocol = connection.getHRegionConnection(sn.getHostname(), sn.getPort()); } catch (RetriesExhaustedException e) { if (e.getCause() != null && e.getCause() instanceof ConnectException) {
HRegionInterface rs = this.connection.getHRegionConnection( sn.getHostname(), sn.getPort());
/** * Close a region. For expert-admins Runs close on the regionserver. The * master will not be informed of the close. * @param sn * @param hri * @throws IOException */ public void closeRegion(final ServerName sn, final HRegionInfo hri) throws IOException { HRegionInterface rs = this.connection.getHRegionConnection(sn.getHostname(), sn.getPort()); // Close the region without updating zk state. rs.closeRegion(hri, false); }
/** * Contacts a region server and waits up to hbase.hbck.close.timeout ms * (default 120s) to close the region. This bypasses the active hmaster. */ public static void closeRegionSilentlyAndWait(HBaseAdmin admin, ServerName server, HRegionInfo region) throws IOException, InterruptedException { HConnection connection = admin.getConnection(); HRegionInterface rs = connection.getHRegionConnection(server.getHostname(), server.getPort()); rs.closeRegion(region, false); long timeout = admin.getConfiguration() .getLong("hbase.hbck.close.timeout", 120000); long expiration = timeout + System.currentTimeMillis(); while (System.currentTimeMillis() < expiration) { try { HRegionInfo rsRegion = rs.getRegionInfo(region.getRegionName()); if (rsRegion == null) return; } catch (IOException ioe) { return; } Thread.sleep(1000); } throw new IOException("Region " + region + " failed to close within" + " timeout " + timeout); }
/** * Roll the log writer. That is, start writing log messages to a new file. * * @param serverName * The servername of the regionserver. A server name is made of host, * port and startcode. This is mandatory. Here is an example: * <code> host187.example.com,60020,1289493121758</code> * @return If lots of logs, flush the returned regions so next time through * we can clean logs. Returns null if nothing to flush. Names are actual * region names as returned by {@link HRegionInfo#getEncodedName()} * @throws IOException if a remote or network exception occurs * @throws FailedLogCloseException */ public synchronized byte[][] rollHLogWriter(String serverName) throws IOException, FailedLogCloseException { ServerName sn = new ServerName(serverName); HRegionInterface rs = this.connection.getHRegionConnection( sn.getHostname(), sn.getPort()); return rs.rollHLogWriter(); }
connection.getHRegionConnection(firstMetaServer.getHostname(), firstMetaServer.getPort()); for (int tries = 0; tries < (this.numRetries * this.retryLongerMultiplier); tries++) { long scannerId = -1L;
ServerName sn = regionServerPair.getSecond(); HRegionInterface rs = this.connection.getHRegionConnection(sn.getHostname(), sn.getPort()); return CompactionState.valueOf( rs.getCompactionState(regionServerPair.getFirst().getRegionName())); ServerName sn = pair.getSecond(); HRegionInterface rs = this.connection.getHRegionConnection(sn.getHostname(), sn.getPort()); switch (CompactionState.valueOf( rs.getCompactionState(pair.getFirst().getRegionName()))) {
try { HRegionInterface server = connection.getHRegionConnection(rsinfo.getHostname(), rsinfo.getPort());