use of com.att.aro.core.pojo.AROTraceData in project VideoOptimzer by attdevsupport.
the class AROServiceImpl method analyzeFile.
/**
* Launches an analysis of a traceFile with the results populating an
* AROTraceData object
*
* @param requests
* list of BestPracticeType bestPractices to analyze
* @param traceFile
* path to a pcap trace file, usually traffic.cap
* @param profile
* device profile used as a model of the device when analyzing
* trace data
* @param filter
* used for filtering information from a trace analysis based on
* a specified time range and set of ApplicationSelection
* objects.
* @return AROTraceData object
* @throws IOException
* if trace file not found
*/
@Override
public AROTraceData analyzeFile(List<BestPracticeType> requests, String traceFile, Profile profile, AnalysisFilter filter) throws IOException {
AROTraceData data = new AROTraceData();
try {
PacketAnalyzerResult result = packetanalyzer.analyzeTraceFile(traceFile, profile, filter);
if (result == null) {
data.setError(ErrorCodeRegistry.getTraceFileNotAnalyzed());
} else {
if (result.getTraceresult().getAllpackets().size() == 0) {
// we set on purpose
data.setError(ErrorCodeRegistry.getUnRecognizedPackets());
data.setSuccess(false);
} else {
List<AbstractBestPracticeResult> bestPractices = analyze(result, requests);
bestPractices.addAll(createEmptyResults());
data.setAnalyzerResult(result);
data.setBestPracticeResults(bestPractices);
data.setSuccess(true);
}
}
} catch (TsharkException ex) {
data.setError(ErrorCodeRegistry.getWiresharkError());
}
return data;
}
use of com.att.aro.core.pojo.AROTraceData in project VideoOptimzer by attdevsupport.
the class AROServiceImpl method analyzeDirectory.
/**
* Launches an analysis of a trace directory with the results populating an
* AROTraceData object.
* <p>
* Other trace files depend on capture method, platform and version of
* device.
* </p>
*
* @param requests
* list of BestPracticeType bestPractices to analyze
* @param traceDirectory
* path to a trace directory, usually contains traffic.cap
* @param profile
* device profile used as a model of the device when analyzing
* trace data
* @param filter
* used for filtering information from a trace analysis based on
* a specified time range and set of ApplicationSelection
* objects.
* @return AROTraceData object
* @throws IOException
* if trace file not found
*/
@Override
public AROTraceData analyzeDirectory(List<BestPracticeType> requests, String traceDirectory, Profile profile, AnalysisFilter filter) throws IOException {
AROTraceData data = new AROTraceData();
PacketAnalyzerResult result = null;
if (!filemanager.fileExist(traceDirectory + Util.FILE_SEPARATOR + "traffic.cap")) {
data.setError(ErrorCodeRegistry.getTrafficFileNotFound());
data.setSuccess(false);
} else {
try {
result = packetanalyzer.analyzeTraceDirectory(traceDirectory, profile, filter);
} catch (FileNotFoundException ex) {
data.setError(ErrorCodeRegistry.getTraceDirNotFound());
return data;
} catch (TsharkException ex) {
data.setError(ErrorCodeRegistry.getWiresharkError());
return data;
}
if (result == null) {
data.setError(ErrorCodeRegistry.getTraceDirectoryNotAnalyzed());
data.setSuccess(false);
} else {
if (result.getTraceresult() == null) {
// we set this on purpose
data.setSuccess(false);
data.setError(ErrorCodeRegistry.getUnRecognizedPackets());
} else if (result.getTraceresult().getAllpackets() == null || result.getTraceresult().getAllpackets().size() == 0) {
data.setSuccess(false);
data.setError(ErrorCodeRegistry.getPacketsNotFound());
} else {
List<AbstractBestPracticeResult> bestPractices = analyze(result, requests);
bestPractices.addAll(createEmptyResults());
data.setAnalyzerResult(result);
data.setBestPracticeResults(bestPractices);
data.setSuccess(true);
}
}
}
return data;
}
use of com.att.aro.core.pojo.AROTraceData in project VideoOptimzer by attdevsupport.
the class AROServiceImplTest method analyzeFileNullTest.
@Test
public void analyzeFileNullTest() throws IOException {
PacketAnalyzerResult analyze = new PacketAnalyzerResult();
TraceFileResult traceresult = new TraceFileResult();
List<PacketInfo> allpackets = new ArrayList<PacketInfo>();
allpackets.add(new PacketInfo(new Packet(0, 0, 0, 0, null)));
analyze.setTraceresult(traceresult);
List<BestPracticeType> req = new ArrayList<BestPracticeType>();
req.add(BestPracticeType.UNNECESSARY_CONNECTIONS);
AROTraceData testResult = aro.analyzeFile(req, "traffic.cap");
assertEquals(null, testResult.getBestPracticeResults());
}
use of com.att.aro.core.pojo.AROTraceData in project VideoOptimzer by attdevsupport.
the class MainFrame method refresh.
public void refresh() {
if (aroController != null) {
AROTraceData traceData = aroController.getTheModel();
if (traceData.isSuccess()) {
try {
modelObserver.refreshModel(traceData);
this.profile = traceData.getAnalyzerResult().getProfile();
if (traceData.getAnalyzerResult().getTraceresult().getTraceResultType() == TraceResultType.TRACE_DIRECTORY) {
TraceDirectoryResult traceResults = (TraceDirectoryResult) traceData.getAnalyzerResult().getTraceresult();
(new Thread(() -> sendGATraceParams(traceResults))).start();
Util.updateRecentItem(traceResults.getTraceDirectory());
frmApplicationResourceOptimizer.setJMenuBar(mainMenu.getAROMainFileMenu());
frmApplicationResourceOptimizer.getJMenuBar().updateUI();
}
} catch (OutOfMemoryError err) {
LOG.error("Out of memory exception after a successful trace analysis", err);
Util.restart(true);
}
} else if (traceData.getError() != null) {
LOG.info("Error code details: " + traceData.getError());
if (isUpdateRequired(traceData.getError().getCode())) {
Util.updateRecentItem(tracePath);
}
tracePath = null;
if (aroSwingWorker != null) {
aroSwingWorker.cancel(true);
try {
Thread.sleep(150);
} catch (Exception exc) {
LOG.info("Thread sleep exception");
}
}
if (ErrorCodeEnum.OUT_OF_MEMEORY.getCode() == traceData.getError().getCode()) {
Util.restart(true);
} else {
MessageDialogFactory.getInstance().showErrorDialog(window.getJFrame(), traceData.getError().getDescription());
}
} else {
showErrorMessage("menu.error.unknownfileformat");
}
}
}
use of com.att.aro.core.pojo.AROTraceData in project VideoOptimzer by attdevsupport.
the class VideoPlayerController method update.
@Override
public void update(Observable observable, Object model) {
traceResult = ((AROTraceData) model).getAnalyzerResult().getTraceresult();
TraceResultType traceResultType = traceResult.getTraceResultType();
traceDirectory = traceResult.getTraceDirectory();
if (traceDirectory == null) {
LOGGER.error("Trace dir is null, error launching video player.");
return;
}
if (traceResultType == TraceResultType.TRACE_FILE || !(VideoUtil.mp4VideoExists(traceDirectory) || VideoUtil.movVideoExists(traceDirectory))) {
currentPlayer.clear();
currentPlayer.notifyLauncher(false);
return;
}
IVideoPlayer player = getPlayer(VideoPlayerType.MP4_VLCJ);
;
if (player == null) {
LOGGER.error("Error launching video player - no appropriate Mp4 or Mov player found");
return;
}
player.loadVideo(traceResult);
diagnosticsTab.setVideoPlayer(player);
setCurrentVideoPlayer(player);
player.notifyLauncher(true);
}
Aggregations