org.apache.hadoop.hbase.HConstants#HIGH_QOS源码实例Demo

下面列出了org.apache.hadoop.hbase.HConstants#HIGH_QOS 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: phoenix   文件: PhoenixIndexRpcSchedulerFactory.java
@Override
public RpcScheduler create(Configuration conf, PriorityFunction priorityFunction, Abortable abortable) {
    // create the delegate scheduler
    RpcScheduler delegate;
    try {
        // happens in <=0.98.4 where the scheduler factory is not visible
        delegate = new SimpleRpcSchedulerFactory().create(conf, priorityFunction, abortable);
    } catch (IllegalAccessError e) {
        LOG.fatal(VERSION_TOO_OLD_FOR_INDEX_RPC);
        throw e;
    }

    int indexHandlerCount = conf.getInt(QueryServices.INDEX_HANDLER_COUNT_ATTRIB, QueryServicesOptions.DEFAULT_INDEX_HANDLER_COUNT);
    int minPriority = getMinPriority(conf);
    int maxPriority = conf.getInt(QueryServices.MAX_INDEX_PRIOIRTY_ATTRIB, QueryServicesOptions.DEFAULT_INDEX_MAX_PRIORITY);
    // make sure the ranges are outside the warning ranges
    Preconditions.checkArgument(maxPriority > minPriority, "Max index priority (" + maxPriority
            + ") must be larger than min priority (" + minPriority + ")");
    boolean allSmaller =
            minPriority < HConstants.REPLICATION_QOS
                    && maxPriority < HConstants.REPLICATION_QOS;
    boolean allLarger = minPriority > HConstants.HIGH_QOS;
    Preconditions.checkArgument(allSmaller || allLarger, "Index priority range (" + minPriority
            + ",  " + maxPriority + ") must be outside HBase priority range ("
            + HConstants.REPLICATION_QOS + ", " + HConstants.HIGH_QOS + ")");

    LOG.info("Using custom Phoenix Index RPC Handling with " + indexHandlerCount
            + " handlers and priority range [" + minPriority + ", " + maxPriority + ")");

    PhoenixIndexRpcScheduler scheduler =
            new PhoenixIndexRpcScheduler(indexHandlerCount, conf, delegate, minPriority,
                    maxPriority);
    return scheduler;
}
 
public InterRegionServerRpcController(HBaseRpcController delegate, Configuration conf) {
    super(delegate);
    // Set priority higher that normal, but lower than high
    this.priority = (HConstants.HIGH_QOS + HConstants.NORMAL_QOS) / 2;
}
 
public InterRegionServerRpcController(PayloadCarryingRpcController delegate, Configuration conf) {
    super(delegate);
    // Set priority higher that normal, but lower than high
    this.priority = (HConstants.HIGH_QOS + HConstants.NORMAL_QOS) / 2;
}
 
@Override
public int getPriority(RPCProtos.RequestHeader header, Message param, User user) {
  // Yes this is copy pasted from the base class but it keeps from having to look in the
  // annotatedQos table twice something that could get costly since this is called for
  // every single RPC request.
  int priorityByAnnotation = getAnnotatedPriority(header);
  if (priorityByAnnotation >= 0) {
    // no one can have higher priority than meta transition.
    if (priorityByAnnotation >= META_TRANSITION_QOS) {
      return META_TRANSITION_QOS - 1;
    } else {
      return priorityByAnnotation;
    }
  }

  // If meta is moving then all the other of reports of state transitions will be
  // un able to edit meta. Those blocked reports should not keep the report that opens meta from
  // running. Hence all reports of meta transition should always be in a different thread.
  // This keeps from deadlocking the cluster.
  if (param instanceof RegionServerStatusProtos.ReportRegionStateTransitionRequest) {
    // Regions are moving. Lets see which ones.
    RegionServerStatusProtos.ReportRegionStateTransitionRequest tRequest =
      (RegionServerStatusProtos.ReportRegionStateTransitionRequest) param;
    for (RegionServerStatusProtos.RegionStateTransition rst : tRequest.getTransitionList()) {
      if (rst.getRegionInfoList() != null) {
        for (HBaseProtos.RegionInfo info : rst.getRegionInfoList()) {
          TableName tn = ProtobufUtil.toTableName(info.getTableName());
          if (TableName.META_TABLE_NAME.equals(tn)) {
            return META_TRANSITION_QOS;
          }
        }
      }
    }
    return HConstants.HIGH_QOS;
  }
  // also use HIGH_QOS for region server report
  if (param instanceof RegionServerStatusProtos.RegionServerReportRequest) {
    return HConstants.HIGH_QOS;
  }

  // Handle the rest of the different reasons to change priority.
  return getBasePriority(header, param);
}