Search in sources :

Example 1 with AbstractBestPracticeResult

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

the class AROServiceImpl method createEmptyResults.

private List<AbstractBestPracticeResult> createEmptyResults() {
    List<BestPracticeType> allBP = Arrays.asList(BestPracticeType.values());
    List<BestPracticeType> selected = SettingsUtil.retrieveBestPractices();
    Function<? super BestPracticeType, ? extends AbstractBestPracticeResult> resMapper = (bp) -> {
        AbstractBestPracticeResult res = new AbstractBestPracticeResult() {

            @Override
            public BestPracticeType getBestPracticeType() {
                return bp;
            }
        };
        res.setResultType(BPResultType.NONE);
        res.setDetailTitle(res.getBestPracticeType().getDescription());
        res.setOverviewTitle(res.getBestPracticeType().getDescription());
        return res;
    };
    List<AbstractBestPracticeResult> results = allBP.stream().filter((bp) -> bp.getCategory() != Category.PRE_PROCESS && !selected.contains(bp)).map(resMapper).collect(Collectors.toList());
    return results;
}
Also used : Arrays(java.util.Arrays) AnalysisFilter(com.att.aro.core.packetanalysis.pojo.AnalysisFilter) TsharkException(com.att.aro.core.exception.TsharkException) IFileManager(com.att.aro.core.fileio.IFileManager) AROTraceData(com.att.aro.core.pojo.AROTraceData) Autowired(org.springframework.beans.factory.annotation.Autowired) Category(com.att.aro.core.bestpractice.pojo.BestPracticeType.Category) VersionInfo(com.att.aro.core.pojo.VersionInfo) Function(java.util.function.Function) ArrayList(java.util.ArrayList) Value(org.springframework.beans.factory.annotation.Value) AbstractBestPracticeResult(com.att.aro.core.bestpractice.pojo.AbstractBestPracticeResult) Logger(org.apache.log4j.Logger) GoogleAnalyticsUtil(com.att.aro.core.util.GoogleAnalyticsUtil) SettingsUtil(com.att.aro.core.settings.SettingsUtil) Qualifier(org.springframework.beans.factory.annotation.Qualifier) PacketAnalyzerResult(com.att.aro.core.packetanalysis.pojo.PacketAnalyzerResult) ErrorCodeRegistry(com.att.aro.core.pojo.ErrorCodeRegistry) Profile(com.att.aro.core.configuration.pojo.Profile) BPResultType(com.att.aro.core.bestpractice.pojo.BPResultType) IAROService(com.att.aro.core.IAROService) Util(com.att.aro.core.util.Util) IOException(java.io.IOException) Collectors(java.util.stream.Collectors) FileNotFoundException(java.io.FileNotFoundException) BestPracticeType(com.att.aro.core.bestpractice.pojo.BestPracticeType) List(java.util.List) ICacheAnalysis(com.att.aro.core.packetanalysis.ICacheAnalysis) IBestPractice(com.att.aro.core.bestpractice.IBestPractice) IReport(com.att.aro.core.report.IReport) IPacketAnalyzer(com.att.aro.core.packetanalysis.IPacketAnalyzer) LogManager(org.apache.log4j.LogManager) AbstractBestPracticeResult(com.att.aro.core.bestpractice.pojo.AbstractBestPracticeResult) BestPracticeType(com.att.aro.core.bestpractice.pojo.BestPracticeType)

Example 2 with AbstractBestPracticeResult

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

the class AROServiceImpl method analyze.

/**
 * Performs BestPractice tests identified in the requests
 * List&lt;BestPracticeType&gt; requests.<br>
 * Test results are added to a resultList, ArrayList&lt;IBestPractice&gt;
 *
 * @param result
 *            a PacketAnalyzerResult object
 * @param requests
 *            a List of BestPracticeType
 * @return ArrayList&lt;IBestPractice&gt; or null if result was null
 */
@Override
public List<AbstractBestPracticeResult> analyze(PacketAnalyzerResult result, List<BestPracticeType> requests) {
    if (result == null) {
        return null;
    }
    List<AbstractBestPracticeResult> resultlist = new ArrayList<AbstractBestPracticeResult>();
    IBestPractice worker = null;
    if (requests.contains(BestPracticeType.USING_CACHE) || requests.contains(BestPracticeType.CACHE_CONTROL) || requests.contains(BestPracticeType.DUPLICATE_CONTENT)) {
        this.createCacheAnalysis(result);
    }
    for (BestPracticeType type : requests) {
        worker = getBPWorker(type);
        if (worker != null) {
            try {
                long bpStartTime = System.currentTimeMillis();
                resultlist.add(worker.runTest(result));
                GoogleAnalyticsUtil.getGoogleAnalyticsInstance().sendAnalyticsTimings(type.getDescription(), System.currentTimeMillis() - bpStartTime, bpTimingsTitle);
            } catch (Exception | Error ex) {
                LOGGER.error("Error running best practice " + type.getDescription() + " : ", ex);
                new Thread(() -> sendExceptiontoGA(type)).start();
            }
        }
    }
    for (AbstractBestPracticeResult testresult : resultlist) {
        sendGABPResult(testresult);
    }
    return resultlist;
}
Also used : IBestPractice(com.att.aro.core.bestpractice.IBestPractice) AbstractBestPracticeResult(com.att.aro.core.bestpractice.pojo.AbstractBestPracticeResult) ArrayList(java.util.ArrayList) BestPracticeType(com.att.aro.core.bestpractice.pojo.BestPracticeType) TsharkException(com.att.aro.core.exception.TsharkException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException)

