public AssignmentManager(final MasterServices master) { this(master, new RegionStateStore(master)); }
public void deleteRegion(final RegionInfo regionInfo) throws IOException { deleteRegions(Collections.singletonList(regionInfo)); }
public void mergeRegions(RegionInfo child, RegionInfo hriA, RegionInfo hriB, ServerName serverName) throws IOException { TableDescriptor htd = getTableDescriptor(child.getTable()); long regionAOpenSeqNum = -1L; long regionBOpenSeqNum = -1L; if (htd.hasGlobalReplicationScope()) { regionAOpenSeqNum = getOpenSeqNumForParentRegion(hriA); regionBOpenSeqNum = getOpenSeqNumForParentRegion(hriB); } MetaTableAccessor.mergeRegions(master.getConnection(), child, hriA, regionAOpenSeqNum, hriB, regionBOpenSeqNum, serverName, getRegionReplication(htd)); }
private boolean hasGlobalReplicationScope(TableName tableName) throws IOException { return hasGlobalReplicationScope(getTableDescriptor(tableName)); }
hasGlobalReplicationScope(regionInfo.getTable())) { MetaTableAccessor.addReplicationBarrier(put, openSeqNum); info.append(", repBarrier=").append(openSeqNum); .setRow(put.getRow()) .setFamily(HConstants.CATALOG_FAMILY) .setQualifier(getServerNameColumn(replicaId)) .setTimestamp(put.getTimestamp()) .setType(Cell.Type.Put) .setRow(put.getRow()) .setFamily(HConstants.CATALOG_FAMILY) .setQualifier(getStateColumn(replicaId)) .setTimestamp(put.getTimestamp()) .setType(Cell.Type.Put) .build()); LOG.info(info.toString()); updateRegionLocation(regionInfo, state, put);
private void visitMetaEntry(final RegionStateVisitor visitor, final Result result) throws IOException { final RegionLocations rl = MetaTableAccessor.getRegionLocations(result); if (rl == null) return; final HRegionLocation[] locations = rl.getRegionLocations(); if (locations == null) return; for (int i = 0; i < locations.length; ++i) { final HRegionLocation hrl = locations[i]; if (hrl == null) continue; final RegionInfo regionInfo = hrl.getRegion(); if (regionInfo == null) continue; final int replicaId = regionInfo.getReplicaId(); final State state = getRegionState(result, replicaId); final ServerName lastHost = hrl.getServerName(); final ServerName regionLocation = getRegionServer(result, replicaId); final long openSeqNum = hrl.getSeqNum(); // TODO: move under trace, now is visible for debugging LOG.info( "Load hbase:meta entry region={}, regionState={}, lastHost={}, " + "regionLocation={}, openSeqNum={}", regionInfo.getEncodedName(), state, lastHost, regionLocation, openSeqNum); visitor.visitRegionState(result, regionInfo, state, regionLocation, lastHost, openSeqNum); } }
if (RegionStateStore.getRegionState(r, info.getReplicaId()) != RegionState.State.OPEN) { return false;
/** * Pull the region state from a catalog table {@link Result}. * @param r Result to pull the region state from * @return the region state, or null if unknown. */ @VisibleForTesting public static State getRegionState(final Result r, int replicaId) { Cell cell = r.getColumnLatestCell(HConstants.CATALOG_FAMILY, getStateColumn(replicaId)); if (cell == null || cell.getValueLength() == 0) { return null; } return State.valueOf(Bytes.toString(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength())); }
/** * Returns the {@link ServerName} from catalog table {@link Result} * where the region is transitioning. It should be the same as * {@link MetaTableAccessor#getServerName(Result,int)} if the server is at OPEN state. * @param r Result to pull the transitioning server name from * @return A ServerName instance or {@link MetaTableAccessor#getServerName(Result,int)} * if necessary fields not found or empty. */ static ServerName getRegionServer(final Result r, int replicaId) { final Cell cell = r.getColumnLatestCell(HConstants.CATALOG_FAMILY, getServerNameColumn(replicaId)); if (cell == null || cell.getValueLength() == 0) { RegionLocations locations = MetaTableAccessor.getRegionLocations(r); if (locations != null) { HRegionLocation location = locations.getRegionLocation(replicaId); if (location != null) { return location.getServerName(); } } return null; } return ServerName.parseServerName(Bytes.toString(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength())); }
if (RegionStateStore.getRegionState(r, info.getReplicaId()) != RegionState.State.OPEN) { return false;
public void splitRegion(RegionInfo parent, RegionInfo hriA, RegionInfo hriB, ServerName serverName) throws IOException { TableDescriptor htd = getTableDescriptor(parent.getTable()); long parentOpenSeqNum = HConstants.NO_SEQNUM; if (htd.hasGlobalReplicationScope()) { parentOpenSeqNum = getOpenSeqNumForParentRegion(parent); } MetaTableAccessor.splitRegion(master.getConnection(), parent, parentOpenSeqNum, hriA, hriB, serverName, getRegionReplication(htd)); }
/** * Delete the region states. This is called by "DeleteTable" */ public void deleteTable(final TableName tableName) throws IOException { final ArrayList<RegionInfo> regions = regionStates.getTableRegionsInfo(tableName); regionStateStore.deleteRegions(regions); for (int i = 0; i < regions.size(); ++i) { final RegionInfo regionInfo = regions.get(i); // we expect the region to be offline regionStates.removeFromOfflineRegions(regionInfo); regionStates.deleteRegion(regionInfo); } }