Search in sources :

Example 6 with AROTraceData

use of com.att.aro.core.pojo.AROTraceData in project VideoOptimzer by attdevsupport.

the class AROController method runAnalyzer.

/**
 * <p>Note:  Do not use this method - use <em>updateModel(...)</em> instead.</p><p>
 *
 * Analyze a trace and produce a report either in json or html<br>
 *
 * @param trace The FQPN of the directory or pcap file to analyze
 * @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
 * @see #updateModel(String, Profile, AnalysisFilter)
 */
public AROTraceData runAnalyzer(String trace, Profile profile, AnalysisFilter filter) {
    serv = context.getBean(IAROService.class);
    AROTraceData results = new AROTraceData();
    long analysisStartTime = System.currentTimeMillis();
    try {
        // Request garbage collection before loading a trace
        System.gc();
        LOG.debug("\nAnalyze trace :" + trace);
        LOG.debug(String.format("\nTrace initial memory:%d free:%d", Runtime.getRuntime().totalMemory(), Runtime.getRuntime().freeMemory()));
        // analyze trace file or directory?
        try {
            if (serv.isFile(trace)) {
                results = serv.analyzeFile(retrieveBestPractices(), trace, profile, filter);
            } else {
                results = serv.analyzeDirectory(retrieveBestPractices(), trace, profile, filter);
            }
            if (results.getAnalyzerResult() != null && results.getAnalyzerResult().getStreamingVideoData() != null && !results.getAnalyzerResult().getStreamingVideoData().isFinished()) {
                StreamingVideoData streamingVideoData = results.getAnalyzerResult().getStreamingVideoData();
                if (!streamingVideoData.getVideoStreamMap().isEmpty()) {
                    Runnable waitingForUpdate = () -> {
                        int count = 1;
                        while (!streamingVideoData.isFinished()) {
                            LOG.debug(String.format("(%d) Waiting for FFmpegRunner to complete", count++));
                            Util.sleep(1000);
                        }
                        Util.sleep(1000);
                        SwingUtilities.invokeLater(new Runnable() {

                            @Override
                            public void run() {
                                analyzeVideoBP();
                            }
                        });
                    };
                    new Thread(waitingForUpdate, "waitingForUpdate").start();
                }
            }
        } catch (OutOfMemoryError err) {
            LOG.error(err.getMessage(), err);
            results = new AROTraceData();
            results.setSuccess(false);
            results.setError(ErrorCodeRegistry.getOutOfMemoryError());
        }
    } catch (IOException exception) {
        LOG.error(exception.getMessage(), exception);
        results.setSuccess(false);
        results.setError(ErrorCodeRegistry.getUnknownFileFormat());
    }
    LOG.debug(String.format("\n%s\nTrace Analysis Elapsed time: %.6f sec.", trace, (double) (System.currentTimeMillis() - analysisStartTime) / 1000));
    LOG.debug(String.format("\nTrace analysis completed memory:%d free:%d", Runtime.getRuntime().totalMemory(), Runtime.getRuntime().freeMemory()));
    return results;
}
Also used : IAROService(com.att.aro.core.IAROService) StreamingVideoData(com.att.aro.core.videoanalysis.pojo.StreamingVideoData) IOException(java.io.IOException) AROTraceData(com.att.aro.core.pojo.AROTraceData)

Example 7 with AROTraceData

use of com.att.aro.core.pojo.AROTraceData in project VideoOptimzer by attdevsupport.

the class VideoChunksPlot method refreshBPVideoResults.

private AROTraceData refreshBPVideoResults(AROTraceData model, AbstractBestPracticeResult bpResult, AbstractBestPracticeResult stallBPResult, AbstractBestPracticeResult bufferOccupancyBPResult) {
    removeList.clear();
    AROTraceData trace = model;
    for (AbstractBestPracticeResult bp : model.getBestPracticeResults()) {
        if (bp.getBestPracticeType() == BestPracticeType.STARTUP_DELAY) {
            updateAbstractBestPracticeParameters(bp, bpResult, model.getBestPracticeResults().indexOf(bp));
        } else if (stallBPResult != null && bp.getBestPracticeType() == BestPracticeType.VIDEO_STALL) {
            updateAbstractBestPracticeParameters(bp, stallBPResult, model.getBestPracticeResults().indexOf(bp));
        } else if (bufferOccupancyBPResult != null && bp.getBestPracticeType() == BestPracticeType.BUFFER_OCCUPANCY) {
            updateAbstractBestPracticeParameters(bp, bufferOccupancyBPResult, model.getBestPracticeResults().indexOf(bp));
        }
    }
    if (!removeList.isEmpty()) {
        for (int index : removeList.keySet()) {
            AbstractBestPracticeResult bp = removeList.get(index);
            trace.getBestPracticeResults().remove(bp);
            AbstractBestPracticeResult result = null;
            if (bp.getBestPracticeType() == BestPracticeType.STARTUP_DELAY) {
                result = bpResult;
            } else if (bp.getBestPracticeType() == BestPracticeType.VIDEO_STALL) {
                result = stallBPResult;
            } else if (bp.getBestPracticeType() == BestPracticeType.BUFFER_OCCUPANCY) {
                result = bufferOccupancyBPResult;
            }
            trace.getBestPracticeResults().add(index, result);
        }
    }
    return trace;
}
Also used : AbstractBestPracticeResult(com.att.aro.core.bestpractice.pojo.AbstractBestPracticeResult) AROTraceData(com.att.aro.core.pojo.AROTraceData)