Example 3 with AbstractBestPracticeResult

use of com.att.aro.core.bestpractice.pojo.AbstractBestPracticeResult 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 4 with AbstractBestPracticeResult

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

the class HtmlReportImpl method getBPSummaryRows.

private String getBPSummaryRows(List<AbstractBestPracticeResult> bpResults) {
    int pass = 0;
    int fail = 0;
    int warning = 0;
    int selftest = 0;
    for (AbstractBestPracticeResult result : bpResults) {
        if (result.getResultType() == BPResultType.PASS) {
            pass++;
        } else if (result.getResultType() == BPResultType.FAIL) {
            fail++;
        } else if (result.getResultType() == BPResultType.WARNING) {
            warning++;
        } else if (result.getResultType() == BPResultType.SELF_TEST) {
            selftest++;
        }
    }
    StringBuilder sBuilder = new StringBuilder(160);
    sBuilder.append(tableLIne() + "<th>Best Practices Passed</th><td>" + pass + tableChange() + System.getProperty(lineSeperator()) + tableLIne() + "<th>Best Practices Failed</th><td>" + fail + tableChange() + System.getProperty(lineSeperator()) + tableLIne() + "<th>Best Practices with Warnings</th><td>" + warning + tableLIne() + "<th>Best Practices with Self Test</th><td>" + selftest + tableChange() + System.getProperty(lineSeperator()));
    return sBuilder.toString();
}
Also used : AbstractBestPracticeResult(com.att.aro.core.bestpractice.pojo.AbstractBestPracticeResult)

Example 5 with AbstractBestPracticeResult

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

the class HtmlReportImpl method reportGenerator.

@Override
public boolean reportGenerator(String resultFilePath, AROTraceData results) {
    if (results == null) {
        return false;
    }
    PacketAnalyzerResult analyzerResults = results.getAnalyzerResult();
    List<AbstractBestPracticeResult> bpResults = results.getBestPracticeResults();
    StringBuilder htmlString = new StringBuilder(200);
    htmlString.append(getHtmlHead());
    htmlString.append("	<body>");
    htmlString.append(System.getProperty(lineSeperator()));
    htmlString.append("		<table class='table'>");
    htmlString.append(System.getProperty(lineSeperator()));
    htmlString.append(getTableHeader(analyzerResults));
    htmlString.append(getTraceRows(analyzerResults));
    htmlString.append(getTimeRangeAnalysisAndStatisticRows(analyzerResults));
    htmlString.append(getBPSummaryRows(bpResults));
    htmlString.append("<tr><th></th><td></td></tr><tr><th>Best Practices Results</th><td></td></tr>\n");
    htmlString.append(getBpRows(bpResults));
    htmlString.append("		</table>");
    htmlString.append(System.getProperty(lineSeperator()));
    htmlString.append(System.getProperty(lineSeperator()));
    htmlString.append("	</body>");
    htmlString.append(System.getProperty(lineSeperator()));
    htmlString.append("</html>");
    try {
        File file = filereader.createFile(resultFilePath);
        PrintWriter writer = new PrintWriter(file);
        writer.println(htmlString.toString());
        writer.close();
        return true;
    } catch (IOException e) {
        LOGGER.info("IOException: " + e);
    }
    return false;
}
Also used : AbstractBestPracticeResult(com.att.aro.core.bestpractice.pojo.AbstractBestPracticeResult) PacketAnalyzerResult(com.att.aro.core.packetanalysis.pojo.PacketAnalyzerResult) IOException(java.io.IOException) File(java.io.File) PrintWriter(java.io.PrintWriter)

Aggregations

AbstractBestPracticeResult (com.att.aro.core.bestpractice.pojo.AbstractBestPracticeResult)66 BaseTest (com.att.aro.core.BaseTest)47 ArrayList (java.util.ArrayList)47 Test (org.junit.Test)47 Session (com.att.aro.core.packetanalysis.pojo.Session)33 HttpRequestResponseInfo (com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo)29 PacketAnalyzerResult (com.att.aro.core.packetanalysis.pojo.PacketAnalyzerResult)17 Burst (com.att.aro.core.packetanalysis.pojo.Burst)8 BestPracticeType (com.att.aro.core.bestpractice.pojo.BestPracticeType)6 CacheEntry (com.att.aro.core.packetanalysis.pojo.CacheEntry)6 List (java.util.List)6 IBestPractice (com.att.aro.core.bestpractice.IBestPractice)5 BPResultType (com.att.aro.core.bestpractice.pojo.BPResultType)4 UnnecessaryConnectionResult (com.att.aro.core.bestpractice.pojo.UnnecessaryConnectionResult)4 BufferOccupancyResult (com.att.aro.core.bestpractice.pojo.BufferOccupancyResult)3 TsharkException (com.att.aro.core.exception.TsharkException)3 BurstCollectionAnalysisData (com.att.aro.core.packetanalysis.pojo.BurstCollectionAnalysisData)3 TraceDirectoryResult (com.att.aro.core.packetanalysis.pojo.TraceDirectoryResult)3 AROTraceData (com.att.aro.core.pojo.AROTraceData)3 IOException (java.io.IOException)3