@Override public boolean equals(Object o) { return o instanceof HRegion && Bytes.equals(getRegionInfo().getRegionName(), ((HRegion) o).getRegionInfo().getRegionName()); }
private void checkRegionsAndRegionLoads(Collection<RegionInfo> regions, Collection<RegionMetrics> regionLoads) { assertEquals("No of regions and regionloads doesn't match", regions.size(), regionLoads.size()); Map<byte[], RegionMetrics> regionLoadMap = Maps.newTreeMap(Bytes.BYTES_COMPARATOR); for (RegionMetrics regionLoad : regionLoads) { regionLoadMap.put(regionLoad.getRegionName(), regionLoad); } for (RegionInfo info : regions) { assertTrue("Region not in regionLoadMap region:" + info.getRegionNameAsString() + " regionMap: " + regionLoadMap, regionLoadMap.containsKey(info.getRegionName())); } }
public void addFailures(RegionInfo... hris) { for (RegionInfo hri : hris) { failures.add(hri.getRegionName()); } }
private void split(final RegionInfo hri, final HRegionServer server, final int regionCount) throws IOException, InterruptedException { admin.splitRegionAsync(hri.getRegionName(), null); for (int i = 0; cluster.getRegions(hri.getTable()).size() <= regionCount && i < 60; i++) { LOG.debug("Waiting on region " + hri.getRegionNameAsString() + " to split"); Thread.sleep(2000); } assertFalse("Waited too long for split", cluster.getRegions(hri.getTable()).size() <= regionCount); }
/** * Gets whether the current region name follows the pattern of a mob region name. * @param tableName The current table name. * @param regionName The current region name. * @return True if the current region name follows the pattern of a mob region name. */ public static boolean isMobRegionName(TableName tableName, byte[] regionName) { return Bytes.equals(regionName, getMobRegionInfo(tableName).getRegionName()); }
public RegionInfo getMetaRegionFromName(final byte[] regionName) { for (RegionInfo hri: getMetaRegionSet()) { if (Bytes.equals(hri.getRegionName(), regionName)) { return hri; } } return null; }
public FlushRegionCallable(ClusterConnection connection, RpcControllerFactory rpcControllerFactory, RegionInfo regionInfo, boolean writeFlushWalMarker) { this(connection, rpcControllerFactory, regionInfo.getTable(), regionInfo.getRegionName(), regionInfo.getStartKey(), writeFlushWalMarker); }
public void addAction(HRegionLocation loc, Action action) { computeIfAbsent(actionsByRegion, loc.getRegion().getRegionName(), () -> new RegionRequest(loc)).actions.add(action); } }
private static boolean isMetaRegion(final byte[] regionName) { return Bytes.equals(regionName, RegionInfoBuilder.FIRST_META_REGIONINFO.getRegionName()) || Bytes.equals(regionName, RegionInfoBuilder.FIRST_META_REGIONINFO.getEncodedNameAsBytes()); } }
@VisibleForTesting RegionStateNode createRegionStateNode(RegionInfo regionInfo) { RegionStateNode newNode = new RegionStateNode(regionInfo, regionInTransition); RegionStateNode oldNode = regionsMap.putIfAbsent(regionInfo.getRegionName(), newNode); return oldNode != null ? oldNode : newNode; }
public CloseRegionRequest buildCloseRegionRequest(final ServerName serverName) { return ProtobufUtil.buildCloseRegionRequest(serverName, getRegionInfo().getRegionName(), getDestinationServer()); } }
/** * Get the ServerName of region server serving the first hbase:meta region */ public ServerName getServerHoldingMeta() throws IOException { return getServerHoldingRegion(TableName.META_TABLE_NAME, RegionInfoBuilder.FIRST_META_REGIONINFO.getRegionName()); }
@Override public AdminProtos.GetRegionInfoResponse.CompactionState call() throws Exception { RegionInfo info = RegionInfo.createMobRegionInfo(tableName); GetRegionInfoRequest request = RequestConverter.buildGetRegionInfoRequest(info.getRegionName(), true); GetRegionInfoResponse response = masterAdmin.getRegionInfo(rpcController, request); return response.getCompactionState(); } };
public RegionFailedOpen addToFailedOpen(final RegionStateNode regionNode) { final byte[] key = regionNode.getRegionInfo().getRegionName(); RegionFailedOpen node = regionFailedOpen.get(key); if (node == null) { RegionFailedOpen newNode = new RegionFailedOpen(regionNode); RegionFailedOpen oldNode = regionFailedOpen.putIfAbsent(key, newNode); node = oldNode != null ? oldNode : newNode; } return node; }
private void fillCatalogFamily(RegionInfo region) throws IOException { try (Table table = UTIL.getConnection().getTable(TableName.META_TABLE_NAME)) { table.put(new Put(region.getRegionName()).addColumn(HConstants.CATALOG_FAMILY, Bytes.toBytes("whatever"), Bytes.toBytes("whatever"))); } }
private RegionInfoBuilder(RegionInfo regionInfo) { this.tableName = regionInfo.getTable(); this.startKey = regionInfo.getStartKey(); this.endKey = regionInfo.getEndKey(); this.offLine = regionInfo.isOffline(); this.split = regionInfo.isSplit(); this.regionId = regionInfo.getRegionId(); this.replicaId = regionInfo.getReplicaId(); this.regionName = regionInfo.getRegionName(); this.encodedName = regionInfo.getEncodedName(); }
private void addBarrier(RegionInfo region, long... barriers) throws IOException { Put put = new Put(region.getRegionName(), EnvironmentEdgeManager.currentTime()); for (int i = 0; i < barriers.length; i++) { put.addColumn(HConstants.REPLICATION_BARRIER_FAMILY, HConstants.SEQNUM_QUALIFIER, put.getTimestamp() - barriers.length + i, Bytes.toBytes(barriers[i])); } try (Table table = UTIL.getConnection().getTable(TableName.META_TABLE_NAME)) { table.put(put); } }
private BulkLoadHFileRequest ConvertSecureBulkLoadHFilesRequest( SecureBulkLoadHFilesRequest request) { BulkLoadHFileRequest.Builder bulkLoadHFileRequest = BulkLoadHFileRequest.newBuilder(); RegionSpecifier region = ProtobufUtil.buildRegionSpecifier(RegionSpecifierType.REGION_NAME, this.env .getRegionInfo().getRegionName()); bulkLoadHFileRequest.setRegion(region).setFsToken(request.getFsToken()) .setBulkToken(request.getBulkToken()).setAssignSeqNum(request.getAssignSeqNum()) .addAllFamilyPath(request.getFamilyPathList()); return bulkLoadHFileRequest.build(); }
@Override public Boolean rpcCall() throws Exception { SecureBulkLoadClient secureClient = null; byte[] regionName = getLocation().getRegion().getRegionName(); try (Table table = conn.getTable(getTableName())) { secureClient = new SecureBulkLoadClient(conf, table); return secureClient.secureBulkLoadHFiles(getStub(), famPaths, regionName, true, null, bulkToken); } } };
public static ServerName getServerHoldingRegion(final HBaseTestingUtility util, final RegionInfo hri) throws Exception { ServerName serverName = util.getMiniHBaseCluster().getServerHoldingRegion( hri.getTable(), hri.getRegionName()); ServerName amServerName = getMaster(util).getAssignmentManager().getRegionStates() .getRegionServerOfRegion(hri); // Make sure AM and MiniCluster agrees on the Server holding the region // and that the server is online. assertEquals(amServerName, serverName); assertEquals(true, getMaster(util).getServerManager().isServerOnline(serverName)); return serverName; }