下面列出了org.apache.hadoop.hbase.HConstants#PRIORITY_UNSET 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
public boolean dispatch(CallRunner callTask) throws InterruptedException {
RpcCall call = callTask.getRpcCall();
int level = priority.getPriority(call.getHeader(), call.getParam(),
call.getRequestUser().orElse(null));
if (level == HConstants.PRIORITY_UNSET) {
level = HConstants.NORMAL_QOS;
}
if (metaTransitionExecutor != null &&
level == MasterAnnotationReadingPriorityFunction.META_TRANSITION_QOS) {
return metaTransitionExecutor.dispatch(callTask);
} else if (priorityExecutor != null && level > highPriorityLevel) {
return priorityExecutor.dispatch(callTask);
} else if (replicationExecutor != null && level == HConstants.REPLICATION_QOS) {
return replicationExecutor.dispatch(callTask);
} else {
return callExecutor.dispatch(callTask);
}
}
static RequestHeader buildRequestHeader(Call call, CellBlockMeta cellBlockMeta) {
RequestHeader.Builder builder = RequestHeader.newBuilder();
builder.setCallId(call.id);
//TODO handle htrace API change, see HBASE-18895
/*if (call.span != null) {
builder.setTraceInfo(RPCTInfo.newBuilder().setParentId(call.span.getSpanId())
.setTraceId(call.span.getTracerId()));
}*/
builder.setMethodName(call.md.getName());
builder.setRequestParam(call.param != null);
if (cellBlockMeta != null) {
builder.setCellBlockMeta(cellBlockMeta);
}
// Only pass priority if there is one set.
if (call.priority != HConstants.PRIORITY_UNSET) {
builder.setPriority(call.priority);
}
builder.setTimeout(call.timeout);
return builder.build();
}
protected Message callExecService(RpcController controller, final Descriptors.MethodDescriptor method, final Message request, Message responsePrototype) throws IOException {
if(LOG.isTraceEnabled()) {
LOG.trace("Call: " + method.getName() + ", " + request.toString());
}
if(this.row == null) {
throw new NullPointerException("Can\'t be null!");
} else {
int priority = HConstants.PRIORITY_UNSET;
if (controller instanceof SpliceRpcController) {
priority = ((SpliceRpcController)controller).getPriority();
}
ClientServiceCallable callable = new ClientServiceCallable(this.conn, this.table, this.row, this.conn.getRpcControllerFactory().newController(), priority) {
protected ClientProtos.CoprocessorServiceResponse rpcCall() throws Exception {
byte[] regionName = this.getLocation().getRegionInfo().getRegionName();
ClientProtos.CoprocessorServiceRequest csr = CoprocessorRpcUtils.getCoprocessorServiceRequest(method, request, RegionCoprocessorRpcChannel.this.row, regionName);
return ((ClientProtos.ClientService.BlockingInterface)this.getStub()).execService(this.getRpcController(), csr);
}
};
ClientProtos.CoprocessorServiceResponse result = (ClientProtos.CoprocessorServiceResponse)this.rpcCallerFactory.newCaller().callWithRetries(callable, this.operationTimeout);
this.lastRegion = result.getRegion().getValue().toByteArray();
return CoprocessorRpcUtils.getResponse(result, responsePrototype);
}
}
public Action(Row action, int originalIndex) {
this(action, originalIndex, HConstants.PRIORITY_UNSET);
}
public int getPriority() {
Optional<Action> result = actions.values().stream().flatMap(List::stream)
.max((action1, action2) -> Math.max(action1.getPriority(), action2.getPriority()));
return result.isPresent() ? result.get().getPriority() : HConstants.PRIORITY_UNSET;
}
/**
* Select the priority for the rpc call.
* <p/>
* The rules are:
* <ol>
* <li>If user set a priority explicitly, then just use it.</li>
* <li>For system table, use {@link HConstants#SYSTEMTABLE_QOS}.</li>
* <li>For other tables, use {@link HConstants#NORMAL_QOS}.</li>
* </ol>
* @param priority the priority set by user, can be {@link HConstants#PRIORITY_UNSET}.
* @param tableName the table we operate on
*/
static int calcPriority(int priority, TableName tableName) {
if (priority != HConstants.PRIORITY_UNSET) {
return priority;
} else {
return getPriority(tableName);
}
}