@Test public void testCacheIpfixDataSet() throws Exception { Long obsvDomain = 4335L; String hostname = "deviceA"; byte[] data = IpfixUtilities.hexStringToByteArray("0103001800"); IpfixDataSet expected = new IpfixDataSet(data); m_ipfixfeCachingService.cacheIpfixDataSet(obsvDomain, hostname, expected); List<IpfixDataSet> result = m_ipfixfeCachingService.getAndInvalidateIpfixDataSet(obsvDomain, hostname); assertEquals(1, result.size()); IpfixSetHeader expectedHeader = expected.getHeader(); IpfixSetHeader actualHeader = result.get(0).getHeader(); assertEquals(expectedHeader.getId(), actualHeader.getId()); assertEquals(expectedHeader.getLength(), actualHeader.getLength()); assertTrue("IpfixSetHeader.getPresentation() isn't returned correctly", Arrays.equals(expectedHeader.getPresentation(), actualHeader.getPresentation())); assertTrue("IpfixDataSet.getRawData() isn't returned correctly", Arrays.equals(expected.getRawData(), result.get(0).getRawData())); assertEquals(expected.getRecords(), result.get(0).getRecords()); assertTrue("IpfixDataSet.getPresentation() isn't returned correctly", Arrays.equals(expected.getPresentation(), result.get(0).getPresentation())); result = m_ipfixfeCachingService.getAndInvalidateIpfixDataSet(obsvDomain, hostname); assertEquals(0, result.size()); }
@Override public void cacheIpfixDataSet(long obsvDomain, String hostName, IpfixDataSet set) { m_ipfixDataSetCache.put(new Element(buildCacheKey(obsvDomain, hostName, set.getHeader().getId()), set)); }
IpfixCachingServiceImpl implements IpfixCachingService { @Override public void cacheIpfixDataSet(long obsvDomain, String hostName, IpfixDataSet set) { m_ipfixDataSetCache.put(new Element(buildCacheKey(obsvDomain, hostName, set.getHeader().getId()), set)); } }
IpfixCachingServiceImpl implements IpfixCachingService { @Override public void cacheIpfixDataSet(long obsvDomain, String hostName, IpfixDataSet set) { m_ipfixDataSetCache.put(new Element(buildCacheKey(obsvDomain, hostName, set.getHeader().getId()), set)); } IpfixCachingServiceImpl(); }
IpfixCachingServiceImpl implements IpfixCachingService { @Override public void cacheIpfixDataSet(long obsvDomain, String hostName, IpfixDataSet set) { m_ipfixDataSetCache.put(new Element(buildCacheKey(obsvDomain, hostName, set.getHeader().getId()), set)); } IpfixCachingServiceImpl(); @Override void cleanUpCache(); void destroy(); void setCentralCacheManager(CacheManager centralCacheManager); void initialize(); @Override void cacheTemplateRecord(long obsvDomain, String hostname, Map<Integer, AbstractTemplateRecord> templateByIdCache); @Override AbstractTemplateRecord getTemplateRecord(long obsvDomain, String hostname, int templateId); @Override Set<String> getAllCacheKeys(); @Override void updateHostName(long obsvDomain, String oldHostName, String newHostName); @Override void cacheIpfixDataSet(long obsvDomain, String hostName, IpfixDataSet set); @Override List<IpfixDataSet> getAndInvalidateIpfixDataSet(long obsvDomain, String hostName); }
IpfixCachingServiceImpl implements IpfixCachingService { @Override public void cacheIpfixDataSet(long obsvDomain, String hostName, IpfixDataSet set) { m_ipfixDataSetCache.put(new Element(buildCacheKey(obsvDomain, hostName, set.getHeader().getId()), set)); } IpfixCachingServiceImpl(); @Override void cleanUpCache(); void destroy(); void setCentralCacheManager(CacheManager centralCacheManager); void initialize(); @Override void cacheTemplateRecord(long obsvDomain, String hostname, Map<Integer, AbstractTemplateRecord> templateByIdCache); @Override AbstractTemplateRecord getTemplateRecord(long obsvDomain, String hostname, int templateId); @Override Set<String> getAllCacheKeys(); @Override void updateHostName(long obsvDomain, String oldHostName, String newHostName); @Override void cacheIpfixDataSet(long obsvDomain, String hostName, IpfixDataSet set); @Override List<IpfixDataSet> getAndInvalidateIpfixDataSet(long obsvDomain, String hostName); public Cache m_ipfixDataSetCache; public Cache m_ipfixTemplateRecordCache; }