Search in sources :

Example 1 with IBestPractice

use of com.att.aro.core.bestpractice.IBestPractice 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)

Aggregations

IBestPractice (com.att.aro.core.bestpractice.IBestPractice)1 AbstractBestPracticeResult (com.att.aro.core.bestpractice.pojo.AbstractBestPracticeResult)1 BestPracticeType (com.att.aro.core.bestpractice.pojo.BestPracticeType)1 TsharkException (com.att.aro.core.exception.TsharkException)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1