Search in sources :

Example 1 with StreamValidation

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

the class MainViewController method assignProfile.

/**
 * Assign profile to selected port
 *
 * @param profileName
 */
private void assignProfile(String profileName, double currentBandwidth, boolean assignPrevBandwidth, int portID) {
    try {
        // update selected profile
        AssignedProfile assignedProf = assignedPortProfileMap.get(portID);
        if (assignedProf == null) {
            return;
        }
        assignedProf.setProfileName(profileName);
        assignedProf.setAllStreamsWithLatency(allStreamWithLatency);
        PortModel port = PortsManager.getInstance().getPortModel(portID);
        String portState = port.getPortStatus();
        StreamValidation streamValidationGraph = serverRPCMethods.assignTrafficProfile(portID, loadedProfiles);
        portManager.getPortModel(portID).setStreamLoaded(true);
        startStream.setDisable(false);
        // update current multiplier data
        assignedProf.setRate(streamValidationGraph.getResult().getRate());
        multiplierView.assignNewProfile(assignedProf);
        // update multiplier value according to previous bandwidth value
        if (assignPrevBandwidth) {
            multiplierView.setSliderValue(currentBandwidth);
        }
        updateMultiplierValues(assignedProf);
        if (portState.equalsIgnoreCase("tx")) {
            startTraffic(portID);
        }
    } catch (IOException | InvalidRPCResponseException | IncorrectRPCMethodException ex) {
        startStream.setDisable(true);
        portManager.getPortModel(portID).setStreamLoaded(false);
        LOG.error("Failed to load Stream", ex);
    } catch (Exception ex) {
        java.util.logging.Logger.getLogger(MainViewController.class.getName()).log(Level.SEVERE, null, ex);
    } finally {
        portManager.updatedPorts(Arrays.asList(portID));
    }
}
Also used : AssignedProfile(com.exalttech.trex.ui.views.models.AssignedProfile) PortModel(com.exalttech.trex.ui.models.PortModel) IOException(java.io.IOException) StreamValidation(com.exalttech.trex.remote.models.validate.StreamValidation) IncorrectRPCMethodException(com.exalttech.trex.remote.exceptions.IncorrectRPCMethodException) InvalidRPCResponseException(com.exalttech.trex.remote.exceptions.InvalidRPCResponseException) TrafficException(com.exalttech.trex.remote.exceptions.TrafficException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) InvalidRPCResponseException(com.exalttech.trex.remote.exceptions.InvalidRPCResponseException) IncorrectRPCMethodException(com.exalttech.trex.remote.exceptions.IncorrectRPCMethodException) PortAcquireException(com.exalttech.trex.remote.exceptions.PortAcquireException) IOException(java.io.IOException)

Example 2 with StreamValidation

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

the class RPCMethods method validateStream.

/**
 * @param portID
 * @return true if the methods was executed successfully , false otherwise
 * @throws java.lang.Exception
 */
public StreamValidation validateStream(int portID) throws Exception {
    LOG.trace("Validating Stream on port(s) [" + portID + "]:");
    LogsController.getInstance().appendText(LogType.INFO, "Validating Stream on port(s) [" + portID + "]:");
    String handler = (String) connectionHandler.get(portID);
    CommonParams params = new CommonParams(portID, handler);
    ObjectMapper mapper = new ObjectMapper();
    String response = serverConnectionManager.sendRPCRequest(Constants.VALIDATE_METHOD, params);
    response = Util.removeFirstBrackets(response);
    StreamValidation streamValidationResponse = mapper.readValue(response, StreamValidation.class);
    LOG.trace("Stream Validation response :" + streamValidationResponse.getResult().getRate().toString());
    LogsController.getInstance().appendText(LogType.INFO, "Stream Validation response :" + streamValidationResponse.getResult().getRate().toString());
    return streamValidationResponse;
}
Also used : StreamValidation(com.exalttech.trex.remote.models.validate.StreamValidation) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Aggregations

StreamValidation (com.exalttech.trex.remote.models.validate.StreamValidation)2 IncorrectRPCMethodException (com.exalttech.trex.remote.exceptions.IncorrectRPCMethodException)1 InvalidRPCResponseException (com.exalttech.trex.remote.exceptions.InvalidRPCResponseException)1 PortAcquireException (com.exalttech.trex.remote.exceptions.PortAcquireException)1 TrafficException (com.exalttech.trex.remote.exceptions.TrafficException)1 PortModel (com.exalttech.trex.ui.models.PortModel)1 AssignedProfile (com.exalttech.trex.ui.views.models.AssignedProfile)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 IOException (java.io.IOException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1