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;
}
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<BestPracticeType> requests.<br>
* Test results are added to a resultList, ArrayList<IBestPractice>
*
* @param result
* a PacketAnalyzerResult object
* @param requests
* a List of BestPracticeType
* @return ArrayList<IBestPractice> 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;
}
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;
}
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();
}
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;
}
Aggregations