Search in sources :

Example 1 with IExecSorter

use of org.apache.storm.scheduler.resource.strategies.scheduling.sorter.IExecSorter in project storm by apache.

the class TestConstraintSolverStrategy method testConstraintSolverForceBacktrackWithSpreadCoLocation.

@Test
public void testConstraintSolverForceBacktrackWithSpreadCoLocation() {
    // to find an answer.
    if (CO_LOCATION_CNT > 1 && !consolidatedConfigFlag) {
        LOG.info("INFO: Skipping Test {} with {}={} (required 1), and consolidatedConfigFlag={} (required false)", "testConstraintSolverForceBacktrackWithSpreadCoLocation", ConstraintSolverConfig.CONSTRAINT_TYPE_MAX_NODE_CO_LOCATION_CNT, CO_LOCATION_CNT, consolidatedConfigFlag);
        return;
    }
    ConstraintSolverStrategy cs = new ConstraintSolverStrategy() {

        protected void prepareForScheduling(Cluster cluster, TopologyDetails topologyDetails) {
            super.prepareForScheduling(cluster, topologyDetails);
            // set a reversing execSorter instance
            IExecSorter execSorter = new ExecSorterByConstraintSeverity(cluster, topologyDetails) {

                @Override
                public List<ExecutorDetails> sortExecutors(Set<ExecutorDetails> unassignedExecutors) {
                    List<ExecutorDetails> tmp = super.sortExecutors(unassignedExecutors);
                    List<ExecutorDetails> reversed = new ArrayList<>();
                    while (!tmp.isEmpty()) {
                        reversed.add(0, tmp.remove(0));
                    }
                    return reversed;
                }
            };
            setExecSorter(execSorter);
        }
    };
    basicUnitTestWithKillAndRecover(cs, BACKTRACK_BOLT_PARALLEL, CO_LOCATION_CNT);
}
Also used : ExecutorDetails(org.apache.storm.scheduler.ExecutorDetails) HashSet(java.util.HashSet) Set(java.util.Set) ArrayList(java.util.ArrayList) Cluster(org.apache.storm.scheduler.Cluster) TopologyDetails(org.apache.storm.scheduler.TopologyDetails) ExecSorterByConstraintSeverity(org.apache.storm.scheduler.resource.strategies.scheduling.sorter.ExecSorterByConstraintSeverity) IExecSorter(org.apache.storm.scheduler.resource.strategies.scheduling.sorter.IExecSorter) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1 Cluster (org.apache.storm.scheduler.Cluster)1 ExecutorDetails (org.apache.storm.scheduler.ExecutorDetails)1 TopologyDetails (org.apache.storm.scheduler.TopologyDetails)1 ExecSorterByConstraintSeverity (org.apache.storm.scheduler.resource.strategies.scheduling.sorter.ExecSorterByConstraintSeverity)1 IExecSorter (org.apache.storm.scheduler.resource.strategies.scheduling.sorter.IExecSorter)1 Test (org.junit.Test)1