Search in sources :

Example 1 with Multiplier

use of com.exalttech.trex.remote.models.multiplier.Multiplier in project trex-stateless-gui by cisco-system-traffic-generator.

the class RPCMethods method startTraffic.

/**
 * @param portID
 * @param force
 * @param type
 * @param multiplierValue
 * @param duration
 * @return multiplier value from the server
 * @throws com.exalttech.trex.remote.exceptions.TrafficException
 */
public double startTraffic(int portID, boolean force, String type, double multiplierValue, double duration) throws TrafficException {
    LogsController.getInstance().appendText(LogType.INFO, "Starting Traffic on Port " + portID);
    String handler = (String) connectionHandler.get(portID);
    Multiplier trafficMultiplier = new Multiplier(type, multiplierValue);
    TrafficParams trafficParams = new TrafficParams(force, handler, trafficMultiplier, portID);
    trafficParams.setDuration(duration);
    try {
        String updateTrafficResponse = serverConnectionManager.sendRPCRequest(Constants.START_TRAFFIC_METHOD, trafficParams);
        LOG.trace("Start Traffic response:" + updateTrafficResponse);
        return getMultiplierValue(updateTrafficResponse);
    } catch (JsonProcessingException | UnsupportedEncodingException | InvalidRPCResponseException | IncorrectRPCMethodException | NullPointerException | SizeLimitExceededException ex) {
        throw new TrafficException(ex.toString());
    }
}
Also used : SizeLimitExceededException(javax.naming.SizeLimitExceededException) Multiplier(com.exalttech.trex.remote.models.multiplier.Multiplier) UnsupportedEncodingException(java.io.UnsupportedEncodingException) IncorrectRPCMethodException(com.exalttech.trex.remote.exceptions.IncorrectRPCMethodException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) InvalidRPCResponseException(com.exalttech.trex.remote.exceptions.InvalidRPCResponseException) TrafficException(com.exalttech.trex.remote.exceptions.TrafficException)

Example 2 with Multiplier

use of com.exalttech.trex.remote.models.multiplier.Multiplier in project trex-stateless-gui by cisco-system-traffic-generator.

the class RPCMethods method updateTraffic.

/**
 * @param portID
 * @param force
 * @param type
 * @param multiplierValue
 * @return multiplier value from the server
 * @throws com.exalttech.trex.remote.exceptions.TrafficException
 */
public double updateTraffic(int portID, boolean force, String type, double multiplierValue) throws TrafficException {
    LOG.trace("Updating Traffic on port(s) [" + portID + "], setting to " + multiplierValue + " pps");
    LogsController.getInstance().appendText(LogType.INFO, "Updating Traffic on port(s) [" + portID + "], setting to " + multiplierValue + " pps");
    Multiplier trafficMultiplier = new Multiplier(type, multiplierValue);
    String handler = (String) connectionHandler.get(portID);
    TrafficParams trafficParams = new TrafficParams(force, handler, trafficMultiplier, portID);
    try {
        String updateTrafficResponse = serverConnectionManager.sendRPCRequest(Constants.UPDATE_TRAFFIC_METHOD, trafficParams);
        return getMultiplierValue(updateTrafficResponse);
    } catch (JsonProcessingException | UnsupportedEncodingException | InvalidRPCResponseException | IncorrectRPCMethodException | NullPointerException | SizeLimitExceededException ex) {
        throw new TrafficException(ex.toString());
    }
}
Also used : SizeLimitExceededException(javax.naming.SizeLimitExceededException) Multiplier(com.exalttech.trex.remote.models.multiplier.Multiplier) UnsupportedEncodingException(java.io.UnsupportedEncodingException) IncorrectRPCMethodException(com.exalttech.trex.remote.exceptions.IncorrectRPCMethodException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) InvalidRPCResponseException(com.exalttech.trex.remote.exceptions.InvalidRPCResponseException) TrafficException(com.exalttech.trex.remote.exceptions.TrafficException)

Aggregations

IncorrectRPCMethodException (com.exalttech.trex.remote.exceptions.IncorrectRPCMethodException)2 InvalidRPCResponseException (com.exalttech.trex.remote.exceptions.InvalidRPCResponseException)2 TrafficException (com.exalttech.trex.remote.exceptions.TrafficException)2 Multiplier (com.exalttech.trex.remote.models.multiplier.Multiplier)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 SizeLimitExceededException (javax.naming.SizeLimitExceededException)2