use of com.att.aro.core.packetanalysis.pojo.CacheEntry in project VideoOptimzer by attdevsupport.
the class BpFileDuplicateContentTablePanel method getContentTable.
/**
* Initializes and returns the RequestResponseTable.
*/
@Override
@SuppressWarnings("unchecked")
public DataTable<CacheEntry> getContentTable() {
if (contentTable == null) {
contentTable = new DataTable<CacheEntry>(tableModel);
contentTable.setName(ResourceBundleHelper.getMessageString("file.duplicate.content.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;
}
use of com.att.aro.core.packetanalysis.pojo.CacheEntry in project VideoOptimzer by attdevsupport.
the class UsingCacheImpl method runTest.
@Override
public AbstractBestPracticeResult runTest(PacketAnalyzerResult tracedata) {
UsingCacheResult result = new UsingCacheResult();
if (tracedata.getCacheAnalysis() == null) {
return null;
}
double cacheHeaderRatio = 0.0;
boolean usingCache = false;
int validCount = 0;
int noCacheHeadersCount = 0;
PacketInfo noCacheHeaderFirstPacket = null;
for (CacheEntry entry : tracedata.getCacheAnalysis().getDiagnosisResults()) {
if (entry.getDiagnosis() != Diagnosis.CACHING_DIAG_REQUEST_NOT_FOUND && entry.getDiagnosis() != Diagnosis.CACHING_DIAG_INVALID_OBJ_NAME && entry.getDiagnosis() != Diagnosis.CACHING_DIAG_INVALID_REQUEST && entry.getDiagnosis() != Diagnosis.CACHING_DIAG_INVALID_RESPONSE) {
++validCount;
if (!entry.hasCacheHeaders()) {
if (noCacheHeadersCount == 0) {
noCacheHeaderFirstPacket = entry.getSessionFirstPacket();
}
++noCacheHeadersCount;
}
}
}
cacheHeaderRatio = validCount > 0 ? (100.0 * noCacheHeadersCount) / validCount : 0.0;
usingCache = cacheHeaderRatio <= 10.0;
if (usingCache) {
result.setResultType(BPResultType.PASS);
result.setResultText(textResultPass);
result.setResultExcelText(BPResultType.PASS.getDescription());
} else {
// ref. old analyzer give warning in this best practice
result.setResultType(BPResultType.WARNING);
String text = MessageFormat.format(textResults, ApplicationConfig.getInstance().getAppShortName(), NumberFormat.getIntegerInstance().format(cacheHeaderRatio));
result.setResultText(text);
result.setResultExcelText(MessageFormat.format(textExcelResults, BPResultType.WARNING.getDescription(), NumberFormat.getIntegerInstance().format(cacheHeaderRatio)));
}
result.setCacheHeaderRatio(cacheHeaderRatio);
result.setNoCacheHeaderFirstPacket(noCacheHeaderFirstPacket);
result.setAboutText(aboutText);
result.setDetailTitle(detailTitle);
result.setLearnMoreUrl(learnMoreUrl);
result.setOverviewTitle(overviewTitle);
result.setExportAllCacheConPct(exportAllCacheConPct);
return result;
}
use of com.att.aro.core.packetanalysis.pojo.CacheEntry in project VideoOptimzer by attdevsupport.
the class DuplicateContentResult method hashCode.
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
long temp;
temp = Double.doubleToLongBits(duplicateContentBytesRatio);
result = prime * result + (int) (temp ^ (temp >>> 32));
result = prime * result + (int) duplicateContentBytes;
result = prime * result + (int) totalContentBytes;
result = prime * result + duplicateContentSizeOfUniqueItems;
result = prime * result + duplicateContentsize;
for (CacheEntry cacheEntry : duplicateContentList) {
result = prime * result + cacheEntry.hashCode();
}
result = prime * result + getBestPracticeDescription().hashCode();
result = prime * result + getBestPracticeType().hashCode();
return result;
}
use of com.att.aro.core.packetanalysis.pojo.CacheEntry in project VideoOptimzer by attdevsupport.
the class DuplicateContentImplTest method runTest_resTypeIsFail.
@Test
public void runTest_resTypeIsFail() {
List<CacheEntry> duplicateContent = new ArrayList<CacheEntry>();
for (int i = 0; i < 5; i++) {
duplicateContent.add(entryArray[i]);
}
Mockito.when(cacheAnalysis.getDuplicateContentBytes()).thenReturn(value);
Mockito.when(cacheAnalysis.getDuplicateContentBytesRatio()).thenReturn(1.0);
Mockito.when(cacheAnalysis.getDuplicateContent()).thenReturn(duplicateContent);
Mockito.when(tracedata.getCacheAnalysis()).thenReturn(cacheAnalysis);
duplicateContentImpl = (DuplicateContentImpl) context.getBean("duplicateContent");
AbstractBestPracticeResult testResult = duplicateContentImpl.runTest(tracedata);
assertEquals(BPResultType.FAIL, testResult.getResultType());
}
use of com.att.aro.core.packetanalysis.pojo.CacheEntry in project VideoOptimzer by attdevsupport.
the class CacheControlImplTest method runTest_resTypeIsFail.
@Test
public void runTest_resTypeIsFail() {
List<CacheEntry> diagnosisResults = new ArrayList<CacheEntry>();
Mockito.when(entryArray[0].getDiagnosis()).thenReturn(Diagnosis.CACHING_DIAG_NOT_EXPIRED_DUP);
Mockito.when(entryArray[1].getDiagnosis()).thenReturn(Diagnosis.CACHING_DIAG_NOT_EXPIRED_DUP_PARTIALHIT);
Mockito.when(entryArray[2].getDiagnosis()).thenReturn(Diagnosis.CACHING_DIAG_OBJ_NOT_CHANGED_304);
Mockito.when(entryArray[3].getDiagnosis()).thenReturn(Diagnosis.CACHING_DIAG_NOT_EXPIRED_DUP_PARTIALHIT);
Mockito.when(entryArray[4].getDiagnosis()).thenReturn(Diagnosis.CACHING_DIAG_OBJ_NOT_CHANGED_304);
for (int i = 0; i < 5; i++) {
diagnosisResults.add(entryArray[i]);
}
Mockito.when(cacheAnalysis.getDiagnosisResults()).thenReturn(diagnosisResults);
Mockito.when(tracedata.getCacheAnalysis()).thenReturn(cacheAnalysis);
cacheControlImpl = (CacheControlImpl) context.getBean("cacheControl");
AbstractBestPracticeResult testResult = cacheControlImpl.runTest(tracedata);
assertEquals(BPResultType.WARNING, testResult.getResultType());
}
Aggregations