if (table != null && state != null && !table.equals("null") && !state.equals("null")) { rit = rit.stream().filter(regionStateNode -> regionStateNode.getTable().getNameAsString().equals(table)) .filter(regionStateNode -> regionStateNode.getState().name().equals(state)) .collect(Collectors.toList());
.setServer(ProtobufUtil.toServerName(serverName)) .setRpcVersion(HConstants.RPC_CURRENT_VERSION) .setState(state.convert()).build(); byte[] data = ProtobufUtil.prependPBMagic(pbrsr.toByteArray()); try {
/** * Don't count timestamp in hash code calculation */ @Override public int hashCode() { return (serverName != null ? serverName.hashCode() * 11 : 0) + hri.hashCode() + 5 * state.ordinal(); } }
if (replicaId == 0 && state.equals(State.SPLIT)) { for (HRegionLocation h : locations) { replicasToClose.add(h.getRegionInfo());
Bytes.toBytes(state.name())); LOG.info(info);
(data, prefixLen, data.length - prefixLen); if (rl.hasState()) { state = RegionState.State.convert(rl.getState());
data.length - prefixLen); if (rl.hasState()) { state = RegionState.State.convert(rl.getState());
.setServer(ProtobufUtil.toServerName(serverName)) .setRpcVersion(HConstants.RPC_CURRENT_VERSION) .setState(state.convert()).build(); byte[] data = ProtobufUtil.prependPBMagic(pbrsr.toByteArray()); try {
.setServer(ProtobufUtil.toServerName(serverName)) .setRpcVersion(HConstants.RPC_CURRENT_VERSION) .setState(state.convert()).build(); byte[] data = ProtobufUtil.prependPBMagic(pbrsr.toByteArray()); try {
/** * Gets current state of all regions of the table. * This method looks at the in-memory state. It does not go to <code>hbase:meta</code>. * Method guaranteed to return keys for all states * in {@link org.apache.hadoop.hbase.master.RegionState.State} * * @param tableName * @return Online regions from <code>tableName</code> */ public synchronized Map<RegionState.State, List<HRegionInfo>> getRegionByStateOfTable(TableName tableName) { Map<RegionState.State, List<HRegionInfo>> tableRegions = new HashMap<State, List<HRegionInfo>>(); for (State state : State.values()) { tableRegions.put(state, new ArrayList<HRegionInfo>()); } Map<String, RegionState> indexMap = regionStatesTableIndex.get(tableName); if (indexMap == null) return tableRegions; for (RegionState regionState : indexMap.values()) { tableRegions.get(regionState.getState()).add(regionState.getRegion()); } return tableRegions; }
/** * Test normal operations */ @Test public void testMetaLookup() throws IOException, InterruptedException, ServiceException, KeeperException { final ClientProtos.ClientService.BlockingInterface client = Mockito.mock(ClientProtos.ClientService.BlockingInterface.class); Mockito.when(client.get((RpcController)Mockito.any(), (GetRequest)Mockito.any())). thenReturn(GetResponse.newBuilder().build()); final MetaTableLocator mtl = new MetaTableLocator(); assertNull(mtl.getMetaRegionLocation(this.watcher)); for (RegionState.State state : RegionState.State.values()) { if (state.equals(RegionState.State.OPEN)) continue; MetaTableLocator.setMetaLocation(this.watcher, SN, state); assertNull(mtl.getMetaRegionLocation(this.watcher)); assertEquals(state, MetaTableLocator.getMetaRegionState(this.watcher).getState()); } MetaTableLocator.setMetaLocation(this.watcher, SN, RegionState.State.OPEN); assertEquals(SN, mtl.getMetaRegionLocation(this.watcher)); assertEquals(RegionState.State.OPEN, MetaTableLocator.getMetaRegionState(this.watcher).getState()); mtl.deleteMetaLocation(this.watcher); assertNull(MetaTableLocator.getMetaRegionState(this.watcher).getServerName()); assertEquals(RegionState.State.OFFLINE, MetaTableLocator.getMetaRegionState(this.watcher).getState()); assertNull(mtl.getMetaRegionLocation(this.watcher)); }
private void addStateAndBarrier(RegionInfo region, RegionState.State state, long... barriers) throws IOException { Put put = new Put(region.getRegionName(), EnvironmentEdgeManager.currentTime()); if (state != null) { put.addColumn(HConstants.CATALOG_FAMILY, HConstants.STATE_QUALIFIER, Bytes.toBytes(state.name())); } 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 void addStateAndBarrier(RegionInfo region, RegionState.State state, long... barriers) throws IOException { Put put = new Put(region.getRegionName(), EnvironmentEdgeManager.currentTime()); if (state != null) { put.addColumn(HConstants.CATALOG_FAMILY, HConstants.STATE_QUALIFIER, Bytes.toBytes(state.name())); } 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); } }
/** * Don't count timestamp in hash code calculation */ @Override public int hashCode() { return (serverName != null ? serverName.hashCode() * 11 : 0) + hri.hashCode() + 5 * state.ordinal(); } }
/** * Pull the region state from a catalog table {@link Result}. * @param r Result to pull the region state from * @return the region state, or OPEN if there's no value written. */ static State getRegionState(final Result r, int replicaId) { Cell cell = r.getColumnLatestCell(HConstants.CATALOG_FAMILY, getStateColumn(replicaId)); if (cell == null || cell.getValueLength() == 0) return State.OPEN; return State.valueOf(Bytes.toString(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength())); }
/** * Don't count timestamp in hash code calculation */ @Override public int hashCode() { return (serverName != null ? serverName.hashCode() * 11 : 0) + hri.hashCode() + 5 * state.ordinal(); } }
/** * Convert a protobuf HBaseProtos.RegionState to a RegionState * * @return the RegionState */ public static RegionState convert(ClusterStatusProtos.RegionState proto) { return new RegionState(ProtobufUtil.toRegionInfo(proto.getRegionInfo()), State.convert(proto.getState()), proto.getStamp(), null); }
/** * Convert a protobuf HBaseProtos.RegionState to a RegionState * * @return the RegionState */ public static RegionState convert(ClusterStatusProtos.RegionState proto) { return new RegionState(HRegionInfo.convert(proto.getRegionInfo()), State.convert(proto.getState()), proto.getStamp(), null); }
/** * Convert a RegionState to an HBaseProtos.RegionState * * @return the converted HBaseProtos.RegionState */ public ClusterStatusProtos.RegionState convert() { ClusterStatusProtos.RegionState.Builder regionState = ClusterStatusProtos.RegionState.newBuilder(); regionState.setRegionInfo(HRegionInfo.convert(hri)); regionState.setState(state.convert()); regionState.setStamp(getStamp()); return regionState.build(); }