Search in sources :

Example 6 with PythonInterpreterRequest

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

the class PythonRequestResponseUtil method buildRequestForMethodCallCommand.

/**
 * Builds the request object for the Method call command. See
 * {@link ApexPythonEngine#executeMethodCall(WorkerExecutionMode, long, long, PythonInterpreterRequest)} for details
 * @param methodName Name of the method
 * @param methodParams parames to the method
 * @param timeOut Time allocated for completing the API
 * @param timeUnit The units of time
 * @param clazz The Class that represents the return type
 * @param <T> Java templating signature
 * @return The request object that can be used for method calls
 */
public static <T> PythonInterpreterRequest<T> buildRequestForMethodCallCommand(String methodName, List<Object> methodParams, long timeOut, TimeUnit timeUnit, Class<T> clazz) {
    PythonInterpreterRequest<T> request = new PythonInterpreterRequest<>(clazz);
    MethodCallRequestPayload methodCallRequestPayload = new MethodCallRequestPayload();
    methodCallRequestPayload.setNameOfMethod(methodName);
    methodCallRequestPayload.setArgs(methodParams);
    request.setTimeUnit(timeUnit);
    request.setTimeout(timeOut);
    request.setMethodCallRequest(methodCallRequestPayload);
    return request;
}
Also used : MethodCallRequestPayload(org.apache.apex.malhar.python.base.requestresponse.MethodCallRequestPayload) PythonInterpreterRequest(org.apache.apex.malhar.python.base.requestresponse.PythonInterpreterRequest)

Aggregations

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