@Test public void testPriority() { Configuration conf = new Configuration(); conf.set("ns." + DecayRpcScheduler.IPC_CALLQUEUE_DECAYSCHEDULER_PERIOD_KEY, "99999999"); conf.set("ns." + DecayRpcScheduler.IPC_CALLQUEUE_DECAYSCHEDULER_THRESHOLDS_KEY, "25, 50, 75"); scheduler = new DecayRpcScheduler(4, "ns", conf); assertEquals(0, scheduler.getPriorityLevel(mockCall("A"))); assertEquals(2, scheduler.getPriorityLevel(mockCall("A"))); assertEquals(0, scheduler.getPriorityLevel(mockCall("B"))); assertEquals(1, scheduler.getPriorityLevel(mockCall("B"))); assertEquals(0, scheduler.getPriorityLevel(mockCall("C"))); assertEquals(0, scheduler.getPriorityLevel(mockCall("C"))); assertEquals(1, scheduler.getPriorityLevel(mockCall("A"))); assertEquals(1, scheduler.getPriorityLevel(mockCall("A"))); assertEquals(1, scheduler.getPriorityLevel(mockCall("A"))); assertEquals(2, scheduler.getPriorityLevel(mockCall("A"))); }
@Override public int getPriorityLevel(Schedulable obj) { String identity = this.identityProvider.makeIdentity(obj); if (identity == null) { identity = DECAYSCHEDULER_UNKNOWN_IDENTITY; } return cachedOrComputedPriorityLevel(identity); }
DecayRpcScheduler implements RpcScheduler, DecayRpcSchedulerMXBean { @Override public int getPriorityLevel(Schedulable obj) { String identity = this.identityProvider.makeIdentity(obj); if (identity == null) { identity = DECAYSCHEDULER_UNKNOWN_IDENTITY; } return cachedOrComputedPriorityLevel(identity); } }
DecayRpcScheduler implements RpcScheduler, DecayRpcSchedulerMXBean { @Override public int getPriorityLevel(Schedulable obj) { String identity = this.identityProvider.makeIdentity(obj); if (identity == null) { identity = DECAYSCHEDULER_UNKNOWN_IDENTITY; } return cachedOrComputedPriorityLevel(identity); } DecayRpcScheduler(int numQueues, String ns, Configuration conf); }
DecayRpcScheduler implements RpcScheduler, DecayRpcSchedulerMXBean { @Override public int getPriorityLevel(Schedulable obj) { String identity = this.identityProvider.makeIdentity(obj); if (identity == null) { identity = DECAYSCHEDULER_UNKNOWN_IDENTITY; } return cachedOrComputedPriorityLevel(identity); } DecayRpcScheduler(int numQueues, String ns, Configuration conf); @Override int getPriorityLevel(Schedulable obj); @VisibleForTesting double getDecayFactor(); @VisibleForTesting long getDecayPeriodMillis(); @VisibleForTesting double[] getThresholds(); @VisibleForTesting void forceDecay(); @VisibleForTesting Map<Object, Long> getCallCountSnapshot(); @VisibleForTesting long getTotalCallSnapshot(); int getUniqueIdentityCount(); long getTotalCallVolume(); String getSchedulingDecisionSummary(); String getCallVolumeSummary(); }
DecayRpcScheduler implements RpcScheduler, DecayRpcSchedulerMXBean { @Override public int getPriorityLevel(Schedulable obj) { String identity = this.identityProvider.makeIdentity(obj); if (identity == null) { identity = DECAYSCHEDULER_UNKNOWN_IDENTITY; } return cachedOrComputedPriorityLevel(identity); } DecayRpcScheduler(int numQueues, String ns, Configuration conf); @Override int getPriorityLevel(Schedulable obj); @VisibleForTesting double getDecayFactor(); @VisibleForTesting long getDecayPeriodMillis(); @VisibleForTesting double[] getThresholds(); @VisibleForTesting void forceDecay(); @VisibleForTesting Map<Object, Long> getCallCountSnapshot(); @VisibleForTesting long getTotalCallSnapshot(); int getUniqueIdentityCount(); long getTotalCallVolume(); String getSchedulingDecisionSummary(); String getCallVolumeSummary(); static final String IPC_CALLQUEUE_DECAYSCHEDULER_PERIOD_KEY; static final long IPC_CALLQUEUE_DECAYSCHEDULER_PERIOD_DEFAULT; static final String IPC_CALLQUEUE_DECAYSCHEDULER_FACTOR_KEY; static final double IPC_CALLQUEUE_DECAYSCHEDULER_FACTOR_DEFAULT; static final String IPC_CALLQUEUE_DECAYSCHEDULER_THRESHOLDS_KEY; static final String DECAYSCHEDULER_UNKNOWN_IDENTITY; static final Log LOG; }