Search in sources :

Example 1 with TrafficException

use of com.exalttech.trex.remote.exceptions.TrafficException in project trex-stateless-gui by cisco-system-traffic-generator.

the class MainViewController method doUpdateAssignedProfile.

/**
     * Update current port
     */
private void doUpdateAssignedProfile(int portIndex) {
    try {
        if (reAssign) {
            reAssign = false;
            String assignedProfile = String.valueOf(profileListBox.getValue());
            assignProfile(assignedProfile, multiplierView.getSliderValue(), true, portIndex);
        } else {
            serverRPCMethods.updateTraffic(portIndex, false, MultiplierType.pps.name(), multiplierView.getPPSValue());
            // update assigned profile multiplier
            AssignedProfile assignedProf = assignedPortProfileMap.get(portIndex);
            updateMultiplierValues(assignedProf);
        }
        updateHeaderBtnStat();
    } catch (TrafficException ex) {
        LOG.error("Error updating port", ex);
    }
    enableUpdateBtn(false, false);
}
Also used : AssignedProfile(com.exalttech.trex.ui.views.models.AssignedProfile) TrafficException(com.exalttech.trex.remote.exceptions.TrafficException)

Example 2 with TrafficException

use of com.exalttech.trex.remote.exceptions.TrafficException in project trex-stateless-gui by cisco-system-traffic-generator.

the class MainViewController method startTraffic.

/**
     * Start traffic on port
     *
     * @param portID
     */
private void startTraffic(int portID) {
    try {
        AssignedProfile assignedProf = assignedPortProfileMap.get(portID);
        if (assignedProf != null && assignedProf.isAllStreamsWithLatency()) {
            serverRPCMethods.startTraffic(portID, false, "percentage", 100, multiplierView.getDuration());
        } else {
            serverRPCMethods.startTraffic(portID, false, "pps", multiplierView.getPPSValue(), multiplierView.getDuration());
        }
        if (assignedProf != null) {
            assignedProf.setStreamStarted(true);
            assignedProf.setHasDuration(multiplierView.isDurationEnable());
            updateMultiplierValues(assignedProf);
        }
    } catch (TrafficException ex) {
        // re-enable start button in case of errors
        startStream.setDisable(false);
        LOG.error("Error starting traffic", ex);
    }
}
Also used : AssignedProfile(com.exalttech.trex.ui.views.models.AssignedProfile) TrafficException(com.exalttech.trex.remote.exceptions.TrafficException)

Example 3 with TrafficException

use of com.exalttech.trex.remote.exceptions.TrafficException 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 ex) {
        throw new TrafficException(ex.toString());
    }
}
Also used : 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 4 with TrafficException

use of com.exalttech.trex.remote.exceptions.TrafficException 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 ex) {
        throw new TrafficException(ex.toString());
    }
}
Also used : 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

TrafficException (com.exalttech.trex.remote.exceptions.TrafficException)4 IncorrectRPCMethodException (com.exalttech.trex.remote.exceptions.IncorrectRPCMethodException)2 InvalidRPCResponseException (com.exalttech.trex.remote.exceptions.InvalidRPCResponseException)2 Multiplier (com.exalttech.trex.remote.models.multiplier.Multiplier)2 AssignedProfile (com.exalttech.trex.ui.views.models.AssignedProfile)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2