/** * Force releasing the cache item for the given group id, even though there * may be active references. */ public synchronized void forceRelease() { try { if (store != null) { store.close(); } } catch (IOException e) { LOG.warn("Error closing timeline store", e); } store = null; // reset offsets so next time logs are re-parsed for (LogInfo log : appLogs.getDetailLogs()) { if (log.getFilename().contains(groupId.toString())) { log.setOffset(0); } } LOG.debug("Cache for group {} released. ", groupId); }
public synchronized void releaseCache(TimelineEntityGroupId groupId) { try { if (store != null) { store.close(); } } catch (IOException e) { LOG.warn("Error closing datamanager", e); } store = null; // reset offsets so next time logs are re-parsed for (LogInfo log : appLogs.getDetailLogs()) { if (log.getFilename().contains(groupId.toString())) { log.offset = 0; } } } }
if (!appLogs.isDone()) { appLogs.parseSummaryLogs(); } else if (appLogs.getDetailLogs().isEmpty()) { appLogs.scanForLogs(); if (!appLogs.getDetailLogs().isEmpty()) { if (store == null) { store = new LevelDBCacheTimelineStore(groupId.toString(), tdm.init(config); tdm.start(); if (appLogs.getDetailLogs().isEmpty()) { LOG.debug("cache id {}'s detail log is empty! ", groupId); for (LogInfo log : appLogs.getDetailLogs()) { LOG.debug("Try refresh logs for {}", log.getFilename()); appLogs.getDetailLogs().removeAll(removeList); tdm.close();
} else if (appLogs.getDetailLogs().isEmpty()) { appLogs.scanForLogs(); if (!appLogs.getDetailLogs().isEmpty()) { if (store == null) { store = ReflectionUtils.newInstance(config.getClass(
@Test public void testAppLogsScanLogs() throws Exception { EntityGroupFSTimelineStore.AppLogs appLogs = store.new AppLogs(mainTestAppId, mainTestAppDirPath, AppState.COMPLETED); appLogs.scanForLogs(); List<LogInfo> summaryLogs = appLogs.getSummaryLogs(); List<LogInfo> detailLogs = appLogs.getDetailLogs(); assertEquals(2, summaryLogs.size()); assertEquals(1, detailLogs.size()); for (LogInfo log : summaryLogs) { String fileName = log.getFilename(); assertTrue(fileName.equals(TEST_SUMMARY_LOG_FILE_NAME) || fileName.equals(TEST_DOMAIN_LOG_FILE_NAME)); } for (LogInfo log : detailLogs) { String fileName = log.getFilename(); assertEquals(fileName, mainEntityLogFileName); } }