use of org.apache.hyracks.api.constraints.IConstraintAcceptor in project asterixdb by apache.
the class JobSpecificationActivityClusterGraphGeneratorFactory method createActivityClusterGraphGenerator.
@Override
public IActivityClusterGraphGenerator createActivityClusterGraphGenerator(JobId jobId, final ICCServiceContext ccServiceCtx, Set<JobFlag> jobFlags) throws HyracksException {
final JobActivityGraphBuilder builder = new JobActivityGraphBuilder(spec, jobFlags);
PlanUtils.visit(spec, new IConnectorDescriptorVisitor() {
@Override
public void visit(IConnectorDescriptor conn) throws HyracksException {
builder.addConnector(conn);
}
});
PlanUtils.visit(spec, new IOperatorDescriptorVisitor() {
@Override
public void visit(IOperatorDescriptor op) {
op.contributeActivities(builder);
}
});
builder.finish();
final JobActivityGraph jag = builder.getActivityGraph();
ActivityClusterGraphBuilder acgb = new ActivityClusterGraphBuilder();
final ActivityClusterGraph acg = acgb.inferActivityClusters(jobId, jag);
acg.setFrameSize(spec.getFrameSize());
acg.setMaxReattempts(spec.getMaxReattempts());
acg.setJobletEventListenerFactory(spec.getJobletEventListenerFactory());
acg.setGlobalJobDataFactory(spec.getGlobalJobDataFactory());
acg.setConnectorPolicyAssignmentPolicy(spec.getConnectorPolicyAssignmentPolicy());
acg.setUseConnectorPolicyForScheduling(spec.isUseConnectorPolicyForScheduling());
final Set<Constraint> constraints = new HashSet<>();
final IConstraintAcceptor acceptor = new IConstraintAcceptor() {
@Override
public void addConstraint(Constraint constraint) {
constraints.add(constraint);
}
};
PlanUtils.visit(spec, new IOperatorDescriptorVisitor() {
@Override
public void visit(IOperatorDescriptor op) {
op.contributeSchedulingConstraints(acceptor, ccServiceCtx);
}
});
PlanUtils.visit(spec, new IConnectorDescriptorVisitor() {
@Override
public void visit(IConnectorDescriptor conn) {
conn.contributeSchedulingConstraints(acceptor, acg.getConnectorMap().get(conn.getConnectorId()), ccServiceCtx);
}
});
constraints.addAll(spec.getUserConstraints());
return new IActivityClusterGraphGenerator() {
@Override
public ActivityClusterGraph initialize() {
ActivityClusterGraphRewriter rewriter = new ActivityClusterGraphRewriter();
rewriter.rewrite(acg);
return acg;
}
@Override
public Set<Constraint> getConstraints() {
return constraints;
}
};
}
Aggregations