Search in sources :

Example 21 with Session

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);
        }
    }
}
Also used : MultipleConnectionsEntry(com.att.aro.core.bestpractice.pojo.MultipleConnectionsEntry) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) SessionValues(com.att.aro.core.packetanalysis.pojo.SessionValues) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) TreeMap(java.util.TreeMap) Map(java.util.Map) SortedMap(java.util.SortedMap) Session(com.att.aro.core.packetanalysis.pojo.Session)

Example 22 with Session

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;
}
Also used : ImageMdataEntry(com.att.aro.core.bestpractice.pojo.ImageMdataEntry) HttpRequestResponseInfo(com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo) ArrayList(java.util.ArrayList) File(java.io.File) Session(com.att.aro.core.packetanalysis.pojo.Session)

Example 23 with Session

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;
}
Also used : HtmlImage(com.att.aro.core.bestpractice.pojo.HtmlImage) ImageSizeEntry(com.att.aro.core.bestpractice.pojo.ImageSizeEntry) HttpRequestResponseInfo(com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo) ArrayList(java.util.ArrayList) TraceDirectoryResult(com.att.aro.core.packetanalysis.pojo.TraceDirectoryResult) ImageSizeResult(com.att.aro.core.bestpractice.pojo.ImageSizeResult) Session(com.att.aro.core.packetanalysis.pojo.Session)

Example 24 with Session

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;
}
Also used : MinificationResult(com.att.aro.core.bestpractice.pojo.MinificationResult) HttpRequestResponseInfo(com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo) ArrayList(java.util.ArrayList) MinificationEntry(com.att.aro.core.bestpractice.pojo.MinificationEntry) ExecutorService(java.util.concurrent.ExecutorService) Future(java.util.concurrent.Future) ExecutionException(java.util.concurrent.ExecutionException) Session(com.att.aro.core.packetanalysis.pojo.Session)

Example 25 with Session

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);
}
Also used : HashMap(java.util.HashMap) HttpRequestResponseInfo(com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo) PacketInfo(com.att.aro.core.packetanalysis.pojo.PacketInfo) ArrayList(java.util.ArrayList) List(java.util.List) InetAddress(java.net.InetAddress) HashMap(java.util.HashMap) Map(java.util.Map) Session(com.att.aro.core.packetanalysis.pojo.Session) HashSet(java.util.HashSet)

Aggregations

Session (com.att.aro.core.packetanalysis.pojo.Session)130 ArrayList (java.util.ArrayList)86 HttpRequestResponseInfo (com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo)74 BaseTest (com.att.aro.core.BaseTest)49 Test (org.junit.Test)49 PacketInfo (com.att.aro.core.packetanalysis.pojo.PacketInfo)32 AbstractBestPracticeResult (com.att.aro.core.bestpractice.pojo.AbstractBestPracticeResult)31 InetAddress (java.net.InetAddress)26 HashMap (java.util.HashMap)19 TCPPacket (com.att.aro.core.packetreader.pojo.TCPPacket)17 HashSet (java.util.HashSet)11 TreeMap (java.util.TreeMap)11 List (java.util.List)10 Statistic (com.att.aro.core.packetanalysis.pojo.Statistic)9 File (java.io.File)9 TraceDirectoryResult (com.att.aro.core.packetanalysis.pojo.TraceDirectoryResult)8 DomainNameSystem (com.att.aro.core.packetreader.pojo.DomainNameSystem)8 BurstCollectionAnalysisData (com.att.aro.core.packetanalysis.pojo.BurstCollectionAnalysisData)7 HttpRequestResponseInfoWithSession (com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfoWithSession)7 UDPPacket (com.att.aro.core.packetreader.pojo.UDPPacket)7