@Override public void updateConfiguration(final ServerName server) throws IOException { final AdminService.BlockingInterface admin = this.connection.getAdmin(server); Callable<Void> callable = new Callable<Void>() { @Override public Void call() throws Exception { admin.updateConfiguration(null, UpdateConfigurationRequest.getDefaultInstance()); return null; } }; ProtobufUtil.call(callable); }
@Override public AdminProtos.AdminService.BlockingInterface getAdminProtocol(ServerName serverName) throws IOException { return ((ClusterConnection)this.connection).getAdmin(serverName); }
@Override public void unassign(byte[] regionName) throws IOException { clusterConnection.getAdmin().unassign(regionName, false); }
/** * Get a randomly-chosen replication sink to replicate to. * * @return a replication sink to replicate to */ public synchronized SinkPeer getReplicationSink() throws IOException { if (endpoint.getLastRegionServerUpdate() > this.lastUpdateToPeers || sinks.isEmpty()) { LOG.info("Current list of sinks is out of date or empty, updating"); chooseSinks(); } if (sinks.isEmpty()) { throw new IOException("No replication sinks are available"); } ServerName serverName = sinks.get(random.nextInt(sinks.size())); return new SinkPeer(serverName, ((ClusterConnection) conn).getAdmin(serverName)); }
@Override public List<RegionInfo> getRegions(final ServerName sn) throws IOException { AdminService.BlockingInterface admin = this.connection.getAdmin(sn); // TODO: There is no timeout on this controller. Set one! HBaseRpcController controller = rpcControllerFactory.newController(); return ProtobufUtil.getOnlineRegions(controller, admin); }
@Override public void compactRegionServer(final ServerName serverName) throws IOException { for (RegionInfo region : getRegions(serverName)) { compact(this.connection.getAdmin(serverName), region, false, null); } }
@Override public void flushRegionServer(ServerName serverName) throws IOException { for (RegionInfo region : getRegions(serverName)) { flush(this.connection.getAdmin(serverName), region); } }
@Override public void majorCompactRegionServer(final ServerName serverName) throws IOException { for (RegionInfo region : getRegions(serverName)) { compact(this.connection.getAdmin(serverName), region, true, null); } }
@Override public List<RegionMetrics> getRegionMetrics(ServerName serverName, TableName tableName) throws IOException { AdminService.BlockingInterface admin = this.connection.getAdmin(serverName); HBaseRpcController controller = rpcControllerFactory.newController(); AdminProtos.GetRegionLoadRequest request = RequestConverter.buildGetRegionLoadRequest(tableName); try { return admin.getRegionLoad(controller, request).getRegionLoadsList().stream() .map(RegionMetricsBuilder::toRegionMetrics).collect(Collectors.toList()); } catch (ServiceException se) { throw ProtobufUtil.getRemoteException(se); } }
@Override public void enable() throws IOException { try { if (LOG.isTraceEnabled()) { LOG.trace("Starting disable of " + getTableName()); } getRegionServerServices().getClusterConnection().getAdmin().disableTable(getTableName()); if (LOG.isTraceEnabled()) { LOG.trace("Disable is complete for " + getTableName()); } } catch (TableNotEnabledException tnee) { // The state we wanted it to be in. } }
@Override public void disable() throws IOException { try { if (LOG.isTraceEnabled()) { LOG.trace("Starting enable of " + getTableName()); } getRegionServerServices().getClusterConnection().getAdmin().enableTable(getTableName()); if (LOG.isTraceEnabled()) { LOG.trace("Enable is complete for " + getTableName()); } } catch (TableNotDisabledException | TableNotFoundException e) { // The state we wanted it to be in // Or, in case table is not found, nothing to do } }
@Override public void prepare(boolean reload) throws IOException { if (Thread.interrupted()) { throw new InterruptedIOException(); } if (reload || location == null) { location = getLocation(!reload); } if (location == null) { // With this exception, there will be a retry. throw new HBaseIOException(getExceptionMessage()); } this.setStub(connection.getAdmin(location.getServerName())); }
private RollWALWriterResponse rollWALWriterImpl(final ServerName sn) throws IOException, FailedLogCloseException { final AdminService.BlockingInterface admin = this.connection.getAdmin(sn); RollWALWriterRequest request = RequestConverter.buildRollWALWriterRequest(); // TODO: There is no timeout on this controller. Set one! HBaseRpcController controller = rpcControllerFactory.newController(); try { return admin.rollWALWriter(controller, request); } catch (ServiceException e) { throw ProtobufUtil.handleRemoteException(e); } }
/** * Get region info from local cluster. */ Map<ServerName, List<String>> getDeployedHRIs(final Admin admin) throws IOException { ClusterMetrics status = admin.getClusterMetrics(EnumSet.of(Option.LIVE_SERVERS)); Collection<ServerName> regionServers = status.getLiveServerMetrics().keySet(); Map<ServerName, List<String>> mm = new HashMap<>(); for (ServerName hsi : regionServers) { AdminProtos.AdminService.BlockingInterface server = connection.getAdmin(hsi); // list all online regions from this region server List<RegionInfo> regions = ProtobufUtil.getOnlineRegions(server); List<String> regionNames = new ArrayList<>(regions.size()); for (RegionInfo hri : regions) { regionNames.add(hri.getRegionNameAsString()); } mm.put(hsi, regionNames); } return mm; }
@Override public void flushRegion(final byte[] regionName) throws IOException { Pair<RegionInfo, ServerName> regionServerPair = getRegion(regionName); if (regionServerPair == null) { throw new IllegalArgumentException("Unknown regionname: " + Bytes.toStringBinary(regionName)); } if (regionServerPair.getSecond() == null) { throw new NoServerForRegionException(Bytes.toStringBinary(regionName)); } final RegionInfo regionInfo = regionServerPair.getFirst(); ServerName serverName = regionServerPair.getSecond(); flush(this.connection.getAdmin(serverName), regionInfo); }
private CacheEvictionStats clearBlockCache(final ServerName sn, final List<RegionInfo> hris) throws IOException { HBaseRpcController controller = rpcControllerFactory.newController(); AdminService.BlockingInterface admin = this.connection.getAdmin(sn); ClearRegionBlockCacheRequest request = RequestConverter.buildClearRegionBlockCacheRequest(hris); ClearRegionBlockCacheResponse response; try { response = admin.clearRegionBlockCache(controller, request); return ProtobufUtil.toCacheEvictionStats(response.getStats()); } catch (ServiceException se) { throw ProtobufUtil.getRemoteException(se); } }
@Override protected Void rpcCall() throws Exception { LOG.debug("compacting " + getLocation() + " for row " + Bytes.toStringBinary(getRow())); AdminProtos.AdminService.BlockingInterface server = conn.getAdmin(getLocation().getServerName()); CompactRegionRequest request = RequestConverter.buildCompactRegionRequest( getLocation().getRegionInfo().getRegionName(), true, null); server.compactRegion(null, request); numCompactions.incrementAndGet(); return null; } };
@Override protected Void rpcCall() throws Exception { LOG.debug("compacting " + getLocation() + " for row " + Bytes.toStringBinary(getRow())); AdminProtos.AdminService.BlockingInterface server = conn.getAdmin(getLocation().getServerName()); CompactRegionRequest request = RequestConverter.buildCompactRegionRequest( getLocation().getRegionInfo().getRegionName(), true, null); server.compactRegion(null, request); numCompactions.incrementAndGet(); return null; } };
@Override protected Void rpcCall() throws Exception { LOG.debug("compacting " + getLocation() + " for row " + Bytes.toStringBinary(getRow())); AdminProtos.AdminService.BlockingInterface server = conn.getAdmin(getLocation().getServerName()); CompactRegionRequest request = RequestConverter.buildCompactRegionRequest( getLocation().getRegionInfo().getRegionName(), true, null); server.compactRegion(null, request); numCompactions.incrementAndGet(); return null; } };
private void performMultiplePutAndFlush(HBaseAdmin admin, Table table, byte[] row, byte[] family, int nFlushes, int nPuts) throws Exception { try (RegionLocator locator = TEST_UTIL.getConnection().getRegionLocator(table.getName())) { // connection needed for poll-wait HRegionLocation loc = locator.getRegionLocation(row, true); AdminProtos.AdminService.BlockingInterface server = ((ClusterConnection) admin.getConnection()).getAdmin(loc.getServerName()); byte[] regName = loc.getRegionInfo().getRegionName(); for (int i = 0; i < nFlushes; i++) { randomCFPuts(table, row, family, nPuts); List<String> sf = ProtobufUtil.getStoreFiles(server, regName, FAMILY); int sfCount = sf.size(); admin.flush(table.getName()); } } }