DecayRpcScheduler implements RpcScheduler,
    DecayRpcSchedulerMXBean, MetricsSource { @VisibleForTesting void forceDecay() { decayCurrentCosts(); } DecayRpcScheduler(int numLevels, String ns, Configuration conf); @Override int getPriorityLevel(Schedulable obj); @Override boolean shouldBackOff(Schedulable obj); @Override void addResponseTime(String callName, Schedulable schedulable,
      ProcessingDetails details); int getUniqueIdentityCount(); long getTotalCallVolume(); long getTotalRawCallVolume(); long getTotalServiceUserCallVolume(); long getTotalServiceUserRawCallVolume(); long[] getResponseTimeCountInLastWindow(); @Override double[] getAverageResponseTime(); @Override void getMetrics(MetricsCollector collector, boolean all); String getSchedulingDecisionSummary(); String getCallVolumeSummary(); @VisibleForTesting DecayRpcSchedulerDetailedMetrics getDecayRpcSchedulerDetailedMetrics(); @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 IPC_DECAYSCHEDULER_SERVICE_USERS_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 testPriority() throws Exception { Configuration conf = new Configuration(); final String namespace = "ipc.12"; conf.set(namespace + "." + DecayRpcScheduler .IPC_FCQ_DECAYSCHEDULER_PERIOD_KEY, "99999999"); conf.set(namespace + "." + DecayRpcScheduler .IPC_FCQ_DECAYSCHEDULER_THRESHOLDS_KEY, "25, 50, 75"); scheduler = new DecayRpcScheduler(4, namespace, conf); assertEquals(0, getPriorityIncrementCallCount("A")); assertEquals(3, getPriorityIncrementCallCount("A")); assertEquals(0, getPriorityIncrementCallCount("B")); assertEquals(1, getPriorityIncrementCallCount("B")); assertEquals(0, getPriorityIncrementCallCount("C")); assertEquals(0, getPriorityIncrementCallCount("C")); assertEquals(1, getPriorityIncrementCallCount("A")); assertEquals(1, getPriorityIncrementCallCount("A")); assertEquals(2, getPriorityIncrementCallCount("A")); assertEquals(2, getPriorityIncrementCallCount("A")); MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); ObjectName mxbeanName = new ObjectName( "Hadoop:service="+ namespace + ",name=DecayRpcScheduler"); String cvs1 = (String) mbs.getAttribute(mxbeanName, "CallVolumeSummary"); assertTrue("Get expected JMX of CallVolumeSummary before decay", cvs1.equals("{\"A\":6,\"B\":2,\"C\":2}")); scheduler.forceDecay(); String cvs2 = (String) mbs.getAttribute(mxbeanName, "CallVolumeSummary"); assertTrue("Get expected JMX for CallVolumeSummary after decay", cvs2.equals("{\"A\":3,\"B\":1,\"C\":1}")); }