use of com.exalttech.trex.remote.models.common.RPCRequest in project trex-stateless-gui by cisco-system-traffic-generator.
the class ConnectionManager method sendRPCRequest.
/**
*
* @param method
* @param params
* @return
* @throws JsonProcessingException
* @throws UnsupportedEncodingException
* @throws InvalidRPCResponseException
* @throws IncorrectRPCMethodException
*/
public String sendRPCRequest(String method, Params params) throws JsonProcessingException, UnsupportedEncodingException, InvalidRPCResponseException, IncorrectRPCMethodException {
RPCRequest rpcRequest = new RPCRequest();
ObjectMapper mapper = new ObjectMapper();
rpcRequest.setId(Util.getRandomID(Constants.RPC_REQUEST_ID_LENGTH));
rpcRequest.setMethod(method);
if (params != null) {
rpcRequest.setParams(params);
}
String jsonRequestString = mapper.writeValueAsString(rpcRequest);
jsonRequestString = Util.tuneJSONParams(jsonRequestString, params, apiH);
LOG.trace("Sending request \n" + Util.toPrettyFormat(jsonRequestString));
logProperty.setValue("Sending request " + Util.toPrettyFormat(jsonRequestString));
byte[] serverResponse = getServerRPCResponse(jsonRequestString);
return handleResponse(serverResponse, true);
}
use of com.exalttech.trex.remote.models.common.RPCRequest in project trex-stateless-gui by cisco-system-traffic-generator.
the class ConnectionManager method sendPortXStatsValuesRequest.
/**
* Send request for port status
*
* @param port
* @return
* @throws JsonProcessingException
* @throws UnsupportedEncodingException
* @throws IncorrectRPCMethodException
* @throws InvalidRPCResponseException
*/
public String sendPortXStatsValuesRequest(Port port) throws JsonProcessingException, UnsupportedEncodingException, IncorrectRPCMethodException, InvalidRPCResponseException {
List<String> addStreamCommandList = new ArrayList<>();
ObjectMapper mapper = new ObjectMapper();
RPCRequest rpcRequest = new RPCRequest();
String jsonRequestString;
rpcRequest.setId(Util.getRandomID(Constants.RPC_REQUEST_ID_LENGTH));
rpcRequest.setMethod(Constants.PORT_XSTATS_VALUES_METHOD);
rpcRequest.setParams(port.getPortParam());
jsonRequestString = mapper.writeValueAsString(rpcRequest);
jsonRequestString = Util.tuneJSONParams(jsonRequestString, port.getPortParam(), apiH);
addStreamCommandList.add(jsonRequestString);
String requestCommand = Util.toPrettyFormat(addStreamCommandList.toString());
LOG.info("Send port xstats_values request \n " + requestCommand);
byte[] serverResponse = getServerRPCResponse(addStreamCommandList.toString());
return handleResponse(serverResponse, false, true);
}
use of com.exalttech.trex.remote.models.common.RPCRequest in project trex-stateless-gui by cisco-system-traffic-generator.
the class ConnectionManager method sendPortStatusRequest.
/**
* Send request for port status
*
* @param portList
* @return
* @throws JsonProcessingException
* @throws UnsupportedEncodingException
* @throws IncorrectRPCMethodException
* @throws InvalidRPCResponseException
*/
public String sendPortStatusRequest(List<Port> portList) throws JsonProcessingException, UnsupportedEncodingException, IncorrectRPCMethodException, InvalidRPCResponseException {
List<String> addStreamCommandList = new ArrayList<>();
ObjectMapper mapper = new ObjectMapper();
RPCRequest rpcRequest = new RPCRequest();
String jsonRequestString;
for (Port port : portList) {
rpcRequest.setId(Util.getRandomID(Constants.RPC_REQUEST_ID_LENGTH));
rpcRequest.setMethod(Constants.PORT_STATUS_METHOD);
rpcRequest.setParams(port.getPortParam());
jsonRequestString = mapper.writeValueAsString(rpcRequest);
jsonRequestString = Util.tuneJSONParams(jsonRequestString, port.getPortParam(), apiH);
addStreamCommandList.add(jsonRequestString);
}
String requestCommand = Util.toPrettyFormat(addStreamCommandList.toString());
LOG.info("Send port status request \n " + requestCommand);
byte[] serverResponse = getServerRPCResponse(addStreamCommandList.toString());
return handleResponse(serverResponse, false);
}
use of com.exalttech.trex.remote.models.common.RPCRequest in project trex-stateless-gui by cisco-system-traffic-generator.
the class ConnectionManager method sendPortXStatsNamesRequest.
/**
* Send request for port status
*
* @param port
* @return
* @throws JsonProcessingException
* @throws UnsupportedEncodingException
* @throws IncorrectRPCMethodException
* @throws InvalidRPCResponseException
*/
public String sendPortXStatsNamesRequest(Port port) throws JsonProcessingException, UnsupportedEncodingException, IncorrectRPCMethodException, InvalidRPCResponseException {
List<String> addStreamCommandList = new ArrayList<>();
ObjectMapper mapper = new ObjectMapper();
RPCRequest rpcRequest = new RPCRequest();
String jsonRequestString;
rpcRequest.setId(Util.getRandomID(Constants.RPC_REQUEST_ID_LENGTH));
rpcRequest.setMethod(Constants.PORT_XSTATS_NAMES_METHOD);
rpcRequest.setParams(port.getPortParam());
jsonRequestString = mapper.writeValueAsString(rpcRequest);
jsonRequestString = Util.tuneJSONParams(jsonRequestString, port.getPortParam(), apiH);
addStreamCommandList.add(jsonRequestString);
String requestCommand = Util.toPrettyFormat(addStreamCommandList.toString());
LOG.info("Send port xstats_names request \n " + requestCommand);
byte[] serverResponse = getServerRPCResponse(addStreamCommandList.toString());
return handleResponse(serverResponse, false);
}
use of com.exalttech.trex.remote.models.common.RPCRequest in project trex-stateless-gui by cisco-system-traffic-generator.
the class ConnectionManager method sendAddStreamRequest.
/**
*
* @param profilesList
* @return
* @throws JsonProcessingException
* @throws UnsupportedEncodingException
* @throws IncorrectRPCMethodException
* @throws InvalidRPCResponseException
*/
public String sendAddStreamRequest(Profile[] profilesList) throws JsonProcessingException, UnsupportedEncodingException, IncorrectRPCMethodException, InvalidRPCResponseException {
List<String> addStreamCommandList = new ArrayList<>();
ObjectMapper mapper = new ObjectMapper();
RPCRequest rpcRequest = new RPCRequest();
String jsonRequestString;
for (int i = 0; i < profilesList.length; i++) {
rpcRequest.setId(Util.getRandomID(Constants.RPC_REQUEST_ID_LENGTH));
rpcRequest.setMethod(Constants.ADD_STREAM_METHOD);
rpcRequest.setParams(profilesList[i]);
jsonRequestString = mapper.writeValueAsString(rpcRequest);
jsonRequestString = Util.tuneJSONParams(jsonRequestString, profilesList[i], apiH);
addStreamCommandList.add(jsonRequestString);
}
String requestCommand = Util.toPrettyFormat(addStreamCommandList.toString());
LOG.info(requestCommand);
logProperty.setValue("Sending request " + requestCommand);
byte[] serverResponse = getServerRPCResponse(addStreamCommandList.toString());
return handleResponse(serverResponse, false);
}
Aggregations