use of com.att.aro.core.packetanalysis.pojo.Session in project VideoOptimzer by attdevsupport.
the class UnsecureSSLVersionImpl method runTest.
@Override
public AbstractBestPracticeResult runTest(PacketAnalyzerResult tracedata) {
Set<UnsecureSSLVersionEntry> entries = new HashSet<>();
try {
List<Session> sessions = tracedata.getSessionlist();
for (Session session : sessions) {
Set<String> unsecureSSLVersions = getUnsecureSSLVersionsInSession(session);
if (!unsecureSSLVersions.isEmpty()) {
String unsecureSSLVersionsStr = stringifyUnsecureSSLVersions(unsecureSSLVersions);
UnsecureSSLVersionEntry entry = populateEntry(session, unsecureSSLVersionsStr);
entries.add(entry);
}
}
} catch (Exception e) {
LOGGER.error("Error happened when running unsecure SSL Versions test :: Caused by: " + e.getMessage());
}
return getTestResult(entries);
}
use of com.att.aro.core.packetanalysis.pojo.Session in project VideoOptimzer by attdevsupport.
the class ScriptsImpl method runTest.
@Override
public AbstractBestPracticeResult runTest(PacketAnalyzerResult tracedata) {
ScriptsResult result = new ScriptsResult();
for (Session session : tracedata.getSessionlist()) {
for (HttpRequestResponseInfo req : session.getRequestResponseInfo()) {
if (req.getDirection() == HttpDirection.RESPONSE && req.getContentLength() > 0 && req.getContentType() != null && reqhelper.isHtml(req.getContentType())) {
result = analyzeHtml(req, session, result);
}
}
}
String text = "";
if (result.getFirstFailedHtml() == null) {
result.setResultType(BPResultType.PASS);
text = MessageFormat.format(textResultPass, result.getNumberOfFailedFiles());
result.setResultText(text);
result.setResultExcelText(BPResultType.PASS.getDescription());
} else {
result.setResultType(BPResultType.FAIL);
text = MessageFormat.format(textResults, ApplicationConfig.getInstance().getAppShortName(), result.getNumberOfFailedFiles());
result.setResultText(text);
result.setResultExcelText(MessageFormat.format(textExcelResults, BPResultType.FAIL.getDescription(), result.getNumberOfFailedFiles()));
}
result.setAboutText(aboutText);
result.setDetailTitle(detailTitle);
result.setLearnMoreUrl(learnMoreUrl);
result.setOverviewTitle(overviewTitle);
result.setExportAllNumberOfScriptsFiles(exportAllNumberOfScriptsFiles);
return result;
}
use of com.att.aro.core.packetanalysis.pojo.Session in project VideoOptimzer by attdevsupport.
the class Http4xx5xxImpl method runTest.
@Override
public AbstractBestPracticeResult runTest(PacketAnalyzerResult tracedata) {
Http4xx5xxResult result = new Http4xx5xxResult();
Map<Integer, HttpRequestResponseInfo> firstErrorRespMap4XX = new HashMap<Integer, HttpRequestResponseInfo>();
SortedMap<Integer, Integer> httpErrorCounts4XX = new TreeMap<Integer, Integer>();
List<Http4xx5xxStatusResponseCodesEntry> httpResCodelist = new ArrayList<Http4xx5xxStatusResponseCodesEntry>();
HttpRequestResponseInfo lastRequestObj = null;
for (Session session : tracedata.getSessionlist()) {
lastRequestObj = null;
for (HttpRequestResponseInfo req : session.getRequestResponseInfo()) {
if (req.getDirection() == HttpDirection.REQUEST) {
lastRequestObj = req;
}
if (req.getDirection() == HttpDirection.RESPONSE && HttpRequestResponseInfo.HTTP_SCHEME.equals(req.getScheme()) && req.getStatusCode() >= 400 && req.getStatusCode() < 600) {
Integer code = req.getStatusCode();
Integer count = httpErrorCounts4XX.get(code);
if (count != null) {
httpErrorCounts4XX.put(code, count + 1);
} else {
httpErrorCounts4XX.put(code, 1);
firstErrorRespMap4XX.put(code, req);
}
httpResCodelist.add(new Http4xx5xxStatusResponseCodesEntry(req, lastRequestObj, session.getDomainName()));
}
}
}
if (httpErrorCounts4XX.isEmpty()) {
result.setResultType(BPResultType.PASS);
result.setResultText(textResultPass);
result.setResultExcelText(BPResultType.PASS.getDescription());
} else {
result.setResultType(BPResultType.FAIL);
result.setResultText(Http3xx4xxHelper.createFailResult(httpErrorCounts4XX, textResults, errorPlural, errorSingular));
result.setResultExcelText(MessageFormat.format(textExcelResults, BPResultType.FAIL.getDescription(), Http3xx4xxHelper.formatErrorCodesToText(httpErrorCounts4XX)));
}
result.setAboutText(aboutText);
result.setDetailTitle(detailTitle);
result.setLearnMoreUrl(learnMoreUrl);
result.setOverviewTitle(overviewTitle);
result.setExportAllHttpError(exportAllHttpError);
result.setFirstErrorRespMap4XX(firstErrorRespMap4XX);
result.setHttpErrorCounts4XX(httpErrorCounts4XX);
result.setHttpResCodelist(httpResCodelist);
return result;
}
use of com.att.aro.core.packetanalysis.pojo.Session in project VideoOptimzer by attdevsupport.
the class ImageCompressionImpl method compressImages.
private void compressImages() {
ExecutorService exec = Executors.newFixedThreadPool(5);
for (final Session session : packetResult.getSessionlist()) {
for (final HttpRequestResponseInfo req : session.getRequestResponseInfo()) {
if (req.getDirection() == HttpDirection.RESPONSE && req.getContentType() != null && req.getContentType().contains("image/")) {
String extractedImage = ImageHelper.extractFullNameFromRRInfo(req);
if ((!extractedImage.isEmpty() && !(extractedImage.contains(".jpeg") || extractedImage.contains(".jpg"))) && req.getContentType().contains("jpeg")) {
extractedImage = Util.parseImageName(extractedImage, req);
}
File imgFile = new File(imageFolderPath + extractedImage);
if (imgFile.exists() && !imgFile.isDirectory()) {
int posExtn = extractedImage.lastIndexOf(".");
String imgExtn = extractedImage.substring(posExtn + 1, extractedImage.length());
if (Util.isJPG(imgFile, imgExtn)) {
final String imageFile = extractedImage;
exec.submit(new Runnable() {
@Override
public void run() {
compressImage(imageFolderPath, imageFile);
}
});
}
}
}
}
}
try {
// Time out after 10 minutes
exec.shutdown();
exec.awaitTermination(10, TimeUnit.MINUTES);
} catch (InterruptedException e) {
LOGGER.error(e.getMessage(), e);
}
}
use of com.att.aro.core.packetanalysis.pojo.Session in project VideoOptimzer by attdevsupport.
the class VideoNetworkComparisonImpl method getAvgThroughput.
private double getAvgThroughput(PacketAnalyzerResult tracedata) {
double avgKbps;
int curMaxLength = 0;
for (Session session : tracedata.getSessionlist()) {
double startTime = 0;
int tempLength = 0;
for (PacketInfo packetInfo : session.getTcpPackets()) {
if (startTime == 0) {
// give the initial value
startTime = packetInfo.getTimeStamp();
}
if (startTime + 1 > packetInfo.getTimeStamp()) {
tempLength += packetInfo.getPayloadLen();
} else {
if (curMaxLength < tempLength) {
curMaxLength = tempLength;
LOGGER.debug("packetInfo: " + packetInfo.getPacketId() + " packet Time: " + packetInfo.getTimeStamp() + " find the bigger max: " + curMaxLength);
}
// reset value
tempLength = packetInfo.getPayloadLen();
startTime = packetInfo.getTimeStamp();
}
}
}
// kbps
avgKbps = (double) curMaxLength * 8 / 1024;
return avgKbps;
}
Aggregations