use of com.att.aro.core.packetanalysis.pojo.Session in project VideoOptimzer by attdevsupport.
the class SimultnsConnImpl method populateSimultConnList.
private void populateSimultConnList() {
List<Session> sessions = traceDataResult.getSessionlist();
if (sessions == null || sessions.size() <= 0) {
simultnsConnectionEntryList = Collections.emptyList();
return;
}
Map<String, ArrayList<Session>> distinctMap = simultnsUtil.getDistinctMap(sessions);
HashMap<String, List<SessionValues>> ipMap = new HashMap<String, List<SessionValues>>();
for (Map.Entry<String, ArrayList<Session>> entry : distinctMap.entrySet()) {
ArrayList<Session> tempList = entry.getValue();
tempList.trimToSize();
List<SessionValues> timeMap = simultnsUtil.createDomainsTCPSessions(tempList);
ipMap.put(entry.getKey(), timeMap);
}
for (HashMap.Entry<String, List<SessionValues>> ipEntry : ipMap.entrySet()) {
MultipleConnectionsEntry simultnsConnEntry = simultnsUtil.getTimeMap(ipEntry.getValue(), maxConnections, false);
if (simultnsConnEntry != null) {
simultnsConnectionEntryMap.put(simultnsConnEntry.getStartTimeStamp(), simultnsConnEntry);
}
}
}
use of com.att.aro.core.packetanalysis.pojo.Session in project VideoOptimzer by attdevsupport.
the class ImageFormatImpl method getEntryList.
private List<ImageMdataEntry> getEntryList() {
String originalImage = "";
long convertedImgSize = 0L;
long orgImageSize = 0L;
String imgExtn = "";
long orgImgSize;
long convImageSize;
String convImage = "";
String convertedImagesFolderPath = "";
List<ImageMdataEntry> imgEntryList = new ArrayList<ImageMdataEntry>();
for (Session session : tracedataResult.getSessionlist()) {
for (HttpRequestResponseInfo reqResp : session.getRequestResponseInfo()) {
if (reqResp.getDirection() == HttpDirection.RESPONSE && reqResp.getContentType() != null && reqResp.getContentType().contains("image/")) {
originalImage = ImageHelper.extractFullNameFromRRInfo(reqResp);
if ((!originalImage.isEmpty() && !(originalImage.contains(".jpeg") || originalImage.contains(".jpg"))) && reqResp.getContentType().contains("jpeg")) {
originalImage = Util.parseImageName(originalImage, reqResp);
}
File orgImage = new File(imageFolderPath + originalImage);
orgImageSize = orgImage.length();
int pos = originalImage.lastIndexOf(".");
imgExtn = originalImage.substring(pos + 1, originalImage.length());
if (orgImageSize > 0 && Util.isJPG(orgImage, imgExtn)) {
convertedImagesFolderPath = imageFolderPath + "Format" + System.getProperty("file.separator");
convImage = convertedImagesFolderPath + originalImage.substring(0, originalImage.lastIndexOf(".") + 1) + convExtn;
convertedImgSize = new File(convImage).length();
long indSavings = (orgImageSize - convertedImgSize) * 100 / orgImageSize;
if (convertedImgSize > 0 && (indSavings >= 15)) {
orginalImagesSize = orginalImagesSize + orgImageSize;
convImgsSize = convImgsSize + convertedImgSize;
orgImgSize = orgImageSize / 1024;
convImageSize = convertedImgSize / 1024;
imgEntryList.add(new ImageMdataEntry(reqResp, session.getDomainName(), imageFolderPath + originalImage, orgImgSize, convImageSize, Long.toString(indSavings)));
}
}
}
}
}
return imgEntryList;
}
use of com.att.aro.core.packetanalysis.pojo.Session in project VideoOptimzer by attdevsupport.
the class ImageSizeImpl method runTest.
@Override
public AbstractBestPracticeResult runTest(PacketAnalyzerResult tracedata) {
mImageFoundInHtmlOrCss = false;
ImageSizeResult result = new ImageSizeResult();
List<ImageSizeEntry> entrylist = new ArrayList<ImageSizeEntry>();
// 480 * 1.1;
int deviceScreenSizeX = 528;
// 800 * 1.1;
int deviceScreenSizeY = 880;
// screen size is available when reading trace directory
if (tracedata.getTraceresult().getTraceResultType() == TraceResultType.TRACE_DIRECTORY) {
TraceDirectoryResult dirdata = (TraceDirectoryResult) tracedata.getTraceresult();
deviceScreenSizeX = (dirdata.getDeviceScreenSizeX() * 110) / 100;
deviceScreenSizeY = (dirdata.getDeviceScreenSizeY() * 110) / 100;
}
for (Session session : tracedata.getSessionlist()) {
HttpRequestResponseInfo lastReq = null;
for (HttpRequestResponseInfo req : session.getRequestResponseInfo()) {
if (req.getDirection() == HttpDirection.REQUEST) {
lastReq = req;
}
if (req.getDirection() == HttpDirection.RESPONSE && req.getContentType() != null && req.getContentType().contains("image/")) {
boolean isBigSize = false;
List<HtmlImage> htmlImageList = checkThisImageInAllHTMLOrCSS(session, req);
if (mImageFoundInHtmlOrCss) {
mImageFoundInHtmlOrCss = false;
if (!htmlImageList.isEmpty()) {
for (int index = 0; index < htmlImageList.size(); index++) {
HtmlImage htmlImage = htmlImageList.get(index);
isBigSize = compareDownloadedImgSizeWithStdImageSize(req, htmlImage, deviceScreenSizeX, deviceScreenSizeY, session);
if (isBigSize) {
break;
}
}
} else {
isBigSize = compareDownloadedImgSizeWithStdImageSize(req, null, deviceScreenSizeX, deviceScreenSizeY, session);
}
if (isBigSize) {
entrylist.add(new ImageSizeEntry(req, lastReq, session.getDomainName()));
}
}
}
}
}
result.setDeviceScreenSizeRangeX(deviceScreenSizeX);
result.setDeviceScreenSizeRangeY(deviceScreenSizeY);
result.setResults(entrylist);
String text = "";
if (entrylist.isEmpty()) {
result.setResultType(BPResultType.PASS);
text = MessageFormat.format(textResultPass, entrylist.size());
result.setResultText(text);
result.setResultExcelText(BPResultType.PASS.getDescription());
} else {
result.setResultType(BPResultType.FAIL);
text = MessageFormat.format(textResults, ApplicationConfig.getInstance().getAppShortName(), entrylist.size());
result.setResultText(text);
result.setResultExcelText(MessageFormat.format(textExcelResults, BPResultType.FAIL.getDescription(), entrylist.size()));
}
result.setAboutText(aboutText);
result.setDetailTitle(detailTitle);
result.setLearnMoreUrl(learnMoreUrl);
result.setOverviewTitle(overviewTitle);
result.setExportNumberOfLargeImages(exportNumberOfLargeImages);
return result;
}
use of com.att.aro.core.packetanalysis.pojo.Session in project VideoOptimzer by attdevsupport.
the class MinificationImpl method runTest.
@Override
public AbstractBestPracticeResult runTest(PacketAnalyzerResult tracedata) {
htmlCompressor = null;
MinificationResult result = new MinificationResult();
initHtmlCompressor();
List<MinificationEntry> minificationEntryList = new ArrayList<MinificationEntry>();
String contentType = null;
int totalSavingInBytes = 0;
int totalBytes = 0;
final ExecutorService executorService = Executors.newFixedThreadPool(50);
Collection<Worker> workers = new ArrayList<Worker>();
for (Session session : tracedata.getSessionlist()) {
HttpRequestResponseInfo lastRequestObj = null;
for (HttpRequestResponseInfo req : session.getRequestResponseInfo()) {
if (req.getDirection() == HttpDirection.REQUEST) {
lastRequestObj = req;
}
contentType = req.getContentType();
if (req.getDirection() == HttpDirection.RESPONSE && req.getContentLength() > 0 && contentType != null) {
workers.add(new Worker(contentType, req, lastRequestObj, session));
// if (reqhelper.isJavaScript(contentType)) {
// entry = calculateSavingMinifiedJavascript(req, lastRequestObj, session);
// } else if (reqhelper.isCss(contentType)) {
// workers.add(new Worker(req, lastRequestObj, session));
// // Future<MinificationEntry> res1 = executorService.submit(new Worker(req, lastRequestObj, session);
// // entry = calculateSavingMinifiedCss(req, lastRequestObj, session);
// } else if (reqhelper.isHtml(contentType)) {
// entry = calculateSavingMinifiedHtml(req, lastRequestObj, session);
// } else if (reqhelper.isJSON(contentType)) {
// entry = calculateSavingMinifiedJson(req, lastRequestObj, session);
// }
// if (entry != null) {
// totalSavingInBytes += entry.getSavingsSizeInByte();
// minificationEntryList.add(entry);
// }
}
}
}
try {
List<Future<MinificationEntry>> list = executorService.invokeAll(workers);
for (Future<MinificationEntry> future : list) {
if (future != null && future.get() != null) {
totalSavingInBytes += future.get().getSavingsSizeInByte();
totalBytes += future.get().getOriginalSizeInByte();
minificationEntryList.add(future.get());
}
}
} catch (InterruptedException | ExecutionException ee) {
LOGGER.error(ee.getMessage(), ee);
}
executorService.shutdown();
int savingInKb = totalSavingInBytes / 1024;
result.setTotalSavingsInKb(savingInKb);
result.setTotalSavingsInByte(totalSavingInBytes);
result.setMinificationEntryList(minificationEntryList);
int numberOfFiles = minificationEntryList.size();
String text = "";
if (minificationEntryList.isEmpty()) {
result.setResultType(BPResultType.PASS);
text = MessageFormat.format(textResultPass, numberOfFiles, savingInKb);
result.setResultText(text);
result.setResultExcelText(BPResultType.PASS.getDescription());
} else if (savingInKb < 1) {
result.setResultType(BPResultType.FAIL);
text = MessageFormat.format(textResultFail, ApplicationConfig.getInstance().getAppShortName(), numberOfFiles);
result.setResultText(text);
result.setResultExcelText(MessageFormat.format(textExcelResultsFail, BPResultType.FAIL.getDescription(), numberOfFiles));
} else {
result.setResultType(BPResultType.FAIL);
String percentageSaving = String.valueOf(Math.round(((double) totalSavingInBytes / totalBytes) * 100));
text = MessageFormat.format(textResults, ApplicationConfig.getInstance().getAppShortName(), numberOfFiles, savingInKb, percentageSaving);
result.setResultText(text);
result.setResultExcelText(MessageFormat.format(textExcelResults, BPResultType.FAIL.getDescription(), numberOfFiles, savingInKb, percentageSaving));
}
result.setAboutText(aboutText);
result.setDetailTitle(detailTitle);
result.setLearnMoreUrl(learnMoreUrl);
result.setOverviewTitle(overviewTitle);
result.setExportAllNumberOfMinifyFiles(exportAllNumberOfMinifyFiles);
return result;
}
use of com.att.aro.core.packetanalysis.pojo.Session in project VideoOptimzer by attdevsupport.
the class PeriodicTransferImpl method diagnosisPeriodicRequest.
/**
* Burst data's analyzed to categorize the periodic bursts.
*/
private void diagnosisPeriodicRequest(List<Session> sessionlist, List<Burst> burstCollection, Profile profile) {
/*
* Represent lists of hosts, objects, and IPs requested via HTTP and
* timestamps when these requests were made.
*/
Map<String, List<Double>> requestedHost2tsList = new HashMap<String, List<Double>>();
Map<String, List<Double>> requestedObj2tsList = new HashMap<String, List<Double>>();
Map<InetAddress, List<Double>> connectedIP2tsList = new HashMap<InetAddress, List<Double>>();
// int count = 0;
for (Session tcpSession : sessionlist) {
// Get a list of timestamps of established sessions with each remote IP
if (!tcpSession.isUdpOnly()) {
PacketInfo firstPacket = tcpSession.getTcpPackets().get(0);
if (firstPacket.getTcpInfo() == TcpInfo.TCP_ESTABLISH) {
List<Double> res = connectedIP2tsList.get(tcpSession.getRemoteIP());
if (res == null) {
res = new ArrayList<Double>();
connectedIP2tsList.put(tcpSession.getRemoteIP(), res);
}
res.add(Double.valueOf(firstPacket.getTimeStamp()));
}
// Get a list of timestamps of HTTP requests to hosts/object names
for (HttpRequestResponseInfo hrri : tcpSession.getRequestResponseInfo()) {
PacketInfo pkt = hrri.getFirstDataPacket();
if (hrri.getDirection() == HttpDirection.REQUEST && pkt != null) {
Double ts0 = Double.valueOf(pkt.getTimeStamp());
if (hrri.getHostName() != null) {
List<Double> tempRequestHostEventList = requestedHost2tsList.get(hrri.getHostName());
if (tempRequestHostEventList == null) {
tempRequestHostEventList = new ArrayList<Double>();
requestedHost2tsList.put(hrri.getHostName(), tempRequestHostEventList);
}
tempRequestHostEventList.add(ts0);
}
if (hrri.getObjName() != null) {
String objName = hrri.getObjNameWithoutParams();
List<Double> tempRequestObjEventList = requestedObj2tsList.get(objName);
if (tempRequestObjEventList == null) {
tempRequestObjEventList = new ArrayList<Double>();
requestedObj2tsList.put(objName, tempRequestObjEventList);
}
tempRequestObjEventList.add(ts0);
}
}
}
}
}
// logger.info("done looping session");
Set<String> hostList = new HashSet<String>();
Set<String> objList = new HashSet<String>();
Set<InetAddress> ipList = new HashSet<InetAddress>();
// count = 0;
for (Map.Entry<String, List<Double>> iter : requestedHost2tsList.entrySet()) {
if (determinePeriodicity(iter.getValue(), profile)) {
hostList.add(iter.getKey());
}
// logger.info("count: "+count++);
}
// count = 0;
for (Map.Entry<String, List<Double>> iter : requestedObj2tsList.entrySet()) {
if (determinePeriodicity(iter.getValue(), profile)) {
objList.add(iter.getKey());
}
// logger.info("count: "+count++);
}
// count = 0;
for (Map.Entry<InetAddress, List<Double>> iter : connectedIP2tsList.entrySet()) {
if (determinePeriodicity(iter.getValue(), profile)) {
ipList.add(iter.getKey());
}
// logger.info("count: "+count++);
}
// logger.info("Done looping, now go to determinePeriodicity");
determinePeriodicity(hostList, objList, ipList, burstCollection, profile, sessionlist);
}
Aggregations