@Override public MoveRegionResponse moveRegion(RpcController controller, MoveRegionRequest req) throws ServiceException { final byte [] encodedRegionName = req.getRegion().getValue().toByteArray(); RegionSpecifierType type = req.getRegion().getType(); final byte [] destServerName = (req.hasDestServerName())? Bytes.toBytes(ProtobufUtil.toServerName(req.getDestServerName()).getServerName()):null; MoveRegionResponse mrr = MoveRegionResponse.newBuilder().build(); if (type != RegionSpecifierType.ENCODED_REGION_NAME) { LOG.warn("moveRegion specifier type: expected: " + RegionSpecifierType.ENCODED_REGION_NAME + " actual: " + type); } try { master.checkInitialized(); master.move(encodedRegionName, destServerName); } catch (IOException ioe) { throw new ServiceException(ioe); } return mrr; }
try { final byte [] regionName = req.getRegion().getValue().toByteArray(); RegionSpecifierType type = req.getRegion().getType(); final boolean force = req.getForce(); UnassignRegionResponse urr = UnassignRegionResponse.newBuilder().build();
@Override public AssignRegionResponse assignRegion(RpcController controller, AssignRegionRequest req) throws ServiceException { try { master.checkInitialized(); final RegionSpecifierType type = req.getRegion().getType(); if (type != RegionSpecifierType.REGION_NAME) { LOG.warn("assignRegion specifier type: expected: " + RegionSpecifierType.REGION_NAME + " actual: " + type); } final byte[] regionName = req.getRegion().getValue().toByteArray(); final RegionInfo regionInfo = master.getAssignmentManager().getRegionInfo(regionName); if (regionInfo == null) throw new UnknownRegionException(Bytes.toStringBinary(regionName)); final AssignRegionResponse arr = AssignRegionResponse.newBuilder().build(); if (master.cpHost != null) { master.cpHost.preAssign(regionInfo); } LOG.info(master.getClientIdAuditPrefix() + " assign " + regionInfo.getRegionNameAsString()); master.getAssignmentManager().assign(regionInfo); if (master.cpHost != null) { master.cpHost.postAssign(regionInfo); } return arr; } catch (IOException ioe) { throw new ServiceException(ioe); } }
HBaseProtos.RegionSpecifier rs = actions.getRegion(); if (rs.hasType() && (rs.getType() != HBaseProtos.RegionSpecifier.RegionSpecifierType.REGION_NAME)){ throw new IllegalArgumentException( "We support only encoded types for protobuf multi response.");
/** * Find the HRegion encoded name based on a region specifier * * @param regionSpecifier the region specifier * @return the corresponding region's encoded name * @throws DoNotRetryIOException if the specifier type is unsupported */ public static String getRegionEncodedName( final RegionSpecifier regionSpecifier) throws DoNotRetryIOException { ByteString value = regionSpecifier.getValue(); RegionSpecifierType type = regionSpecifier.getType(); switch (type) { case REGION_NAME: return org.apache.hadoop.hbase.client.RegionInfo.encodeRegionName(value.toByteArray()); case ENCODED_REGION_NAME: return value.toStringUtf8(); default: throw new DoNotRetryIOException( "Unsupported region specifier type: " + type); } }
public Builder mergeFrom(org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.RegionSpecifier other) { if (other == org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.RegionSpecifier.getDefaultInstance()) return this; if (other.hasType()) { setType(other.getType()); } if (other.hasValue()) { setValue(other.getValue()); } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; }
HBaseProtos.RegionSpecifier rs = actions.getRegion(); if (rs.hasType() && (rs.getType() != HBaseProtos.RegionSpecifier.RegionSpecifierType.REGION_NAME)){ throw new IllegalArgumentException( "We support only encoded types for protobuf multi response.");
/** * Find the HRegion encoded name based on a region specifier * * @param regionSpecifier the region specifier * @return the corresponding region's encoded name * @throws DoNotRetryIOException if the specifier type is unsupported */ public static String getRegionEncodedName( final RegionSpecifier regionSpecifier) throws DoNotRetryIOException { ByteString value = regionSpecifier.getValue(); RegionSpecifierType type = regionSpecifier.getType(); switch (type) { case REGION_NAME: return org.apache.hadoop.hbase.client.RegionInfo.encodeRegionName(value.toByteArray()); case ENCODED_REGION_NAME: return value.toStringUtf8(); default: throw new DoNotRetryIOException( "Unsupported region specifier type: " + type); } }
@Override public GetResponse get(RpcController controller, GetRequest request) throws ServiceException { boolean metaRegion = isMetaRegion(request.getRegion().getValue().toByteArray(), request.getRegion().getType()); if (!metaRegion) { return doGetResponse(request); } return doMetaGetResponse(meta, request); }
HBaseProtos.RegionSpecifier rs = actions.getRegion(); if (rs.hasType() && (rs.getType() != HBaseProtos.RegionSpecifier.RegionSpecifierType.REGION_NAME)){ throw new IllegalArgumentException( "We support only encoded types for protobuf multi response.");
for (int i = 0; i < request.getRegionCount(); i++) { final byte[] encodedNameOfRegion = request.getRegion(i).getValue().toByteArray(); if (request.getRegion(i).getType() != RegionSpecifierType.ENCODED_REGION_NAME) { LOG.warn("MergeRegions specifier type: expected: " + RegionSpecifierType.ENCODED_REGION_NAME + " actual: region " + i + " =" + request.getRegion(i).getType());
master.checkInitialized(); final RegionSpecifierType type = request.getRegion().getType(); if (type != RegionSpecifierType.REGION_NAME) { LOG.warn("moveRegion specifier type: expected: " + RegionSpecifierType.REGION_NAME
/** * Get RegionInfo from Master using content of RegionSpecifier as key. * @return RegionInfo found by decoding <code>rs</code> or null if none found */ private RegionInfo getRegionInfo(HBaseProtos.RegionSpecifier rs) throws UnknownRegionException { RegionInfo ri = null; switch(rs.getType()) { case REGION_NAME: final byte[] regionName = rs.getValue().toByteArray(); ri = this.master.getAssignmentManager().getRegionInfo(regionName); break; case ENCODED_REGION_NAME: String encodedRegionName = Bytes.toString(rs.getValue().toByteArray()); RegionState regionState = this.master.getAssignmentManager().getRegionStates(). getRegionState(encodedRegionName); ri = regionState == null? null: regionState.getRegion(); break; default: break; } return ri; }
/** * Find the HRegion encoded name based on a region specifier * * @param regionSpecifier the region specifier * @return the corresponding region's encoded name * @throws DoNotRetryIOException if the specifier type is unsupported */ public static String getRegionEncodedName( final RegionSpecifier regionSpecifier) throws DoNotRetryIOException { ByteString value = regionSpecifier.getValue(); RegionSpecifierType type = regionSpecifier.getType(); switch (type) { case REGION_NAME: return org.apache.hadoop.hbase.client.RegionInfo.encodeRegionName(value.toByteArray()); case ENCODED_REGION_NAME: return value.toStringUtf8(); default: throw new DoNotRetryIOException( "Unsupported region specifier type: " + type); } }
@Override public GetResponse get(RpcController controller, GetRequest request) throws ServiceException { boolean metaRegion = isMetaRegion(request.getRegion().getValue().toByteArray(), request.getRegion().getType()); if (!metaRegion) { return doGetResponse(request); } return doMetaGetResponse(meta, request); }
public Builder mergeFrom(org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.RegionSpecifier other) { if (other == org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.RegionSpecifier.getDefaultInstance()) return this; if (other.hasType()) { setType(other.getType()); } if (other.hasValue()) { setValue(other.getValue()); } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; }