Example 8 with AROTraceData

use of com.att.aro.core.pojo.AROTraceData in project VideoOptimzer by attdevsupport.

the class StartupDelayDialog method launchStartupCalculations.

/**
 * @param startupTime
 */
public void launchStartupCalculations(double startupTime) {
    try {
        if (startupTime >= segmentChosen.getVideoEvent().getEndTS() && segmentChosen.isSelected()) {
            if (videoStreamStartup != null) {
                videoStreamStartup.setValidationStartup(ValidationStartup.USER);
            }
            if (!allUserEventList.isEmpty()) {
                segmentChosen.getVideoEvent().setPlayRequestedTime(Double.valueOf(playRequestedTime.getText()));
                videoStream.setPlayRequestedTime(Double.valueOf(playRequestedTime.getText()));
            }
            saveStartupDelay(startupTime, segmentChosen.getVideoEvent(), videoStream, userEventChosen);
            videoSegmentAnalyzer.applyStartupDelayToStream(startupTime, segmentChosen.getVideoEvent(), videoStream, streamingVideoData);
            AROTraceData aroTraceData = mainFrame.getController().getTheModel();
            IVideoBestPractices videoBestPractices = ContextAware.getAROConfigContext().getBean(IVideoBestPractices.class);
            videoBestPractices.analyze(aroTraceData);
            getGraphPanel().setTraceData(aroTraceData);
            VideoManifestPanel videoManifestPanel = segmentTablePanel.getVideoManifestPanel();
            videoManifestPanel.refresh(segmentTablePanel.getAnalyzerResult());
            mainFrame.refreshBestPracticesTab();
            destroy();
        }
    } catch (Exception ex) {
        LOG.error("Error generating video chunk and buffer plots", ex);
        MessageDialogFactory.showMessageDialog(parentPanel, "Error in drawing buffer graphs", "Failed to generate buffer plots", JOptionPane.ERROR_MESSAGE);
    }
}
Also used : VideoManifestPanel(com.att.aro.ui.view.videotab.VideoManifestPanel) IVideoBestPractices(com.att.aro.core.IVideoBestPractices) AROTraceData(com.att.aro.core.pojo.AROTraceData)

Example 9 with AROTraceData

use of com.att.aro.core.pojo.AROTraceData in project VideoOptimzer by attdevsupport.

the class SliderDialogBox method getSetButtonListener.

