@Test public void testRefreshLoadedJobCache() throws Exception { HistoryFileManager historyManager = mock(HistoryFileManager.class); jobHistory = spy(new JobHistory()); doReturn(historyManager).when(jobHistory).createHistoryFileManager(); Configuration conf = new Configuration(); conf.setInt(JHAdminConfig.MR_HISTORY_LOADED_JOB_CACHE_SIZE, 2); jobHistory.init(conf); jobHistory.start(); CachedHistoryStorage storage = spy((CachedHistoryStorage) jobHistory .getHistoryStorage()); assertFalse(storage.getUseLoadedTasksCache()); Job[] jobs = new Job[3]; JobId[] jobIds = new JobId[3]; for (int i = 0; i < 3; i++) { jobs[i] = mock(Job.class); jobIds[i] = mock(JobId.class); when(jobs[i].getID()).thenReturn(jobIds[i]); } HistoryFileInfo fileInfo = mock(HistoryFileInfo.class); when(historyManager.getFileInfo(any(JobId.class))).thenReturn(fileInfo); when(fileInfo.loadJob()).thenReturn(jobs[0]).thenReturn(jobs[1]) .thenReturn(jobs[2]); for (int i = 0; i < 3; i++) { storage.getFullJob(jobs[i].getID()); } Cache<JobId, Job> jobCache = storage.getLoadedJobCache(); assertTrue(jobCache.size() > 0); conf.setInt(JHAdminConfig.MR_HISTORY_LOADED_JOB_CACHE_SIZE, 3); doReturn(conf).when(storage).createConf(); when(fileInfo.loadJob()).thenReturn(jobs[0]).thenReturn(jobs[1]) .thenReturn(jobs[2]); jobHistory.refreshLoadedJobCache(); for (int i = 0; i < 3; i++) { storage.getFullJob(jobs[i].getID()); } jobCache = storage.getLoadedJobCache(); assertTrue(jobCache.size() > 0); }
public void refreshLoadedJobCache() { if (getServiceState() == STATE.STARTED) { if (storage instanceof CachedHistoryStorage) { ((CachedHistoryStorage) storage).refreshLoadedJobCache(); } else { throw new UnsupportedOperationException(storage.getClass().getName() + " is expected to be an instance of " + CachedHistoryStorage.class.getName()); } } else { LOG.warn("Failed to execute refreshLoadedJobCache: JobHistory service is not started"); } }
JobHistory extends AbstractService implements HistoryContext { public void refreshLoadedJobCache() { if (getServiceState() == STATE.STARTED) { if (storage instanceof CachedHistoryStorage) { ((CachedHistoryStorage) storage).refreshLoadedJobCache(); } else { throw new UnsupportedOperationException(storage.getClass().getName() + " is expected to be an instance of " + CachedHistoryStorage.class.getName()); } } else { LOG.warn("Failed to execute refreshLoadedJobCache: JobHistory service is not started"); } } }
JobHistory extends AbstractService implements HistoryContext { public void refreshLoadedJobCache() { if (getServiceState() == STATE.STARTED) { if (storage instanceof CachedHistoryStorage) { ((CachedHistoryStorage) storage).refreshLoadedJobCache(); } else { throw new UnsupportedOperationException(storage.getClass().getName() + " is expected to be an instance of " + CachedHistoryStorage.class.getName()); } } else { LOG.warn("Failed to execute refreshLoadedJobCache: JobHistory service is not started"); } } JobHistory(); }
JobHistory extends AbstractService implements HistoryContext { public void refreshLoadedJobCache() { if (getServiceState() == STATE.STARTED) { if (storage instanceof CachedHistoryStorage) { ((CachedHistoryStorage) storage).refreshLoadedJobCache(); } else { throw new UnsupportedOperationException(storage.getClass().getName() + " is expected to be an instance of " + CachedHistoryStorage.class.getName()); } } else { LOG.warn("Failed to execute refreshLoadedJobCache: JobHistory service is not started"); } } JobHistory(); @Override String getApplicationName(); @Override Job getJob(JobId jobId); @Override Map<JobId, Job> getAllJobs(ApplicationId appID); @Override Map<JobId, Job> getAllJobs(); void refreshLoadedJobCache(); @Override JobsInfo getPartialJobs(Long offset, Long count, String user,
      String queue, Long sBegin, Long sEnd, Long fBegin, Long fEnd,
      JobState jobState); void refreshJobRetentionSettings(); long getCleanerInterval(); @Override ApplicationAttemptId getApplicationAttemptId(); @Override ApplicationId getApplicationID(); @Override EventHandler getEventHandler(); @Override CharSequence getUser(); @Override Clock getClock(); @Override ClusterInfo getClusterInfo(); @Override Set<String> getBlacklistedNodes(); @Override ClientToAMTokenSecretManager getClientToAMTokenSecretManager(); @Override boolean isLastAMRetry(); @Override boolean hasSuccessfullyUnregistered(); @Override String getNMHostname(); }
JobHistory extends AbstractService implements HistoryContext { public void refreshLoadedJobCache() { if (getServiceState() == STATE.STARTED) { if (storage instanceof CachedHistoryStorage) { ((CachedHistoryStorage) storage).refreshLoadedJobCache(); } else { throw new UnsupportedOperationException(storage.getClass().getName() + " is expected to be an instance of " + CachedHistoryStorage.class.getName()); } } else { LOG.warn("Failed to execute refreshLoadedJobCache: JobHistory service is not started"); } } JobHistory(); @Override String getApplicationName(); @Override Job getJob(JobId jobId); @Override Map<JobId, Job> getAllJobs(ApplicationId appID); @Override Map<JobId, Job> getAllJobs(); void refreshLoadedJobCache(); @Override JobsInfo getPartialJobs(Long offset, Long count, String user,
      String queue, Long sBegin, Long sEnd, Long fBegin, Long fEnd,
      JobState jobState); void refreshJobRetentionSettings(); long getCleanerInterval(); @Override ApplicationAttemptId getApplicationAttemptId(); @Override ApplicationId getApplicationID(); @Override EventHandler getEventHandler(); @Override CharSequence getUser(); @Override Clock getClock(); @Override ClusterInfo getClusterInfo(); @Override Set<String> getBlacklistedNodes(); @Override ClientToAMTokenSecretManager getClientToAMTokenSecretManager(); @Override boolean isLastAMRetry(); @Override boolean hasSuccessfullyUnregistered(); @Override String getNMHostname(); static final Pattern CONF_FILENAME_REGEX; static final String OLD_SUFFIX; }