DecayRpcScheduler implements RpcScheduler,
    DecayRpcSchedulerMXBean, MetricsSource { private static double[] parseThresholds(String ns, Configuration conf, int numLevels) { int[] percentages = conf.getInts(ns + "." + IPC_FCQ_DECAYSCHEDULER_THRESHOLDS_KEY); if (percentages.length == 0) { percentages = conf.getInts(ns + "." + IPC_DECAYSCHEDULER_THRESHOLDS_KEY); if (percentages.length == 0) { return getDefaultThresholds(numLevels); } } else { LOG.warn(IPC_FCQ_DECAYSCHEDULER_THRESHOLDS_KEY + " is deprecated. Please use " + IPC_DECAYSCHEDULER_THRESHOLDS_KEY); } if (percentages.length != numLevels-1) { throw new IllegalArgumentException("Number of thresholds should be " + (numLevels-1) + ". Was: " + percentages.length); } double[] decimals = new double[percentages.length]; for (int i = 0; i < percentages.length; i++) { decimals[i] = percentages[i] / 100.0; } return decimals; } DecayRpcScheduler(int numLevels, String ns, Configuration conf); @Override int getPriorityLevel(Schedulable obj); @Override boolean shouldBackOff(Schedulable obj); @Override void addResponseTime(String name, int priorityLevel, int queueTime,
      int processingTime); @VisibleForTesting double getDecayFactor(); @VisibleForTesting long getDecayPeriodMillis(); @VisibleForTesting double[] getThresholds(); @VisibleForTesting void forceDecay(); @VisibleForTesting Map<Object, Long> getCallCountSnapshot(); @VisibleForTesting long getTotalCallSnapshot(); int getUniqueIdentityCount(); long getTotalCallVolume(); long getTotalRawCallVolume(); long[] getResponseTimeCountInLastWindow(); @Override double[] getAverageResponseTime(); @Override void getMetrics(MetricsCollector collector, boolean all); String getSchedulingDecisionSummary(); String getCallVolumeSummary(); @Override void stop(); static final String IPC_SCHEDULER_DECAYSCHEDULER_PERIOD_KEY; static final long IPC_SCHEDULER_DECAYSCHEDULER_PERIOD_DEFAULT; @Deprecated
  static final String IPC_FCQ_DECAYSCHEDULER_PERIOD_KEY; static final String IPC_SCHEDULER_DECAYSCHEDULER_FACTOR_KEY; static final double IPC_SCHEDULER_DECAYSCHEDULER_FACTOR_DEFAULT; @Deprecated
  static final String IPC_FCQ_DECAYSCHEDULER_FACTOR_KEY; static final String IPC_DECAYSCHEDULER_THRESHOLDS_KEY; @Deprecated
  static final String IPC_FCQ_DECAYSCHEDULER_THRESHOLDS_KEY; static final String DECAYSCHEDULER_UNKNOWN_IDENTITY; static final String IPC_DECAYSCHEDULER_BACKOFF_RESPONSETIME_ENABLE_KEY; static final Boolean IPC_DECAYSCHEDULER_BACKOFF_RESPONSETIME_ENABLE_DEFAULT; static final String IPC_DECAYSCHEDULER_BACKOFF_RESPONSETIME_THRESHOLDS_KEY; static final String DECAYSCHEDULER_METRICS_TOP_USER_COUNT; static final int DECAYSCHEDULER_METRICS_TOP_USER_COUNT_DEFAULT; static final Logger LOG; }
@Test @SuppressWarnings("deprecation") public void testParseThresholds() { Configuration conf = new Configuration(); scheduler = new DecayRpcScheduler(1, "", conf); assertEqualDecimalArrays(new double[]{}, scheduler.getThresholds()); scheduler = new DecayRpcScheduler(2, "", conf); assertEqualDecimalArrays(new double[]{0.5}, scheduler.getThresholds()); scheduler = new DecayRpcScheduler(3, "", conf); assertEqualDecimalArrays(new double[]{0.25, 0.5}, scheduler.getThresholds()); scheduler = new DecayRpcScheduler(4, "", conf); assertEqualDecimalArrays(new double[]{0.125, 0.25, 0.5}, scheduler.getThresholds()); conf = new Configuration(); conf.set("ns." + DecayRpcScheduler.IPC_FCQ_DECAYSCHEDULER_THRESHOLDS_KEY, "1, 10, 20, 50, 85"); scheduler = new DecayRpcScheduler(6, "ns", conf); assertEqualDecimalArrays(new double[]{0.01, 0.1, 0.2, 0.5, 0.85}, scheduler.getThresholds()); }