public ActionListener getSetButtonListener(final VideoChunksPlot vcPlot) {
    return new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            ComboManifest comboBoxItem = (ComboManifest) jcb.getSelectedItem();
            if (segmentChosen != null && segmentChosen.isSelected && (comboBoxItem.getVideoStream() != null)) {
                dispose();
                try {
                    LOGGER.info("startTimeField :" + startTimeField.getText());
                    setStartTime(Double.valueOf(startTimeField.getText()));
                } catch (NumberFormatException e1) {
                // covers user entered bad data, just go with getStartTime()
                }
                try {
                    if (getStartTime() >= segmentChosen.getVideoEvent().getEndTS() && segmentChosen.isSelected) {
                        ComboManifest selectedStream = (ComboManifest) jcb.getSelectedItem();
                        if (selectedStream.getVideoStream() != null) {
                            VideoStream videoStream = selectedStream.getVideoStream();
                            segmentChosen.getVideoEvent().setPlayTime(getStartTime());
                            videoStream.getManifest().setDelay(getStartTime() - segmentChosen.getVideoEvent().getEndTS());
                            videoStream.getManifest().setStartupVideoEvent(segmentChosen.getVideoEvent());
                            videoStream.getManifest().setStartupDelay(segmentChosen.getVideoEvent().getSegmentStartTime() - videoStream.getManifest().getRequestTime());
                            LOGGER.info(String.format("Segment playTime = %.03f", segmentChosen.getVideoEvent().getPlayTime()));
                            startTimeField.setText(String.format("%.03f", segmentChosen.getVideoEvent().getPlayTime()));
                            revalidate();
                            for (VideoStream stream : streamingVideoData.getVideoStreamMap().values()) {
                                if (stream.equals(videoStream)) {
                                    stream.setSelected(true);
                                } else {
                                    stream.setSelected(false);
                                }
                            }
                        } else {
                            for (VideoStream stream : streamingVideoData.getVideoStreamMap().values()) {
                                if (stream.isSelected()) {
                                    stream.getManifest().setDelay(getStartTime() - segmentChosen.getVideoEvent().getEndTS());
                                }
                            }
                        }
                        AROTraceData aroTraceData = mainFrame.getController().getTheModel();
                        streamingVideoData.scanVideoStreams();
                        IVideoBestPractices videoBestPractices = ContextAware.getAROConfigContext().getBean(IVideoBestPractices.class);
                        videoBestPractices.analyze(aroTraceData);
                        mainFrame.getDiagnosticTab().getGraphPanel().refresh(aroTraceData);
                        getGraphPanel().setTraceData(aroTraceData);
                        AROTraceData traceData = vcPlot.refreshPlot(getGraphPanel().getSubplotMap().get(ChartPlotOptions.VIDEO_CHUNKS).getPlot(), getGraphPanel().getTraceData(), getStartTime(), segmentChosen.getVideoEvent());
                        getGraphPanel().setTraceData(traceData);
                        mainFrame.getVideoTab().refresh(traceData);
                    }
                } catch (Exception ex) {
                    LOGGER.error("Error generating video chunk and buffer plots", ex);
                    MessageDialogFactory.showMessageDialog(parentPanel, "Error in drawing buffer graphs", "Failed to generate buffer plots", JOptionPane.ERROR_MESSAGE);
                }
            } else {
                showWarningMessage();
            }
        }
    };
}
Also used : ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) IVideoBestPractices(com.att.aro.core.IVideoBestPractices) VideoStream(com.att.aro.core.videoanalysis.pojo.VideoStream) AROTraceData(com.att.aro.core.pojo.AROTraceData)

Example 10 with AROTraceData

use of com.att.aro.core.pojo.AROTraceData in project VideoOptimzer by attdevsupport.

the class HtmlReportImplTest method reportGenerator_retunrIsTrue.

@Test
@Ignore
public void reportGenerator_retunrIsTrue() {
    AccessingPeripheralResult access = new AccessingPeripheralResult();
    access.setResultType(BPResultType.PASS);
    CacheControlResult cache = new CacheControlResult();
    cache.setResultType(BPResultType.FAIL);
    List<AbstractBestPracticeResult> bpResults = new ArrayList<AbstractBestPracticeResult>();
    bpResults.add(access);
    bpResults.add(cache);
    File tempFile = null;
    try {
        tempFile = folder.newFile("abc.html");
    } catch (IOException e) {
        e.printStackTrace();
    }
    if (tempFile != null) {
        tempFile.deleteOnExit();
    }
    when(filereader.createFile(any(String.class))).thenReturn(tempFile);
    AROTraceData results = new AROTraceData();
    PacketAnalyzerResult analyzerResult = new PacketAnalyzerResult();
    TraceDirectoryResult tracedirresult = new TraceDirectoryResult();
    EnergyModel energyModel = new EnergyModel();
    Statistic statistic = new Statistic();
    statistic.setTotalByte(123);
    statistic.setTotalHTTPSByte(123);
    tracedirresult.setTraceDirectory("temp.txt");
    analyzerResult.setTraceresult(tracedirresult);
    analyzerResult.setEnergyModel(energyModel);
    analyzerResult.setStatistic(statistic);
    results.setAnalyzerResult(analyzerResult);
    results.setBestPracticeResults(bpResults);
    assertTrue(htmlReportImpl.reportGenerator("abc.html", results));
}
Also used : EnergyModel(com.att.aro.core.packetanalysis.pojo.EnergyModel) AbstractBestPracticeResult(com.att.aro.core.bestpractice.pojo.AbstractBestPracticeResult) ArrayList(java.util.ArrayList) IOException(java.io.IOException) AROTraceData(com.att.aro.core.pojo.AROTraceData) AccessingPeripheralResult(com.att.aro.core.bestpractice.pojo.AccessingPeripheralResult) Statistic(com.att.aro.core.packetanalysis.pojo.Statistic) TraceDirectoryResult(com.att.aro.core.packetanalysis.pojo.TraceDirectoryResult) PacketAnalyzerResult(com.att.aro.core.packetanalysis.pojo.PacketAnalyzerResult) CacheControlResult(com.att.aro.core.bestpractice.pojo.CacheControlResult) File(java.io.File) Ignore(org.junit.Ignore) BaseTest(com.att.aro.core.BaseTest) Test(org.junit.Test)

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