use of com.att.aro.core.pojo.AROTraceData in project VideoOptimzer by attdevsupport.
the class AROController method updateModel.
/**
* <p>
* This is the main entry point for requesting an analysis of a trace.
* </p>
* <p>
*
* <em>path</em> is the file or folder containing the trace raw data if we load tracefile , the path include the file name ex, ......\traffic.cap if we load
* tracefolder, the path include the folder name ex, .....\tracefolder
*
* @param path Where the trace directory or .cap file is located
* @param profile The Profile to use for this analysis - LTE if null
* @param filter The filters to use - can be empty for no filtering specified
*/
public void updateModel(String path, Profile profile, AnalysisFilter filter) {
try {
if (path != null) {
AROTraceData model = runAnalyzer(path, profile, filter);
if (!model.isSuccess()) {
AROTraceData tempModel = theModel;
theModel = model;
theView.refresh();
theModel = tempModel;
} else {
theModel = model;
if (filter == null) {
// when the first loading traces, set the filter
initializeFilter();
} else if (filter.getDomainNames() == null || filter.getDomainNames().isEmpty()) {
/*
* For when there is a TimeRange added to an otherwise empty AnalysisFilter.
* Caused by the analysis flow from opening a trace with an active timerange.json selection
* see: AROController.propertyChange(PropertyChangeEvent)
*/
initializeFilter(filter.getTimeRange());
}
theView.refresh();
}
}
} catch (Exception ex) {
LOG.info("Error Log:" + ex.getMessage());
LOG.error("Exception : ", ex);
}
(new Thread(() -> GoogleAnalyticsUtil.reportMimeDataType(theModel))).start();
}
use of com.att.aro.core.pojo.AROTraceData in project VideoOptimzer by attdevsupport.
the class DataDump method startDataDump.
/**
* Starts dumping data in CSV file for the provided trace files.
*
* @param traceFolders
* - List of trace folder names.
* @return A FileWriter object.
* @throws IOException
*/
private FileWriter startDataDump(List<File> traceFolders) throws IOException, ProfileException {
FileWriter writer = new FileWriter(fileToSave);
try {
List<File> validFolderList = new ArrayList<File>();
Set<AROTraceData> analysis = new LinkedHashSet<AROTraceData>();
getValidFolderList(traceFolders, validFolderList);
for (File traceDirectory : validFolderList) {
try {
analysis.add(controller.runAnalyzer(traceDirectory.getAbsolutePath(), controller.getTheModel().getAnalyzerResult().getProfile(), null));
} catch (Exception e) {
LOG.warn("Unable to run analysis on folder: " + traceDirectory, e);
}
}
try {
new ObjectMapper().writeValue(fileToSave, analysis);
} catch (JsonGenerationException e) {
LOG.error(e.getMessage());
new MessageDialogFactory().showUnexpectedExceptionDialog(MSG_WINDOW, e);
} catch (JsonMappingException e) {
LOG.error(e.getMessage());
new MessageDialogFactory().showUnexpectedExceptionDialog(MSG_WINDOW, e);
} catch (IOException e) {
LOG.error(e.getMessage());
new MessageDialogFactory().showUnexpectedExceptionDialog(MSG_WINDOW, e);
}
userPreferences.setLastTraceDirectory(traceDir);
} finally {
writer.close();
}
return writer;
}
use of com.att.aro.core.pojo.AROTraceData in project VideoOptimzer by attdevsupport.
the class GraphPanel method filterFlowTable.
// In 4.1.1, the method called refreshGraph()
public void filterFlowTable() {
AROTraceData filteredSessionTraceData = getTraceData();
double filteredStartTime = 0.0;
double filteredEndTime = 0.0;
double filteredDuration = filteredSessionTraceData.getAnalyzerResult().getTraceresult().getTraceDuration();
List<Session> tcpsessionsList = new ArrayList<Session>();
if (getTraceData() == null) {
return;
} else {
TCPUDPFlowsTableModel model = (TCPUDPFlowsTableModel) parent.getJTCPFlowsTable().getModel();
Map<String, Session> subSessionMap = model.getSessionMap();
Map<String, Boolean> subcheckboxMap = model.getCheckboxMap();
for (Map.Entry<String, Boolean> entry : subcheckboxMap.entrySet()) {
if (entry.getValue()) {
tcpsessionsList.add(subSessionMap.get(entry.getKey()));
}
}
filteredSessionTraceData.getAnalyzerResult().setSessionlist(tcpsessionsList);
}
List<PacketInfo> packetsForSelectedSession = new ArrayList<PacketInfo>();
for (Session tcpSession : tcpsessionsList) {
if (tcpSession.getTcpPackets() != null) {
packetsForSelectedSession.addAll(tcpSession.getTcpPackets());
}
}
// when generating graph, make sure session is ordered by time stamp
Collections.sort(packetsForSelectedSession, new Comparator<PacketInfo>() {
@Override
public int compare(PacketInfo p1, PacketInfo p2) {
return (int) (p1.getTimeStamp() * 1000 - p2.getTimeStamp() * 1000);
}
});
boolean selectedAllPackets = false;
// Adding the TCP packets to the trace for getting redoing the analysis
if (packetsForSelectedSession.size() > 0) {
if (tcpsessionsList.size() == getAllTcpSessions()) {
// For select all use all exiting packets
filteredSessionTraceData.getAnalyzerResult().getTraceresult().setAllpackets(getAllPackets());
selectedAllPackets = true;
} else {
// Collections.sort(packetsForSelectedSession);//?
filteredSessionTraceData.getAnalyzerResult().getTraceresult().setAllpackets(packetsForSelectedSession);
}
}
if (selectedAllPackets) {
filteredStartTime = -0.01;
filteredEndTime = filteredDuration;
} else {
int index = 0;
for (Session tcpSession : tcpsessionsList) {
if (tcpSession.getTcpPackets().size() != 0) {
if (index == 0) {
filteredStartTime = tcpSession.getTcpPackets().get(0).getTimeStamp();
filteredEndTime = tcpSession.getTcpPackets().get(0).getTimeStamp();
}
if (filteredStartTime > tcpSession.getTcpPackets().get(0).getTimeStamp()) {
filteredStartTime = tcpSession.getTcpPackets().get(0).getTimeStamp();
}
if (filteredEndTime < tcpSession.getTcpPackets().get(0).getTimeStamp()) {
filteredEndTime = tcpSession.getTcpPackets().get(0).getTimeStamp();
}
index++;
}
}
if (index == 0) {
filteredStartTime = 0.0;
filteredEndTime = 0.0;
}
}
// for Analysis data particular time of the graph, some number is not clear..
if (filteredStartTime > 0) {
// adjust the time line axis number
filteredStartTime = filteredStartTime - 2;
if (filteredStartTime < 0) {
filteredStartTime = -0.01;
}
}
if (filteredStartTime < 0) {
filteredStartTime = -0.01;
}
if (!selectedAllPackets) {
if (filteredEndTime > 0) {
// adjust the time line axis number
filteredEndTime = filteredEndTime + 15;
}
if (filteredEndTime > filteredDuration) {
filteredEndTime = filteredDuration;
}
}
this.startTime = filteredStartTime;
this.endTime = filteredEndTime;
if (getTraceData() != null) {
TimeRange timeRange = new TimeRange(filteredStartTime, filteredEndTime);
AnalysisFilter filter = filteredSessionTraceData.getAnalyzerResult().getFilter();
filter.setTimeRange(timeRange);
filteredSessionTraceData.getAnalyzerResult().setFilter(filter);
Statistic stat = ContextAware.getAROConfigContext().getBean(IPacketAnalyzer.class).getStatistic(packetsForSelectedSession);
long totaltemp = 0;
for (Session byteCountSession : tcpsessionsList) {
totaltemp += byteCountSession.getBytesTransferred();
}
stat.setTotalByte(totaltemp);
AbstractRrcStateMachine statemachine = ContextAware.getAROConfigContext().getBean(IRrcStateMachineFactory.class).create(packetsForSelectedSession, filteredSessionTraceData.getAnalyzerResult().getProfile(), stat.getPacketDuration(), filteredDuration, stat.getTotalByte(), timeRange);
BurstCollectionAnalysisData burstcollectiondata = new BurstCollectionAnalysisData();
if (stat.getTotalByte() > 0) {
burstcollectiondata = ContextAware.getAROConfigContext().getBean(IBurstCollectionAnalysis.class).analyze(packetsForSelectedSession, filteredSessionTraceData.getAnalyzerResult().getProfile(), stat.getPacketSizeToCountMap(), statemachine.getStaterangelist(), filteredSessionTraceData.getAnalyzerResult().getTraceresult().getUserEvents(), filteredSessionTraceData.getAnalyzerResult().getTraceresult().getCpuActivityList().getCpuActivities(), tcpsessionsList);
}
filteredSessionTraceData.getAnalyzerResult().getStatistic().setTotalByte(stat.getTotalByte());
filteredSessionTraceData.getAnalyzerResult().setStatemachine(statemachine);
filteredSessionTraceData.getAnalyzerResult().setBurstCollectionAnalysisData(burstcollectiondata);
refresh(filteredSessionTraceData);
}
}
use of com.att.aro.core.pojo.AROTraceData in project VideoOptimzer by attdevsupport.
the class AROToolMenu method openPcapAnalysis.
private void openPcapAnalysis() {
// Open PCAP analysis tool
AROTraceData traceData = ((MainFrame) parent).getController().getTheModel();
IFileManager fileManager = ContextAware.getAROConfigContext().getBean(IFileManager.class);
File dir = fileManager.createFile(traceData.getAnalyzerResult().getTraceresult().getTraceDirectory());
File[] trafficFiles;
if (fileManager.isFile(dir.getAbsolutePath())) {
trafficFiles = new File[] { new File(dir.getAbsolutePath()) };
} else {
trafficFiles = getTrafficTextFiles(dir);
}
if (trafficFiles != null && trafficFiles.length > 0) {
try {
for (File trafficFile : trafficFiles) {
if (trafficFile.getName().equals(TraceDataConst.FileName.PCAP_FILE)) {
Desktop.getDesktop().open(trafficFile);
break;
}
}
} catch (NullPointerException e) {
MessageDialogFactory.showMessageDialog(((MainFrame) parent).getJFrame(), ResourceBundleHelper.getMessageString("menu.tools.error.noPcap"));
} catch (IllegalArgumentException e) {
MessageDialogFactory.showMessageDialog(((MainFrame) parent).getJFrame(), ResourceBundleHelper.getMessageString("menu.tools.error.noPcap"));
} catch (IOException e) {
MessageDialogFactory.showMessageDialog(((MainFrame) parent).getJFrame(), ResourceBundleHelper.getMessageString("menu.tools.error.noPcapApp"));
}
}
}
use of com.att.aro.core.pojo.AROTraceData in project VideoOptimzer by attdevsupport.
the class Application method runAnalyzer.
/**
* Analyze a trace and produce a report either in json or html<br>
*
* <pre>
* Required command:
* --analyze with path to trace directory of traffic.cap
* --output output file, error if missing
* --format html or json, if missing defaults to json
*
* @param context
* - Spring ApplicationContext
* @param cmds
* - user commands
*/
void runAnalyzer(ApplicationContext context, Commands cmds) {
String trace = cmds.getAnalyze();
IAROService serv = context.getBean(IAROService.class);
AROTraceData results = null;
// analyze trace file or directory?
OutSave outSave = prepareSystemOut();
ImHereThread imHereThread = new ImHereThread(outSave.getOut(), Logger.getRootLogger());
try {
if (serv.isFile(trace)) {
try {
results = serv.analyzeFile(retrieveBestPractices(), trace);
} catch (IOException | TsharkException e) {
errln("Error occured analyzing trace, detail: " + e.getMessage());
System.exit(1);
}
} else {
try {
results = serv.analyzeDirectory(retrieveBestPractices(), trace);
} catch (IOException e) {
errln("Error occured analyzing trace directory, detail: " + e.getMessage());
System.exit(1);
}
}
if (results != null && results.isSuccess()) {
outSave = prepareSystemOut();
if (cmds.getFormat().equals("json")) {
if (serv.getJSonReport(cmds.getOutput(), results)) {
outln("Successfully produced JSON report: " + cmds.getOutput());
} else {
errln("Failed to produce JSON report.");
}
} else {
if (serv.getHtmlReport(cmds.getOutput(), results)) {
println("Successfully produced HTML report: " + cmds.getOutput());
} else {
errln("Failed to produce HTML report.");
}
}
} else {
printError(results == null ? new ErrorCode() : results.getError());
}
} finally {
imHereThread.endIndicator();
while (imHereThread.isRunning()) {
Thread.yield();
}
restoreSystemOut(outSave);
}
System.exit(0);
}
Aggregations