Search in sources :

Example 51 with PTOperator

use of com.datatorrent.stram.plan.physical.PTOperator in project apex-core by apache.

the class StreamingContainerManager method setPhysicalOperatorProperty.

/**
   * Set property on a physical operator. The property change is applied asynchronously on the deployed operator.
   *
   * @param operatorId
   * @param propertyName
   * @param propertyValue
   */
public void setPhysicalOperatorProperty(int operatorId, String propertyName, String propertyValue) {
    PTOperator o = this.plan.getAllOperators().get(operatorId);
    if (o == null) {
        return;
    }
    writeJournal(new SetPhysicalOperatorProperty(operatorId, propertyName, propertyValue));
    setPhysicalOperatorProperty(o, propertyName, propertyValue);
}
Also used : PTOperator(com.datatorrent.stram.plan.physical.PTOperator)

Example 52 with PTOperator

use of com.datatorrent.stram.plan.physical.PTOperator in project apex-core by apache.

the class StreamingContainerManager method stopRecording.

public void stopRecording(int operId, String portName) {
    StreamingContainerAgent sca = getContainerAgentFromOperatorId(operId);
    StramToNodeRequest request = new StramToNodeRequest();
    request.setOperatorId(operId);
    if (!StringUtils.isBlank(portName)) {
        request.setPortName(portName);
    }
    request.setRequestType(StramToNodeRequest.RequestType.STOP_RECORDING);
    sca.addOperatorRequest(request);
    PTOperator operator = plan.getAllOperators().get(operId);
    if (operator != null) {
        // no stop on deploy, but remove existing start
        updateOnDeployRequests(operator, new RecordingRequestFilter(), null);
    }
}
Also used : PTOperator(com.datatorrent.stram.plan.physical.PTOperator) StramToNodeRequest(com.datatorrent.stram.api.StreamingContainerUmbilicalProtocol.StramToNodeRequest)

Example 53 with PTOperator

use of com.datatorrent.stram.plan.physical.PTOperator in project apex-core by apache.

the class StreamingContainerManager method getPhysicalOperatorProperty.

public FutureTask<Object> getPhysicalOperatorProperty(int operatorId, String propertyName, long waitTime) {
    PTOperator o = this.plan.getAllOperators().get(operatorId);
    StramToNodeGetPropertyRequest request = new StramToNodeGetPropertyRequest();
    request.setOperatorId(operatorId);
    request.setPropertyName(propertyName);
    addOperatorRequest(o, request);
    RequestHandler task = new RequestHandler();
    task.requestId = nodeToStramRequestIds.incrementAndGet();
    task.waitTime = waitTime;
    request.requestId = task.requestId;
    FutureTask<Object> future = new FutureTask<>(task);
    dispatch(future);
    return future;
}
Also used : StramToNodeGetPropertyRequest(com.datatorrent.stram.api.StramToNodeGetPropertyRequest) PTOperator(com.datatorrent.stram.plan.physical.PTOperator) FutureTask(java.util.concurrent.FutureTask) JSONObject(org.codehaus.jettison.json.JSONObject)

Example 54 with PTOperator

use of com.datatorrent.stram.plan.physical.PTOperator in project apex-core by apache.

the class StreamingContainerManager method newStreamingContainerContext.

private StreamingContainerContext newStreamingContainerContext(PTContainer container) {
    try {
        int bufferServerMemory = 0;
        Iterator<PTOperator> operatorIterator = container.getOperators().iterator();
        while (operatorIterator.hasNext()) {
            bufferServerMemory += operatorIterator.next().getBufferServerMemory();
        }
        LOG.debug("Buffer Server Memory {}", bufferServerMemory);
        // the logical plan is not to be serialized via RPC, clone attributes only
        StreamingContainerContext scc = new StreamingContainerContext(plan.getLogicalPlan().getAttributes().clone(), null);
        scc.attributes.put(ContainerContext.IDENTIFIER, container.getExternalId());
        scc.attributes.put(ContainerContext.BUFFER_SERVER_MB, bufferServerMemory);
        scc.attributes.put(ContainerContext.BUFFER_SERVER_TOKEN, container.getBufferServerToken());
        scc.startWindowMillis = this.vars.windowStartMillis;
        return scc;
    } catch (CloneNotSupportedException ex) {
        throw new RuntimeException("Cannot clone DAG attributes", ex);
    }
}
Also used : PTOperator(com.datatorrent.stram.plan.physical.PTOperator) StreamingContainerContext(com.datatorrent.stram.api.StreamingContainerUmbilicalProtocol.StreamingContainerContext) Checkpoint(com.datatorrent.stram.api.Checkpoint)

Example 55 with PTOperator

use of com.datatorrent.stram.plan.physical.PTOperator in project apex-core by apache.

the class StreamingContainerManager method setOperatorProperty.

private void setOperatorProperty(OperatorMeta logicalOperator, String propertyName, String propertyValue) {
    Map<String, String> properties = Collections.singletonMap(propertyName, propertyValue);
    LogicalPlanConfiguration.setOperatorProperties(logicalOperator.getOperator(), properties);
    List<PTOperator> operators = plan.getOperators(logicalOperator);
    for (PTOperator o : operators) {
        StramToNodeSetPropertyRequest request = new StramToNodeSetPropertyRequest();
        request.setOperatorId(o.getId());
        request.setPropertyKey(propertyName);
        request.setPropertyValue(propertyValue);
        addOperatorRequest(o, request);
        // re-apply to checkpointed state on deploy
        updateOnDeployRequests(o, new SetOperatorPropertyRequestFilter(propertyName), request);
    }
    // should probably not record it here because it's better to get confirmation from the operators first.
    // but right now, the operators do not give confirmation for the requests.  so record it here for now.
    recordEventAsync(new StramEvent.SetOperatorPropertyEvent(logicalOperator.getName(), propertyName, propertyValue));
}
Also used : PTOperator(com.datatorrent.stram.plan.physical.PTOperator) StramEvent(com.datatorrent.stram.api.StramEvent) StramToNodeSetPropertyRequest(com.datatorrent.stram.api.StramToNodeSetPropertyRequest)

Aggregations

PTOperator (com.datatorrent.stram.plan.physical.PTOperator)84 Test (org.junit.Test)39 PhysicalPlan (com.datatorrent.stram.plan.physical.PhysicalPlan)38 GenericTestOperator (com.datatorrent.stram.engine.GenericTestOperator)36 PTContainer (com.datatorrent.stram.plan.physical.PTContainer)34 Checkpoint (com.datatorrent.stram.api.Checkpoint)23 LogicalPlan (com.datatorrent.stram.plan.logical.LogicalPlan)22 MemoryStorageAgent (com.datatorrent.stram.support.StramTestSupport.MemoryStorageAgent)16 OperatorDeployInfo (com.datatorrent.stram.api.OperatorDeployInfo)15 OperatorMeta (com.datatorrent.stram.plan.logical.LogicalPlan.OperatorMeta)15 PhysicalPlanTest (com.datatorrent.stram.plan.physical.PhysicalPlanTest)14 TestGeneratorInputOperator (com.datatorrent.stram.engine.TestGeneratorInputOperator)11 ArrayList (java.util.ArrayList)10 HashMap (java.util.HashMap)10 AsyncFSStorageAgent (com.datatorrent.common.util.AsyncFSStorageAgent)9 StramTestSupport (com.datatorrent.stram.support.StramTestSupport)9 Map (java.util.Map)9 TestPlanContext (com.datatorrent.stram.plan.TestPlanContext)7 Operator (com.datatorrent.api.Operator)6 StatsListener (com.datatorrent.api.StatsListener)6