Search in sources :

Example 66 with OperatorMeta

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

the class PhysicalPlan method removeLogicalStream.

/**
   * Remove physical representation of given stream. Operators that are affected
   * in the execution layer will be added to the set. This method does not
   * automatically remove operators from the plan.
   *
   * @param sm
   */
public void removeLogicalStream(StreamMeta sm) {
    // remove incoming connections for logical stream
    for (InputPortMeta ipm : sm.getSinks()) {
        OperatorMeta om = ipm.getOperatorMeta();
        PMapping m = this.logicalToPTOperator.get(om);
        if (m == null) {
            throw new AssertionError("Unknown operator " + om);
        }
        for (PTOperator oper : m.partitions) {
            List<PTInput> inputsCopy = Lists.newArrayList(oper.inputs);
            for (PTInput input : oper.inputs) {
                if (input.logicalStream == sm) {
                    input.source.sinks.remove(input);
                    inputsCopy.remove(input);
                    undeployOpers.add(oper);
                    deployOpers.add(oper);
                }
            }
            oper.inputs = inputsCopy;
        }
    }
    // remove outgoing connections for logical stream
    PMapping m = this.logicalToPTOperator.get(sm.getSource().getOperatorMeta());
    for (PTOperator oper : m.partitions) {
        List<PTOutput> outputsCopy = Lists.newArrayList(oper.outputs);
        for (PTOutput out : oper.outputs) {
            if (out.logicalStream == sm) {
                for (PTInput input : out.sinks) {
                    PTOperator downstreamOper = input.source.source;
                    downstreamOper.inputs.remove(input);
                    Set<PTOperator> deps = this.getDependents(Collections.singletonList(downstreamOper));
                    undeployOpers.addAll(deps);
                    deployOpers.addAll(deps);
                }
                outputsCopy.remove(out);
                undeployOpers.add(oper);
                deployOpers.add(oper);
            }
        }
        oper.outputs = outputsCopy;
    }
}
Also used : InputPortMeta(com.datatorrent.stram.plan.logical.LogicalPlan.InputPortMeta) OperatorMeta(com.datatorrent.stram.plan.logical.LogicalPlan.OperatorMeta) PTInput(com.datatorrent.stram.plan.physical.PTOperator.PTInput) PTOutput(com.datatorrent.stram.plan.physical.PTOperator.PTOutput)

Example 67 with OperatorMeta

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

the class PlanModifier method setOperatorProperty.

/**
   * Set the property on a new operator. Since this is only intended to modify
   * previously added operators, no change to the physical plan is required.
   *
   * @param operatorName
   * @param propertyName
   * @param propertyValue
   */
public void setOperatorProperty(String operatorName, String propertyName, String propertyValue) {
    OperatorMeta om = assertGetOperator(operatorName);
    if (physicalPlan != null) {
        for (PTOperator oper : physicalPlan.getOperators(om)) {
            if (!physicalPlan.newOpers.containsKey(oper)) {
                throw new ValidationException("Properties can only be set on new operators: " + om + " " + propertyName + " " + propertyValue);
            }
        }
    }
    Map<String, String> props = Collections.singletonMap(propertyName, propertyValue);
    LogicalPlanConfiguration.setOperatorProperties(om.getOperator(), props);
}
Also used : ValidationException(javax.validation.ValidationException) OperatorMeta(com.datatorrent.stram.plan.logical.LogicalPlan.OperatorMeta)

Example 68 with OperatorMeta

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

the class StreamMapping method addSlidingUnifiers.

private void addSlidingUnifiers() {
    OperatorMeta sourceOM = streamMeta.getSource().getOperatorMeta();
    if (sourceOM.getAttributes().contains(Context.OperatorContext.SLIDE_BY_WINDOW_COUNT)) {
        if (sourceOM.getValue(Context.OperatorContext.SLIDE_BY_WINDOW_COUNT) < sourceOM.getValue(Context.OperatorContext.APPLICATION_WINDOW_COUNT)) {
            plan.undeployOpers.addAll(slidingUnifiers);
            slidingUnifiers.clear();
            List<PTOutput> newUpstream = Lists.newArrayList();
            PTOperator slidingUnifier;
            for (PTOutput source : upstream) {
                slidingUnifier = StreamMapping.createSlidingUnifier(streamMeta, plan, sourceOM.getValue(Context.OperatorContext.APPLICATION_WINDOW_COUNT), sourceOM.getValue(Context.OperatorContext.SLIDE_BY_WINDOW_COUNT));
                addInput(slidingUnifier, source, null);
                this.slidingUnifiers.add(slidingUnifier);
                newUpstream.add(slidingUnifier.outputs.get(0));
            }
            upstream.clear();
            upstream.addAll(newUpstream);
        } else {
            LOG.warn("Sliding Window Count {} should be less than APPLICATION WINDOW COUNT {}", sourceOM.getValue(Context.OperatorContext.SLIDE_BY_WINDOW_COUNT), sourceOM.getValue(Context.OperatorContext.APPLICATION_WINDOW_COUNT));
        }
    }
}
Also used : OperatorMeta(com.datatorrent.stram.plan.logical.LogicalPlan.OperatorMeta) PTOutput(com.datatorrent.stram.plan.physical.PTOperator.PTOutput)

