Search in sources :

Example 1 with AROTraceData

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;
}
Also used : AbstractBestPracticeResult(com.att.aro.core.bestpractice.pojo.AbstractBestPracticeResult) TsharkException(com.att.aro.core.exception.TsharkException) PacketAnalyzerResult(com.att.aro.core.packetanalysis.pojo.PacketAnalyzerResult) AROTraceData(com.att.aro.core.pojo.AROTraceData)

Example 2 with AROTraceData

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;
}
Also used : FileNotFoundException(java.io.FileNotFoundException) TsharkException(com.att.aro.core.exception.TsharkException) ArrayList(java.util.ArrayList) List(java.util.List) PacketAnalyzerResult(com.att.aro.core.packetanalysis.pojo.PacketAnalyzerResult) AROTraceData(com.att.aro.core.pojo.AROTraceData)

Example 3 with AROTraceData

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());
}
Also used : Packet(com.att.aro.core.packetreader.pojo.Packet) ArrayList(java.util.ArrayList) PacketInfo(com.att.aro.core.packetanalysis.pojo.PacketInfo) BestPracticeType(com.att.aro.core.bestpractice.pojo.BestPracticeType) PacketAnalyzerResult(com.att.aro.core.packetanalysis.pojo.PacketAnalyzerResult) TraceFileResult(com.att.aro.core.packetanalysis.pojo.TraceFileResult) AROTraceData(com.att.aro.core.pojo.AROTraceData) BaseTest(com.att.aro.core.BaseTest) Test(org.junit.Test)

Example 4 with AROTraceData

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");
        }
    }
}
Also used : TraceDirectoryResult(com.att.aro.core.packetanalysis.pojo.TraceDirectoryResult) AROTraceData(com.att.aro.core.pojo.AROTraceData) IOException(java.io.IOException)

Example 5 with AROTraceData

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);
}
Also used : AROTraceData(com.att.aro.core.pojo.AROTraceData) TraceResultType(com.att.aro.core.packetanalysis.pojo.TraceResultType)

Aggregations

AROTraceData (com.att.aro.core.pojo.AROTraceData)24 BaseTest (com.att.aro.core.BaseTest)10 Test (org.junit.Test)10 ArrayList (java.util.ArrayList)9 IOException (java.io.IOException)8 PacketAnalyzerResult (com.att.aro.core.packetanalysis.pojo.PacketAnalyzerResult)6 BestPracticeType (com.att.aro.core.bestpractice.pojo.BestPracticeType)5 AnalysisFilter (com.att.aro.core.packetanalysis.pojo.AnalysisFilter)5 Profile (com.att.aro.core.configuration.pojo.Profile)4 PacketInfo (com.att.aro.core.packetanalysis.pojo.PacketInfo)4 IVideoBestPractices (com.att.aro.core.IVideoBestPractices)3 AbstractBestPracticeResult (com.att.aro.core.bestpractice.pojo.AbstractBestPracticeResult)3 TsharkException (com.att.aro.core.exception.TsharkException)3 TraceDirectoryResult (com.att.aro.core.packetanalysis.pojo.TraceDirectoryResult)3 Packet (com.att.aro.core.packetreader.pojo.Packet)3 File (java.io.File)3 IAROService (com.att.aro.core.IAROService)2 PeriodicTransferResult (com.att.aro.core.bestpractice.pojo.PeriodicTransferResult)2 IPacketAnalyzer (com.att.aro.core.packetanalysis.IPacketAnalyzer)2 Session (com.att.aro.core.packetanalysis.pojo.Session)2