Search in sources :

Example 1 with GenericCommandsRequestPayload

use of org.apache.apex.malhar.python.base.requestresponse.GenericCommandsRequestPayload in project apex-malhar by apache.

the class PythonRequestResponseUtil method buildRequestObjectForRunCommands.

/**
 * Builds the request object for run commands API request. See
 * {@link ApexPythonEngine#runCommands(WorkerExecutionMode, long, long, PythonInterpreterRequest)} for details
 * @param commands
 * @param timeOut timeout for the request to complete
 * @param timeUnit Time units
 * @return A request object that can be passed to the Python Engine API for run commands
 */
public static PythonInterpreterRequest<Void> buildRequestObjectForRunCommands(List<String> commands, long timeOut, TimeUnit timeUnit) {
    GenericCommandsRequestPayload genericCommandsRequestPayload = new GenericCommandsRequestPayload();
    genericCommandsRequestPayload.setGenericCommands(commands);
    PythonInterpreterRequest<Void> request = new PythonInterpreterRequest<>(Void.class);
    request.setTimeUnit(timeUnit);
    request.setTimeout(timeOut);
    request.setGenericCommandsRequestPayload(genericCommandsRequestPayload);
    return request;
}
Also used : GenericCommandsRequestPayload(org.apache.apex.malhar.python.base.requestresponse.GenericCommandsRequestPayload) PythonInterpreterRequest(org.apache.apex.malhar.python.base.requestresponse.PythonInterpreterRequest)

Example 2 with GenericCommandsRequestPayload

use of org.apache.apex.malhar.python.base.requestresponse.GenericCommandsRequestPayload in project apex-malhar by apache.

the class BaseJEPTest method buildRequestObjectForVoidGenericCommand.

protected PythonInterpreterRequest<Void> buildRequestObjectForVoidGenericCommand(List<String> commands, long timeOut, TimeUnit timeUnit) {
    PythonInterpreterRequest<Void> genericCommandRequest = new PythonInterpreterRequest<>(Void.class);
    genericCommandRequest.setTimeout(timeOut);
    genericCommandRequest.setTimeUnit(timeUnit);
    GenericCommandsRequestPayload genericCommandsRequestPayload = new GenericCommandsRequestPayload();
    genericCommandsRequestPayload.setGenericCommands(commands);
    genericCommandRequest.setExpectedReturnType(Void.class);
    genericCommandRequest.setGenericCommandsRequestPayload(genericCommandsRequestPayload);
    return genericCommandRequest;
}
Also used : GenericCommandsRequestPayload(org.apache.apex.malhar.python.base.requestresponse.GenericCommandsRequestPayload) PythonInterpreterRequest(org.apache.apex.malhar.python.base.requestresponse.PythonInterpreterRequest)

Example 3 with GenericCommandsRequestPayload

use of org.apache.apex.malhar.python.base.requestresponse.GenericCommandsRequestPayload in project apex-malhar by apache.

the class BaseJEPTest method setCommonConstructsForRequestResponseObject.

private void setCommonConstructsForRequestResponseObject(PythonCommandType commandType, PythonInterpreterRequest request, PythonRequestResponse requestResponse) throws ApexPythonInterpreterException {
    request.setCommandType(commandType);
    requestResponse.setRequestStartTime(System.currentTimeMillis());
    requestResponse.setRequestId(1L);
    requestResponse.setWindowId(1L);
    switch(commandType) {
        case EVAL_COMMAND:
            EvalCommandRequestPayload payload = new EvalCommandRequestPayload();
            request.setEvalCommandRequestPayload(payload);
            break;
        case METHOD_INVOCATION_COMMAND:
            MethodCallRequestPayload methodCallRequest = new MethodCallRequestPayload();
            request.setMethodCallRequest(methodCallRequest);
            break;
        case SCRIPT_COMMAND:
            ScriptExecutionRequestPayload scriptPayload = new ScriptExecutionRequestPayload();
            request.setScriptExecutionRequestPayload(scriptPayload);
            break;
        case GENERIC_COMMANDS:
            GenericCommandsRequestPayload payloadForGenericCommands = new GenericCommandsRequestPayload();
            request.setGenericCommandsRequestPayload(payloadForGenericCommands);
            break;
        default:
            throw new ApexPythonInterpreterException("Unsupported command type");
    }
}
Also used : EvalCommandRequestPayload(org.apache.apex.malhar.python.base.requestresponse.EvalCommandRequestPayload) GenericCommandsRequestPayload(org.apache.apex.malhar.python.base.requestresponse.GenericCommandsRequestPayload) ScriptExecutionRequestPayload(org.apache.apex.malhar.python.base.requestresponse.ScriptExecutionRequestPayload) ApexPythonInterpreterException(org.apache.apex.malhar.python.base.ApexPythonInterpreterException) MethodCallRequestPayload(org.apache.apex.malhar.python.base.requestresponse.MethodCallRequestPayload)

Aggregations

GenericCommandsRequestPayload (org.apache.apex.malhar.python.base.requestresponse.GenericCommandsRequestPayload)3 PythonInterpreterRequest (org.apache.apex.malhar.python.base.requestresponse.PythonInterpreterRequest)2 ApexPythonInterpreterException (org.apache.apex.malhar.python.base.ApexPythonInterpreterException)1 EvalCommandRequestPayload (org.apache.apex.malhar.python.base.requestresponse.EvalCommandRequestPayload)1 MethodCallRequestPayload (org.apache.apex.malhar.python.base.requestresponse.MethodCallRequestPayload)1 ScriptExecutionRequestPayload (org.apache.apex.malhar.python.base.requestresponse.ScriptExecutionRequestPayload)1