Example 69 with OperatorMeta

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

the class StreamMapping method createUnifier.

public static PTOperator createUnifier(StreamMeta streamMeta, PhysicalPlan plan) {
    OperatorMeta um = streamMeta.getSource().getUnifierMeta();
    PTOperator pu = plan.newOperator(um, um.getName());
    Operator unifier = um.getOperator();
    PortMappingDescriptor mergeDesc = new PortMappingDescriptor();
    Operators.describe(unifier, mergeDesc);
    if (mergeDesc.outputPorts.size() != 1) {
        throw new AssertionError("Unifier must have a single output port, instead found : " + mergeDesc.outputPorts);
    }
    pu.unifiedOperatorMeta = streamMeta.getSource().getOperatorMeta();
    pu.outputs.add(new PTOutput(mergeDesc.outputPorts.keySet().iterator().next(), streamMeta, pu));
    plan.newOpers.put(pu, unifier);
    return pu;
}
Also used : Operator(com.datatorrent.api.Operator) OperatorMeta(com.datatorrent.stram.plan.logical.LogicalPlan.OperatorMeta) PTOutput(com.datatorrent.stram.plan.physical.PTOperator.PTOutput) PortMappingDescriptor(com.datatorrent.stram.plan.logical.Operators.PortMappingDescriptor)

Example 70 with OperatorMeta

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

the class StramWebServices method getLogicalOperator.

@GET
@Path(PATH_LOGICAL_PLAN_OPERATORS + "/{operatorName}")
@Produces(MediaType.APPLICATION_JSON)
public JSONObject getLogicalOperator(@PathParam("operatorName") String operatorName) throws Exception {
    init();
    OperatorMeta logicalOperator = dagManager.getLogicalPlan().getOperatorMeta(operatorName);
    if (logicalOperator == null) {
        throw new NotFoundException();
    }
    LogicalOperatorInfo logicalOperatorInfo = dagManager.getLogicalOperatorInfo(operatorName);
    return new JSONObject(objectMapper.writeValueAsString(logicalOperatorInfo));
}
Also used : OperatorMeta(com.datatorrent.stram.plan.logical.LogicalPlan.OperatorMeta) JSONObject(org.codehaus.jettison.json.JSONObject) NotFoundException(org.apache.hadoop.yarn.webapp.NotFoundException) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

OperatorMeta (com.datatorrent.stram.plan.logical.LogicalPlan.OperatorMeta)78 Test (org.junit.Test)38 GenericTestOperator (com.datatorrent.stram.engine.GenericTestOperator)35 Checkpoint (com.datatorrent.stram.api.Checkpoint)23 TestPlanContext (com.datatorrent.stram.plan.TestPlanContext)23 LogicalPlan (com.datatorrent.stram.plan.logical.LogicalPlan)23 PartitioningTest (com.datatorrent.stram.PartitioningTest)16 HashMap (java.util.HashMap)16 JSONObject (org.codehaus.jettison.json.JSONObject)16 StreamMeta (com.datatorrent.stram.plan.logical.LogicalPlan.StreamMeta)15 Map (java.util.Map)15 PTOperator (com.datatorrent.stram.plan.physical.PTOperator)14 InputPortMeta (com.datatorrent.stram.plan.logical.LogicalPlan.InputPortMeta)13 StatsListener (com.datatorrent.api.StatsListener)12 PhysicalPlan (com.datatorrent.stram.plan.physical.PhysicalPlan)12 TestGeneratorInputOperator (com.datatorrent.stram.engine.TestGeneratorInputOperator)11 Configuration (org.apache.hadoop.conf.Configuration)11 PTInput (com.datatorrent.stram.plan.physical.PTOperator.PTInput)10 Integer2String (com.datatorrent.api.StringCodec.Integer2String)9 OutputPortMeta (com.datatorrent.stram.plan.logical.LogicalPlan.OutputPortMeta)9