private boolean isMetaRegion(final RegionInfo regionInfo) { return regionInfo.isMetaRegion(); }
private void addRegion(final LinkedList<RegionInfo> regions, RegionInfo hri) { // If meta, move it last otherwise other unassigns fail because meta is not // online for them to update state in. This is dodgy. Needs to be made more // robust. See TODO below. if (hri.isMetaRegion()) { regions.addLast(hri); } else { regions.addFirst(hri); } }
@Override public CellComparator getCellComparator() { return this.getRegionInfo().isMetaRegion() ? CellComparatorImpl.META_COMPARATOR : CellComparatorImpl.COMPARATOR; }
private boolean isDefaultMetaRegion(RegionInfo hri) { return hri.isMetaRegion() && RegionReplicaUtil.isDefaultReplica(hri); }
private boolean areAllUserRegionsOffline() { if (getNumberOfOnlineRegions() > 2) return false; boolean allUserRegionsOffline = true; for (Map.Entry<String, HRegion> e: this.onlineRegions.entrySet()) { if (!e.getValue().getRegionInfo().isMetaRegion()) { allUserRegionsOffline = false; break; } } return allUserRegionsOffline; }
private List<RegionInfo> filterRegions(List<RegionInfo> regions) { List<RegionInfo> ret = Lists.newArrayList(); for (RegionInfo hri : regions) { if (hri.isMetaRegion() || (!hbck.checkMetaOnly && hbck.isTableIncluded(hri.getTable()))) { ret.add(hri); } } return ret; } }
void updateCachedLocationOnError(HRegionLocation loc, Throwable exception) { if (loc.getRegion().isMetaRegion()) { metaRegionLocator.updateCachedLocationOnError(loc, exception); } else { nonMetaRegionLocator.updateCachedLocationOnError(loc, exception); } }
public static UnassignRegionHandler create(RegionServerServices server, String encodedName, boolean abort, @Nullable ServerName destination) { // Just try our best to determine whether it is for closing meta. It is not the end of the world // if we put the handler into a wrong executor. Region region = server.getRegion(encodedName); EventType eventType = region != null && region.getRegionInfo().isMetaRegion() ? EventType.M_RS_CLOSE_META : EventType.M_RS_CLOSE_REGION; return new UnassignRegionHandler(server, encodedName, abort, destination, eventType); } }
/** * @param region the region which we want to get a WAL for it. Could be null. */ public WAL getWAL(RegionInfo region) throws IOException { // use different WAL for hbase:meta if (region != null && region.isMetaRegion() && region.getReplicaId() == RegionInfo.DEFAULT_REPLICA_ID) { return getMetaProvider().getWAL(region); } else { return provider.getWAL(region); } }
@Override public void prePut(ObserverContext<RegionCoprocessorEnvironment> c, Put put, WALEdit edit, Durability durability) throws IOException { if (FAIL && c.getEnvironment().getRegionInfo().isMetaRegion()) { throw new IOException("Inject error"); } } }
public static AssignRegionHandler create(RegionServerServices server, RegionInfo regionInfo, TableDescriptor tableDesc, long masterSystemTime) { EventType eventType; if (regionInfo.isMetaRegion()) { eventType = EventType.M_RS_CLOSE_META; } else if (regionInfo.getTable().isSystemTable() || (tableDesc != null && tableDesc.getPriority() >= HConstants.ADMIN_QOS)) { eventType = EventType.M_RS_OPEN_PRIORITY_REGION; } else { eventType = EventType.M_RS_OPEN_REGION; } return new AssignRegionHandler(server, regionInfo, tableDesc, masterSystemTime, eventType); } }
@Override public void preGetOp(ObserverContext<RegionCoprocessorEnvironment> c, Get get, List<Cell> result) throws IOException { if (FAIL && c.getEnvironment().getRegionInfo().isMetaRegion()) { throw new IOException("Inject error"); } }
@Override public boolean postScannerNext(ObserverContext<RegionCoprocessorEnvironment> c, InternalScanner s, List<Result> result, int limit, boolean hasNext) throws IOException { if (c.getEnvironment().getRegionInfo().isMetaRegion()) { CONCURRENCY.decrementAndGet(); } return hasNext; } }
@Test public void testMetaTables() { assertTrue(RegionInfoBuilder.FIRST_META_REGIONINFO.isMetaRegion()); }
@Override public ReportRegionStateTransitionResponse reportRegionStateTransition( ReportRegionStateTransitionRequest req) throws PleaseHoldException { if (ARRIVE_REPORT != null && req.getTransitionList().stream() .allMatch(t -> !ProtobufUtil.toRegionInfo(t.getRegionInfo(0)).isMetaRegion())) { ARRIVE_REPORT.countDown(); try { RESUME_REPORT.await(); } catch (InterruptedException e) { } } return super.reportRegionStateTransition(req); } }
public Result getClosestRowBefore(Region r, byte[] row, byte[] family) throws IOException { Scan scan = new Scan(row); scan.setSmall(true); scan.setCaching(1); scan.setReversed(true); scan.addFamily(family); try (RegionScanner scanner = r.getScanner(scan)) { List<Cell> cells = new ArrayList<>(1); scanner.next(cells); if (r.getRegionInfo().isMetaRegion() && !isTargetTable(row, cells.get(0))) { return null; } return Result.create(cells); } }
@Override public void prePut(ObserverContext<RegionCoprocessorEnvironment> e, Put put, WALEdit edit, Durability durability) throws IOException { Region region = e.getEnvironment().getRegion(); if (!region.getRegionInfo().isMetaRegion() && !region.getRegionInfo().getTable().isSystemTable()) { // The put carries the TTL attribute if (put.getTTL() != Long.MAX_VALUE) { return; } throw new IOException("Operation does not have TTL set"); } } }
public void updateRegionLocation(RegionStateNode regionStateNode) throws IOException { if (regionStateNode.getRegionInfo().isMetaRegion()) { updateMetaLocation(regionStateNode.getRegionInfo(), regionStateNode.getRegionLocation(), regionStateNode.getState()); } else { long openSeqNum = regionStateNode.getState() == State.OPEN ? regionStateNode.getOpenSeqNum() : HConstants.NO_SEQNUM; updateUserRegionLocation(regionStateNode.getRegionInfo(), regionStateNode.getState(), regionStateNode.getRegionLocation(), openSeqNum, // The regionStateNode may have no procedure in a test scenario; allow for this. regionStateNode.getProcedure() != null ? regionStateNode.getProcedure().getProcId() : Procedure.NO_PROC_ID); } }
@Override public void prePut(ObserverContext<RegionCoprocessorEnvironment> e, Put put, WALEdit edit, Durability durability) throws IOException { Region region = e.getEnvironment().getRegion(); if (!region.getRegionInfo().isMetaRegion() && !region.getRegionInfo().getTable().isSystemTable()) { if (put.getAttribute(TEST_ATR_KEY) != null) { LOG.debug("allow any put to happen " + region.getRegionInfo().getRegionNameAsString()); } else { e.bypass(); } } } }
@Override public void preGetOp(final ObserverContext<RegionCoprocessorEnvironment> e, final Get get, final List<Cell> results) throws IOException { int replicaId = e.getEnvironment().getRegion().getRegionInfo().getReplicaId(); // Fail for the primary replica, but not for meta if (throwException) { if (!e.getEnvironment().getRegion().getRegionInfo().isMetaRegion() && (replicaId == 0)) { LOG.info("Get, throw Region Server Stopped Exceptoin for region " + e.getEnvironment() .getRegion().getRegionInfo()); throw new RegionServerStoppedException("Server " + e.getEnvironment().getServerName() + " not running"); } } else { LOG.info("Get, We're replica region " + replicaId); } }