Search in sources :

Example 1 with OperatorPair

use of com.datatorrent.stram.plan.logical.LogicalPlan.OperatorPair in project apex-core by apache.

the class PhysicalPlan method setAntiAffinityForContainers.

public void setAntiAffinityForContainers(LogicalPlan dag, Collection<AffinityRule> affinityRules, Map<PTOperator, PTContainer> operatorContainerMap) {
    for (AffinityRule rule : affinityRules) {
        if (rule.getOperatorsList() != null && rule.getType() == Type.ANTI_AFFINITY) {
            for (int i = 0; i < rule.getOperatorsList().size() - 1; i++) {
                for (int j = i + 1; j < rule.getOperatorsList().size(); j++) {
                    OperatorPair operators = new OperatorPair(rule.getOperatorsList().get(i), rule.getOperatorsList().get(j));
                    PMapping firstPMapping = logicalToPTOperator.get(dag.getOperatorMeta(operators.first));
                    OperatorMeta opMeta = dag.getOperatorMeta(operators.second);
                    PMapping secondMapping = logicalToPTOperator.get(opMeta);
                    for (PTOperator firstPtOperator : firstPMapping.partitions) {
                        PTContainer firstContainer = operatorContainerMap.get(firstPtOperator);
                        for (PTOperator secondPtOperator : secondMapping.partitions) {
                            PTContainer secondContainer = operatorContainerMap.get(secondPtOperator);
                            if (firstContainer == secondContainer || firstContainer.getStrictAntiPrefs().contains(secondContainer)) {
                                continue;
                            }
                            if (rule.isRelaxLocality()) {
                                firstContainer.getPreferredAntiPrefs().add(secondContainer);
                                secondContainer.getPreferredAntiPrefs().add(firstContainer);
                            } else {
                                firstContainer.getStrictAntiPrefs().add(secondContainer);
                                secondContainer.getStrictAntiPrefs().add(firstContainer);
                            }
                        }
                    }
                }
            }
        }
    }
}
Also used : OperatorPair(com.datatorrent.stram.plan.logical.LogicalPlan.OperatorPair) AffinityRule(com.datatorrent.api.AffinityRule) OperatorMeta(com.datatorrent.stram.plan.logical.LogicalPlan.OperatorMeta) Checkpoint(com.datatorrent.stram.api.Checkpoint)

Aggregations

AffinityRule (com.datatorrent.api.AffinityRule)1 Checkpoint (com.datatorrent.stram.api.Checkpoint)1 OperatorMeta (com.datatorrent.stram.plan.logical.LogicalPlan.OperatorMeta)1 OperatorPair (com.datatorrent.stram.plan.logical.LogicalPlan.OperatorPair)1