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);
}
}
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;
}
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;
}
Aggregations