Search in sources :

Example 16 with Profile

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

the class MainViewController method loadStreamTable.

/**
     * View YAML file stream table data
     *
     * @param fileName
     */
private void loadStreamTable(String fileName) {
    try {
        File selectedFile = new File(ProfileManager.getInstance().getProfileFilePath(fileName));
        loadedProfiles = tableView.loadStreamTable(selectedFile);
        allStreamWithLatency = false;
        if (loadedProfiles.length > 0) {
            allStreamWithLatency = true;
            for (Profile profile : loadedProfiles) {
                allStreamWithLatency = allStreamWithLatency && profile.getStream().getFlowStats().isEnabled();
            }
        }
        multiplierView.setDisable(allStreamWithLatency);
        notificationPanelHolder.setVisible(allStreamWithLatency);
    } catch (Exception ex) {
        LOG.error("Error loading stream table", ex);
    }
}
Also used : File(java.io.File) Profile(com.exalttech.trex.remote.models.profiles.Profile) AssignedProfile(com.exalttech.trex.ui.views.models.AssignedProfile) 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 17 with Profile

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

the class TrafficProfile method convertProfilesToTableData.

/**
     * Convert profiles to equivalent tableProfile data
     *
     * @param profilesList
     * @return
     */
public List<TableProfileStream> convertProfilesToTableData(Profile[] profilesList) {
    List<TableProfileStream> tableData = new ArrayList<>();
    for (int index = 0; index < profilesList.length; index++) {
        Profile p = profilesList[index];
        TableProfileStream stream = new TableProfileStream();
        Mode modeYaml = p.getStream().getMode();
        stream.setIndex(String.valueOf(index + 1));
        stream.setEnabled(p.getStream().isEnabled());
        stream.setName(p.getName());
        stream.setMode(modeYaml.getType());
        String rateUnits = "";
        switch(modeYaml.getRate().getType()) {
            case Rate.RateTypes.PPS:
                rateUnits = "pps";
                break;
            case Rate.RateTypes.BPS_L1:
                rateUnits = "bps L1";
                break;
            case Rate.RateTypes.BPS_L2:
                rateUnits = "bps L2";
                break;
            case Rate.RateTypes.PERCENTAGE:
                rateUnits = "%";
                break;
        }
        stream.setRate(Util.formattedData((long) modeYaml.getRate().getValue(), true) + rateUnits);
        stream.setNextStream(getNextStreamValue(p.getNext()));
        String packetBinary = p.getStream().getPacket().getBinary();
        String packetModel = p.getStream().getPacket().getModel();
        stream.setPcapBinary(packetBinary);
        stream.setPktModel(packetModel);
        PacketInfo packetInfo = getPacketInfo(packetBinary);
        stream.setLength(String.valueOf(packetInfo.getLength() + Constants.EXTRA_BYTE));
        stream.setPacketType(packetInfo.getType());
        tableData.add(stream);
    }
    return tableData;
}
Also used : TableProfileStream(com.exalttech.trex.ui.views.models.TableProfileStream) Mode(com.exalttech.trex.remote.models.profiles.Mode) ArrayList(java.util.ArrayList) PacketInfo(com.exalttech.trex.remote.models.profiles.PacketInfo) Profile(com.exalttech.trex.remote.models.profiles.Profile)

Example 18 with Profile

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

the class TrafficProfile method prepareTrafficProfile.

/**
     *
     * @param trafficProfileArray
     * @param portID
     * @param handler
     * @return
     * @throws java.lang.Exception
     */
public Profile[] prepareTrafficProfile(Profile[] trafficProfileArray, int portID, String handler) throws Exception {
    Map<String, Integer> mapStreamToInteger = convertStreamNameToInteger(trafficProfileArray);
    ObjectMapper mapper = new ObjectMapper();
    String profileJsonString = mapper.writeValueAsString(trafficProfileArray);
    Profile[] updatedProfileArray = mapper.readValue(profileJsonString, Profile[].class);
    for (int i = 0; i < updatedProfileArray.length; i++) {
        Profile trafficProfile = updatedProfileArray[i];
        Profile originalProfile = trafficProfileArray[i];
        trafficProfile.setStreamId(mapStreamToInteger.get(trafficProfile.getName()));
        if (!"-1".equals(trafficProfile.getNext())) {
            trafficProfile.getStream().setNextStreamId(mapStreamToInteger.get(trafficProfile.getNext()));
        }
        trafficProfile.setName(null);
        trafficProfile.setNext(null);
        trafficProfile.getStream().getPacket().setPcap(null);
        String vm = (!originalProfile.getStream().getVmRaw().isEmpty() && !"[]".equals(originalProfile.getStream().getVmRaw())) ? originalProfile.getStream().getVmRaw() : "{\n" + "                    \"instructions\": [],\n" + "                    \"split_by_var\": \"\"\n" + "                }";
        String rx = (!originalProfile.getStream().getRxStatsRaw().isEmpty() && !"[]".equals(originalProfile.getStream().getRxStatsRaw())) ? originalProfile.getStream().getRxStatsRaw() : "{\n" + "                    \"enabled\": false\n" + "                }";
        trafficProfile.getStream().setVmRaw(vm);
        trafficProfile.getStream().setRxStatsRaw(rx);
        trafficProfile.setHandler(handler);
        trafficProfile.setPortId(portID);
        updatedProfileArray[i] = trafficProfile;
    }
    return updatedProfileArray;
}
Also used : ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Profile(com.exalttech.trex.remote.models.profiles.Profile)

Aggregations

Profile (com.exalttech.trex.remote.models.profiles.Profile)18 TrafficProfile (com.exalttech.trex.util.TrafficProfile)8 File (java.io.File)6 IOException (java.io.IOException)6 TableProfile (com.exalttech.trex.ui.views.models.TableProfile)5 TableProfileStream (com.exalttech.trex.ui.views.models.TableProfileStream)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 DialogWindow (com.exalttech.trex.ui.dialog.DialogWindow)2 Alert (javafx.scene.control.Alert)2 Window (javafx.stage.Window)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 Mode (com.exalttech.trex.remote.models.profiles.Mode)1 PacketInfo (com.exalttech.trex.remote.models.profiles.PacketInfo)1 AssignedProfile (com.exalttech.trex.ui.views.models.AssignedProfile)1 ImportPcapTableData (com.exalttech.trex.ui.views.models.ImportPcapTableData)1 YAMLFactory (com.fasterxml.jackson.dataformat.yaml.YAMLFactory)1 EOFException (java.io.EOFException)1