@Test public void testSufficientPorts() { control.replay(); ResourceSlot twoPorts = Resources.from( Offers.createOffer(DEFAULT_CPUS, DEFAULT_RAM, DEFAULT_DISK, Pair.of(80, 81))).slot(); ITaskConfig noPortTask = ITaskConfig.build(makeTask(DEFAULT_CPUS, DEFAULT_RAM, DEFAULT_DISK) .newBuilder() .setRequestedPorts(ImmutableSet.of())); ITaskConfig onePortTask = ITaskConfig.build(makeTask(DEFAULT_CPUS, DEFAULT_RAM, DEFAULT_DISK) .newBuilder() .setRequestedPorts(ImmutableSet.of("one"))); ITaskConfig twoPortTask = ITaskConfig.build(makeTask(DEFAULT_CPUS, DEFAULT_RAM, DEFAULT_DISK) .newBuilder() .setRequestedPorts(ImmutableSet.of("one", "two"))); ITaskConfig threePortTask = ITaskConfig.build(makeTask(DEFAULT_CPUS, DEFAULT_RAM, DEFAULT_DISK) .newBuilder() .setRequestedPorts(ImmutableSet.of("one", "two", "three"))); Set<Veto> none = ImmutableSet.of(); IHostAttributes hostA = hostAttributes(HOST_A, host(HOST_A), rack(RACK_A)); assertEquals( none, defaultFilter.filter( new UnusedResource(twoPorts, hostA), new ResourceRequest(noPortTask, EMPTY))); assertEquals( none, defaultFilter.filter( new UnusedResource(twoPorts, hostA), new ResourceRequest(onePortTask, EMPTY))); assertEquals( none, defaultFilter.filter( new UnusedResource(twoPorts, hostA), new ResourceRequest(twoPortTask, EMPTY))); assertEquals( ImmutableSet.of(veto(PORTS, 1)), defaultFilter.filter( new UnusedResource(twoPorts, hostA), new ResourceRequest(threePortTask, EMPTY))); }
@Timed("scheduling_filter") @Override public Set<Veto> filter(UnusedResource resource, ResourceRequest request) { if (!ConfigurationManager.isDedicated(request.getConstraints()) && isDedicated(resource.getAttributes())) { return ImmutableSet.of(Veto.dedicatedHostConstraintMismatch()); } Optional<Veto> maintenanceVeto = getMaintenanceVeto(resource.getAttributes().getMode()); if (maintenanceVeto.isPresent()) { return maintenanceVeto.asSet(); } Optional<Veto> constraintVeto = getConstraintVeto( request.getConstraints(), request.getJobState(), resource.getAttributes().getAttributes()); if (constraintVeto.isPresent()) { return constraintVeto.asSet(); } return getResourceVetoes( resource.getResourceSlot(), ResourceSlot.from(request.getTask()).add(executorSettings.getExecutorOverhead())); }
SchedulingFilterImpl implements SchedulingFilter { @Timed("scheduling_filter") @Override public Set<Veto> filter(UnusedResource resource, ResourceRequest request) { if (!ConfigurationManager.isDedicated(request.getConstraints()) && isDedicated(resource.getAttributes())) { return ImmutableSet.of(Veto.dedicatedHostConstraintMismatch()); } Optional<Veto> maintenanceVeto = getMaintenanceVeto(resource.getAttributes().getMode()); if (maintenanceVeto.isPresent()) { return maintenanceVeto.asSet(); } Optional<Veto> constraintVeto = getConstraintVeto( request.getConstraints(), request.getJobState(), resource.getAttributes().getAttributes()); if (constraintVeto.isPresent()) { return constraintVeto.asSet(); } return getResourceVetoes( resource.getResourceSlot(), ResourceSlot.from(request.getTask()).add(executorSettings.getExecutorOverhead())); } }
SchedulingFilterImpl implements SchedulingFilter { @Timed("scheduling_filter") @Override public Set<Veto> filter(UnusedResource resource, ResourceRequest request) { if (!ConfigurationManager.isDedicated(request.getConstraints()) && isDedicated(resource.getAttributes())) { return ImmutableSet.of(Veto.dedicatedHostConstraintMismatch()); } Optional<Veto> maintenanceVeto = getMaintenanceVeto(resource.getAttributes().getMode()); if (maintenanceVeto.isPresent()) { return maintenanceVeto.asSet(); } Optional<Veto> constraintVeto = getConstraintVeto( request.getConstraints(), request.getJobState(), resource.getAttributes().getAttributes()); if (constraintVeto.isPresent()) { return constraintVeto.asSet(); } return getResourceVetoes( resource.getResourceSlot(), ResourceSlot.from(request.getTask()).add(executorSettings.getExecutorOverhead())); } @Inject @VisibleForTesting  SchedulingFilterImpl(ExecutorSettings executorSettings); }
SchedulingFilterImpl implements SchedulingFilter { @Timed("scheduling_filter") @Override public Set<Veto> filter(UnusedResource resource, ResourceRequest request) { if (!ConfigurationManager.isDedicated(request.getConstraints()) && isDedicated(resource.getAttributes())) { return ImmutableSet.of(Veto.dedicatedHostConstraintMismatch()); } Optional<Veto> maintenanceVeto = getMaintenanceVeto(resource.getAttributes().getMode()); if (maintenanceVeto.isPresent()) { return maintenanceVeto.asSet(); } Optional<Veto> constraintVeto = getConstraintVeto( request.getConstraints(), request.getJobState(), resource.getAttributes().getAttributes()); if (constraintVeto.isPresent()) { return constraintVeto.asSet(); } return getResourceVetoes( resource.getResourceSlot(), ResourceSlot.from(request.getTask()).add(executorSettings.getExecutorOverhead())); } @Inject @VisibleForTesting  SchedulingFilterImpl(ExecutorSettings executorSettings); @Timed("scheduling_filter") @Override Set<Veto> filter(UnusedResource resource, ResourceRequest request); }
SchedulingFilterImpl implements SchedulingFilter { @Timed("scheduling_filter") @Override public Set<Veto> filter(UnusedResource resource, ResourceRequest request) { if (!ConfigurationManager.isDedicated(request.getConstraints()) && isDedicated(resource.getAttributes())) { return ImmutableSet.of(Veto.dedicatedHostConstraintMismatch()); } Optional<Veto> maintenanceVeto = getMaintenanceVeto(resource.getAttributes().getMode()); if (maintenanceVeto.isPresent()) { return maintenanceVeto.asSet(); } Optional<Veto> constraintVeto = getConstraintVeto( request.getConstraints(), request.getJobState(), resource.getAttributes().getAttributes()); if (constraintVeto.isPresent()) { return constraintVeto.asSet(); } return getResourceVetoes( resource.getResourceSlot(), ResourceSlot.from(request.getTask()).add(executorSettings.getExecutorOverhead())); } @Inject @VisibleForTesting  SchedulingFilterImpl(ExecutorSettings executorSettings); @Timed("scheduling_filter") @Override Set<Veto> filter(UnusedResource resource, ResourceRequest request);  }