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;
}
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;
}
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");
}
}
Aggregations