protected void checkReadsEnabled() throws IOException { if (!this.writestate.readsEnabled) { throw new IOException(getRegionInfo().getEncodedName() + ": The region's reads are disabled. Cannot serve the request"); } }
@Override public String getRegionName() { RegionInfo regionInfo = this.region.getRegionInfo(); if (regionInfo == null) { return UNKNOWN; } return regionInfo.getEncodedName(); }
/** * Get the replica id of this region. */ @Override public int getReplicaId() { return region.getRegionInfo().getReplicaId(); }
/** * Returns whether to replay the recovered edits to flush the results. * Currently secondary region replicas do not replay the edits, since it would * cause flushes which might affect the primary region. Primary regions even opened * in read only mode should replay the edits. * @param region the HRegion object * @return whether recovered edits should be replayed. */ public static boolean shouldReplayRecoveredEdits(HRegion region) { return isDefaultReplica(region.getRegionInfo()); }
private void logRegionFiles() { if (LOG.isTraceEnabled()) { LOG.trace(getRegionInfo().getEncodedName() + " : Store files for region: "); stores.values().stream().filter(s -> s.getStorefiles() != null) .flatMap(s -> s.getStorefiles().stream()) .forEachOrdered(sf -> LOG.trace(getRegionInfo().getEncodedName() + " : " + sf)); } }
@Override public boolean equals(Object o) { return o instanceof HRegion && Bytes.equals(getRegionInfo().getRegionName(), ((HRegion) o).getRegionInfo().getRegionName()); }
@Override public void fillRegion(final HRegion region) throws IOException { RegionInfo snapshotHri = snapshotRegions.get(region.getRegionInfo().getEncodedName()); cloneRegion(region, snapshotHri, regionManifests.get(snapshotHri.getEncodedName())); } });
@Override public void addRegion(HRegion region) { this.onlineRegions.put(region.getRegionInfo().getEncodedName(), region); configurationManager.registerObserver(region); }
/** Make sure this is a valid row for the HRegion */ void checkRow(byte[] row, String op) throws IOException { if (!rowIsInRange(getRegionInfo(), row)) { throw new WrongRegionException("Requested row out of range for " + op + " on HRegion " + this + ", startKey='" + Bytes.toStringBinary(getRegionInfo().getStartKey()) + "', getEndKey()='" + Bytes.toStringBinary(getRegionInfo().getEndKey()) + "', row='" + Bytes.toStringBinary(row) + "'"); } }
private void rejectIfInStandByState(HRegion region) throws DoNotRetryIOException { if (shouldRejectRequestsFromClient(region)) { throw new DoNotRetryIOException( region.getRegionInfo().getRegionNameAsString() + " is in STANDBY state."); } }
/** * Returns whether this region replica can accept writes. * @param region the HRegion object * @return whether the replica is read only */ public static boolean isReadOnly(HRegion region) { return region.getTableDescriptor().isReadOnly() || !isDefaultReplica(region.getRegionInfo()); }
@VisibleForTesting protected void writeRegionOpenMarker(WAL wal, long openSeqId) throws IOException { Map<byte[], List<Path>> storeFiles = getStoreFiles(); RegionEventDescriptor regionOpenDesc = ProtobufUtil.toRegionEventDescriptor( RegionEventDescriptor.EventType.REGION_OPEN, getRegionInfo(), openSeqId, getRegionServerServices().getServerName(), storeFiles); WALUtil.writeRegionEventMarker(wal, getReplicationScope(), getRegionInfo(), regionOpenDesc, mvcc); }
@Before public void setupMocks() { conf = HBaseConfiguration.create(); HRegionInfo hri = new HRegionInfo(TABLENAME); htd = new HTableDescriptor(TABLENAME); mockRegion = Mockito.mock(HRegion.class); Mockito.doReturn(htd).when(mockRegion).getTableDescriptor(); Mockito.doReturn(hri).when(mockRegion).getRegionInfo(); stores = new ArrayList<>(); Mockito.doReturn(stores).when(mockRegion).getStores(); }
private HRegion findSplittableRegion(final List<HRegion> regions) throws InterruptedException { for (int i = 0; i < 5; ++i) { for (HRegion r: regions) { if (r.isSplittable() && r.getRegionInfo().getReplicaId() == 0) { return(r); } } Thread.sleep(100); } return(null); }
@Override public void accept(HRegion hRegion) { if (hRegion.getRegionInfo().containsRow(key3)) { Threads.shutdown(ealierBulkload);/// wait util the other bulkload finished } } } ;
private boolean shouldForbidMajorCompaction() { if (rsServices != null && rsServices.getReplicationSourceService() != null) { return rsServices.getReplicationSourceService().getSyncReplicationPeerInfoProvider() .checkState(getRegionInfo().getTable(), ForbidMajorCompactionChecker.get()); } return false; }
@Test public void testAsyncFlushRegion() throws Exception { AsyncAdmin admin = asyncConn.getAdmin(); for (HRegion r : getRegionInfo()) { admin.flushRegion(r.getRegionInfo().getRegionName()).get(); TimeUnit.SECONDS.sleep(1); assertEquals(0, r.getMemStoreDataSize()); } }
@Test public void testFlushRegionEntryEquality() { RegionInfo hri = RegionInfoBuilder.newBuilder(TableName.valueOf(name.getMethodName())) .setRegionId(1).setReplicaId(0).build(); HRegion r = mock(HRegion.class); doReturn(hri).when(r).getRegionInfo(); FlushRegionEntry entry = new FlushRegionEntry(r, true, FlushLifeCycleTracker.DUMMY); FlushRegionEntry other = new FlushRegionEntry(r, true, FlushLifeCycleTracker.DUMMY); assertEquals(entry.hashCode(), other.hashCode()); assertEquals(entry, other); } }
@Test public void testFlushRegion() throws Exception { try (Admin admin = TEST_UTIL.getAdmin()) { for (HRegion r : getRegionInfo()) { admin.flushRegion(r.getRegionInfo().getRegionName()); TimeUnit.SECONDS.sleep(1); assertEquals(0, r.getMemStoreDataSize()); } } }
@Test public void testRemovePeerNothingReplicated() throws Exception { TableName tableName = createTable(); String encodedRegionName = UTIL.getMiniHBaseCluster().getRegions(tableName).get(0).getRegionInfo().getEncodedName(); ReplicationQueueStorage queueStorage = UTIL.getMiniHBaseCluster().getMaster().getReplicationPeerManager().getQueueStorage(); assertEquals(HConstants.NO_SEQNUM, queueStorage.getLastSequenceId(encodedRegionName, PEER_ID)); UTIL.getAdmin().removeReplicationPeer(PEER_ID); assertEquals(HConstants.NO_SEQNUM, queueStorage.getLastSequenceId(encodedRegionName, PEER_ID)); }