@Test(timeout = 1000) public void testIsApplicableTo() throws AllocationConfigurationException { final String ERR = "Broken SchedulingPolicy#isApplicableTo"; SchedulingPolicy policy = SchedulingPolicy.parse("fifo"); assertTrue(ERR, SchedulingPolicy.isApplicableTo(policy, SchedulingPolicy.DEPTH_LEAF)); assertFalse(ERR, SchedulingPolicy.isApplicableTo( SchedulingPolicy.parse("fifo"), SchedulingPolicy.DEPTH_INTERMEDIATE)); assertFalse(ERR, SchedulingPolicy.isApplicableTo( SchedulingPolicy.parse("fifo"), SchedulingPolicy.DEPTH_ROOT)); policy = SchedulingPolicy.parse("fair"); assertTrue(ERR, SchedulingPolicy.isApplicableTo(policy, SchedulingPolicy.DEPTH_LEAF)); assertTrue(ERR, SchedulingPolicy.isApplicableTo(policy, SchedulingPolicy.DEPTH_INTERMEDIATE)); assertTrue(ERR, SchedulingPolicy.isApplicableTo(policy, SchedulingPolicy.DEPTH_ROOT)); assertTrue(ERR, SchedulingPolicy.isApplicableTo(policy, SchedulingPolicy.DEPTH_PARENT)); assertTrue(ERR, SchedulingPolicy.isApplicableTo(policy, SchedulingPolicy.DEPTH_ANY)); policy = SchedulingPolicy.parse("drf"); assertTrue(ERR, SchedulingPolicy.isApplicableTo(policy, SchedulingPolicy.DEPTH_LEAF)); assertTrue(ERR, SchedulingPolicy.isApplicableTo(policy, SchedulingPolicy.DEPTH_INTERMEDIATE)); assertTrue(ERR, SchedulingPolicy.isApplicableTo(policy, SchedulingPolicy.DEPTH_ROOT)); assertTrue(ERR, SchedulingPolicy.isApplicableTo(policy, SchedulingPolicy.DEPTH_PARENT)); assertTrue(ERR, SchedulingPolicy.isApplicableTo(policy, SchedulingPolicy.DEPTH_ANY)); policy = Mockito.mock(SchedulingPolicy.class); Mockito.when(policy.getApplicableDepth()).thenReturn( SchedulingPolicy.DEPTH_PARENT); assertTrue(ERR, SchedulingPolicy.isApplicableTo(policy, SchedulingPolicy.DEPTH_INTERMEDIATE)); assertTrue(ERR, SchedulingPolicy.isApplicableTo(policy, SchedulingPolicy.DEPTH_ROOT)); assertTrue(ERR, SchedulingPolicy.isApplicableTo(policy, SchedulingPolicy.DEPTH_PARENT)); assertFalse(ERR, SchedulingPolicy.isApplicableTo(policy, SchedulingPolicy.DEPTH_ANY)); }
public static boolean isApplicableTo(SchedulingPolicy policy, byte depth) { return ((policy.getApplicableDepth() & depth) == depth) ? true : false; }
SchedulingPolicy { public static boolean isApplicableTo(SchedulingPolicy policy, byte depth) { return ((policy.getApplicableDepth() & depth) == depth) ? true : false; } }
SchedulingPolicy { public static boolean isApplicableTo(SchedulingPolicy policy, byte depth) { return ((policy.getApplicableDepth() & depth) == depth) ? true : false; }  }
SchedulingPolicy { public static boolean isApplicableTo(SchedulingPolicy policy, byte depth) { return ((policy.getApplicableDepth() & depth) == depth) ? true : false; }  static SchedulingPolicy getInstance(Class<? extends SchedulingPolicy> clazz); @SuppressWarnings("unchecked") static SchedulingPolicy parse(String policy); void initialize(Resource clusterCapacity); abstract String getName(); abstract byte getApplicableDepth(); static boolean isApplicableTo(SchedulingPolicy policy, byte depth); abstract Comparator<Schedulable> getComparator(); abstract void computeShares(
      Collection<? extends Schedulable> schedulables, Resource totalResources); abstract void computeSteadyShares(
      Collection<? extends FSQueue> queues, Resource totalResources); abstract boolean checkIfUsageOverFairShare(
      Resource usage, Resource fairShare); abstract boolean checkIfAMResourceUsageOverLimit(
      Resource usage, Resource maxAMResource); abstract Resource getHeadroom(Resource queueFairShare,
      Resource queueUsage, Resource clusterAvailable); }
SchedulingPolicy { public static boolean isApplicableTo(SchedulingPolicy policy, byte depth) { return ((policy.getApplicableDepth() & depth) == depth) ? true : false; }  static SchedulingPolicy getInstance(Class<? extends SchedulingPolicy> clazz); @SuppressWarnings("unchecked") static SchedulingPolicy parse(String policy); void initialize(Resource clusterCapacity); abstract String getName(); abstract byte getApplicableDepth(); static boolean isApplicableTo(SchedulingPolicy policy, byte depth); abstract Comparator<Schedulable> getComparator(); abstract void computeShares(
      Collection<? extends Schedulable> schedulables, Resource totalResources); abstract void computeSteadyShares(
      Collection<? extends FSQueue> queues, Resource totalResources); abstract boolean checkIfUsageOverFairShare(
      Resource usage, Resource fairShare); abstract boolean checkIfAMResourceUsageOverLimit(
      Resource usage, Resource maxAMResource); abstract Resource getHeadroom(Resource queueFairShare,
      Resource queueUsage, Resource clusterAvailable); static final SchedulingPolicy DEFAULT_POLICY; static final byte DEPTH_LEAF; static final byte DEPTH_INTERMEDIATE; static final byte DEPTH_ROOT; static final byte DEPTH_PARENT; static final byte DEPTH_ANY; }