Search in sources :

Example 1 with TextFileCompressionEntry

use of com.att.aro.core.bestpractice.pojo.TextFileCompressionEntry in project VideoOptimzer by attdevsupport.

the class BpFileCompressionTablePanel method getContentTable.

/**
 * Initializes and returns the RequestResponseTable.
 */
@SuppressWarnings("unchecked")
public DataTable<TextFileCompressionEntry> getContentTable() {
    if (contentTable == null) {
        contentTable = new DataTable<TextFileCompressionEntry>(tableModel);
        contentTable.setName(ResourceBundleHelper.getMessageString("file.text.compresssion.tableName"));
        contentTable.setAutoCreateRowSorter(true);
        contentTable.setGridColor(Color.LIGHT_GRAY);
        contentTable.setRowHeight(ROW_HEIGHT);
        contentTable.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
        DataTablePopupMenu popupMenu = (DataTablePopupMenu) contentTable.getPopup();
        popupMenu.initialize();
    }
    return contentTable;
}
Also used : TextFileCompressionEntry(com.att.aro.core.bestpractice.pojo.TextFileCompressionEntry) DataTablePopupMenu(com.att.aro.ui.model.DataTablePopupMenu)

Example 2 with TextFileCompressionEntry

use of com.att.aro.core.bestpractice.pojo.TextFileCompressionEntry in project VideoOptimzer by attdevsupport.

the class FileCompressionImpl method runTest.

@Override
public AbstractBestPracticeResult runTest(PacketAnalyzerResult tracedata) {
    FileCompressionResult result = new FileCompressionResult();
    List<TextFileCompressionEntry> resultlist = new ArrayList<TextFileCompressionEntry>();
    int uncompressedCounter = 0;
    int compressedCounter = 0;
    int totalUncompressBytes = 0;
    int totalDownloadedBytes = 0;
    for (Session session : tracedata.getSessionlist()) {
        HttpRequestResponseInfo lastRequestObj = null;
        for (HttpRequestResponseInfo req : session.getRequestResponseInfo()) {
            if (req.getDirection() == HttpDirection.REQUEST) {
                lastRequestObj = req;
            }
            if (req.getPacketDirection() == PacketDirection.DOWNLINK && req.getContentLength() > 0 && req.getContentType() != null && isTextContent(req.getContentType())) {
                totalDownloadedBytes += req.getContentLength();
                // no compression?
                if (req.getContentEncoding() == null || req.getContentEncoding().contains("identity")) {
                    // don't count tiny file
                    if (req.getContentLength() > FILE_SIZE_THRESHOLD_BYTES) {
                        uncompressedCounter++;
                        totalUncompressBytes += req.getContentLength();
                        TextFileCompressionEntry tfcEntry = new TextFileCompressionEntry(req, lastRequestObj, session.getDomainName());
                        int gzipSavings = calculateSavingForTextBasedOnGzip(req, session);
                        int brotliSavings = calculateSavingForTextBasedOnBrotli(req, session);
                        tfcEntry.setSavingsTextPercentage(brotliSavings > gzipSavings ? brotliSavings : gzipSavings);
                        resultlist.add(tfcEntry);
                    } else {
                        compressedCounter++;
                    }
                } else {
                    compressedCounter++;
                }
            }
        }
    }
    result.setNoOfCompressedFiles(compressedCounter);
    result.setNoOfUncompressedFiles(uncompressedCounter);
    result.setTotalUncompressedSize(totalUncompressBytes);
    result.setResults(resultlist);
    String text = "";
    if (uncompressedCounter == 0) {
        result.setResultType(BPResultType.PASS);
    } else if (totalUncompressBytes >= UNCOMPRESSED_SIZE_FAILED_THRESHOLD) {
        result.setResultType(BPResultType.FAIL);
    } else {
        result.setResultType(BPResultType.WARNING);
    }
    if (result.getResultType() == BPResultType.PASS) {
        text = MessageFormat.format(textResultPass, ApplicationConfig.getInstance().getAppShortName(), FILE_SIZE_THRESHOLD_BYTES, FILE_SIZE_THRESHOLD_BYTES);
        result.setResultExcelText(result.getResultType().getDescription());
    } else {
        String percentageSaving = String.valueOf(Math.round(((double) totalUncompressBytes / totalDownloadedBytes) * 100));
        text = MessageFormat.format(textResults, ApplicationConfig.getInstance().getAppShortName(), totalUncompressBytes / 1024, FILE_SIZE_THRESHOLD_BYTES, percentageSaving, (totalDownloadedBytes / 1024));
        result.setResultExcelText(MessageFormat.format(textExcelResults, result.getResultType().getDescription(), percentageSaving, totalUncompressBytes / 1024, totalDownloadedBytes / 1024));
    }
    result.setResultText(text);
    result.setAboutText(aboutText);
    result.setDetailTitle(detailTitle);
    result.setLearnMoreUrl(learnMoreUrl);
    result.setOverviewTitle(overviewTitle);
    result.setExportAll(exportAll);
    result.setExportAllKb(exportAllKb);
    return result;
}
Also used : HttpRequestResponseInfo(com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo) TextFileCompressionEntry(com.att.aro.core.bestpractice.pojo.TextFileCompressionEntry) ArrayList(java.util.ArrayList) FileCompressionResult(com.att.aro.core.bestpractice.pojo.FileCompressionResult) Session(com.att.aro.core.packetanalysis.pojo.Session)

Aggregations

TextFileCompressionEntry (com.att.aro.core.bestpractice.pojo.TextFileCompressionEntry)2 FileCompressionResult (com.att.aro.core.bestpractice.pojo.FileCompressionResult)1 HttpRequestResponseInfo (com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo)1 Session (com.att.aro.core.packetanalysis.pojo.Session)1 DataTablePopupMenu (com.att.aro.ui.model.DataTablePopupMenu)1 ArrayList (java.util.ArrayList)1