@Test public void testApplyWithoutLogMessage() { EasyMock.expect(inputMock.getCache()).andReturn(createLruCache(DEFAULT_DUMMY_MESSAGE, 100L, true)); EasyMock.expect(inputMock.getInputDescriptor()).andReturn(generateInputDescriptor()); EasyMock.expect(inputMock.getCacheKeyField()).andReturn(CACHE_KEY_FIELD); EasyMock.replay(inputMock); Map<String, Object> lineMap = generateLineMap(); lineMap.remove(CACHE_KEY_FIELD); boolean result = underTest.apply(lineMap, inputMock); EasyMock.verify(inputMock); assertFalse(result); }
public Boolean apply(Map<String, Object> lineMap, Input input) { boolean isLogFilteredOut = false; LRUCache inputLruCache = input.getCache(); if (inputLruCache != null && "service".equals(input.getInputDescriptor().getRowtype())) { String logMessage = (String) lineMap.get(input.getCacheKeyField()); Long timestamp = null; if (lineMap.containsKey((LogFeederConstants.IN_MEMORY_TIMESTAMP))) { timestamp = (Long) lineMap.get(LogFeederConstants.IN_MEMORY_TIMESTAMP); } if (logMessage != null && timestamp != null) { isLogFilteredOut = !inputLruCache.isEntryReplaceable(logMessage, timestamp); if (!isLogFilteredOut) { inputLruCache.put(logMessage, timestamp); } else { logger.debug("Log line filtered out: {} (file: {}, dedupInterval: {}, lastDedupEnabled: {})", logMessage, inputLruCache.getFileName(), inputLruCache.getDedupInterval(), inputLruCache.isLastDedupEnabled()); } } } lineMap.remove(LogFeederConstants.IN_MEMORY_TIMESTAMP); return isLogFilteredOut; }
OutputLineFilter { public Boolean apply(Map<String, Object> lineMap, Input input) { boolean isLogFilteredOut = false; LRUCache inputLruCache = input.getCache(); if (inputLruCache != null && "service".equals(input.getInputDescriptor().getRowtype())) { String logMessage = (String) lineMap.get(input.getCacheKeyField()); Long timestamp = null; if (lineMap.containsKey((LogFeederConstants.IN_MEMORY_TIMESTAMP))) { timestamp = (Long) lineMap.get(LogFeederConstants.IN_MEMORY_TIMESTAMP); } if (logMessage != null && timestamp != null) { isLogFilteredOut = !inputLruCache.isEntryReplaceable(logMessage, timestamp); if (!isLogFilteredOut) { inputLruCache.put(logMessage, timestamp); } else { logger.debug("Log line filtered out: {} (file: {}, dedupInterval: {}, lastDedupEnabled: {})", logMessage, inputLruCache.getFileName(), inputLruCache.getDedupInterval(), inputLruCache.isLastDedupEnabled()); } } } lineMap.remove(LogFeederConstants.IN_MEMORY_TIMESTAMP); return isLogFilteredOut; } }
OutputLineFilter { public Boolean apply(Map<String, Object> lineMap, Input input) { boolean isLogFilteredOut = false; LRUCache inputLruCache = input.getCache(); if (inputLruCache != null && "service".equals(input.getInputDescriptor().getRowtype())) { String logMessage = (String) lineMap.get(input.getCacheKeyField()); Long timestamp = null; if (lineMap.containsKey((LogFeederConstants.IN_MEMORY_TIMESTAMP))) { timestamp = (Long) lineMap.get(LogFeederConstants.IN_MEMORY_TIMESTAMP); } if (logMessage != null && timestamp != null) { isLogFilteredOut = !inputLruCache.isEntryReplaceable(logMessage, timestamp); if (!isLogFilteredOut) { inputLruCache.put(logMessage, timestamp); } else { logger.debug("Log line filtered out: {} (file: {}, dedupInterval: {}, lastDedupEnabled: {})", logMessage, inputLruCache.getFileName(), inputLruCache.getDedupInterval(), inputLruCache.isLastDedupEnabled()); } } } lineMap.remove(LogFeederConstants.IN_MEMORY_TIMESTAMP); return isLogFilteredOut; }  }
OutputLineFilter { public Boolean apply(Map<String, Object> lineMap, Input input) { boolean isLogFilteredOut = false; LRUCache inputLruCache = input.getCache(); if (inputLruCache != null && "service".equals(input.getInputDescriptor().getRowtype())) { String logMessage = (String) lineMap.get(input.getCacheKeyField()); Long timestamp = null; if (lineMap.containsKey((LogFeederConstants.IN_MEMORY_TIMESTAMP))) { timestamp = (Long) lineMap.get(LogFeederConstants.IN_MEMORY_TIMESTAMP); } if (logMessage != null && timestamp != null) { isLogFilteredOut = !inputLruCache.isEntryReplaceable(logMessage, timestamp); if (!isLogFilteredOut) { inputLruCache.put(logMessage, timestamp); } else { logger.debug("Log line filtered out: {} (file: {}, dedupInterval: {}, lastDedupEnabled: {})", logMessage, inputLruCache.getFileName(), inputLruCache.getDedupInterval(), inputLruCache.isLastDedupEnabled()); } } } lineMap.remove(LogFeederConstants.IN_MEMORY_TIMESTAMP); return isLogFilteredOut; }  Boolean apply(Map<String, Object> lineMap, Input input); }
OutputLineFilter { public Boolean apply(Map<String, Object> lineMap, Input input) { boolean isLogFilteredOut = false; LRUCache inputLruCache = input.getCache(); if (inputLruCache != null && "service".equals(input.getInputDescriptor().getRowtype())) { String logMessage = (String) lineMap.get(input.getCacheKeyField()); Long timestamp = null; if (lineMap.containsKey((LogFeederConstants.IN_MEMORY_TIMESTAMP))) { timestamp = (Long) lineMap.get(LogFeederConstants.IN_MEMORY_TIMESTAMP); } if (logMessage != null && timestamp != null) { isLogFilteredOut = !inputLruCache.isEntryReplaceable(logMessage, timestamp); if (!isLogFilteredOut) { inputLruCache.put(logMessage, timestamp); } else { logger.debug("Log line filtered out: {} (file: {}, dedupInterval: {}, lastDedupEnabled: {})", logMessage, inputLruCache.getFileName(), inputLruCache.getDedupInterval(), inputLruCache.isLastDedupEnabled()); } } } lineMap.remove(LogFeederConstants.IN_MEMORY_TIMESTAMP); return isLogFilteredOut; }  Boolean apply(Map<String, Object> lineMap, Input input);  }