@Test public void stopRecording() throws BusinessException { cmrStorageRecorder = spy(cmrStorageRecorder); when(recordingProperties.getRecordingDataProcessors()).thenReturn(Collections.singleton(dataProcessor)); cmrStorageRecorder.startOrScheduleRecording(storageWriter, recordingProperties); long platformId = 10L; DefaultData defaultData = mock(DefaultData.class); when(defaultData.getPlatformIdent()).thenReturn(platformId); cmrStorageRecorder.record(defaultData); SystemInformationData systemInformationData = mock(SystemInformationData.class); when(storageDataDao.getSystemInformationData(Collections.singleton(platformId))).thenReturn(Collections.singletonList(systemInformationData)); cmrStorageRecorder.stopRecording(); verify(dataProcessor, times(1)).flush(); verify(cmrStorageRecorder, times(1)).record(systemInformationData); assertThat(cmrStorageRecorder.isRecordingOn(), is(false)); }
public synchronized void stopRecording() { if (isRecordingOn()) { if (null != stopRecordingFuture) { if (!stopRecordingFuture.isDone() && !stopRecordingFuture.isCancelled()) { stopRecordingFuture.cancel(false); } stopRecordingFuture = null; } Collection<AbstractDataProcessor> recordingDataProcessors = recordingProperties.getRecordingDataProcessors(); if (null != recordingDataProcessors) { for (AbstractDataProcessor abstractDataProcessor : recordingDataProcessors) { abstractDataProcessor.flush(); } } if (!involvedAgentsSet.isEmpty()) { List<SystemInformationData> toRecord = storageDataDao.getSystemInformationData(involvedAgentsSet); for (SystemInformationData defaultData : toRecord) { record(defaultData); } } involvedAgentsSet.clear(); if (log.isDebugEnabled()) { log.info("Recording stopped for storage: " + getStorageData()); } } else if (isRecordingScheduled()) { if (null != startRecordingFuture) { if (!startRecordingFuture.isDone() && !startRecordingFuture.isCancelled()) { startRecordingFuture.cancel(false); } startRecordingFuture = null; } } storageWriter = null; recordingProperties = null; recordingState = RecordingState.OFF; }
CmrStorageRecorder { public synchronized void stopRecording() { if (isRecordingOn()) { if (null != stopRecordingFuture) { if (!stopRecordingFuture.isDone() && !stopRecordingFuture.isCancelled()) { stopRecordingFuture.cancel(false); } stopRecordingFuture = null; } Collection<AbstractDataProcessor> recordingDataProcessors = recordingProperties.getRecordingDataProcessors(); if (null != recordingDataProcessors) { for (AbstractDataProcessor abstractDataProcessor : recordingDataProcessors) { abstractDataProcessor.flush(); } } if (!involvedAgentsSet.isEmpty()) { List<SystemInformationData> toRecord = storageDataDao.getSystemInformationData(involvedAgentsSet); for (SystemInformationData defaultData : toRecord) { record(defaultData); } } involvedAgentsSet.clear(); if (log.isDebugEnabled()) { log.info("Recording stopped for storage: " + getStorageData()); } } else if (isRecordingScheduled()) { if (null != startRecordingFuture) { if (!startRecordingFuture.isDone() && !startRecordingFuture.isCancelled()) { startRecordingFuture.cancel(false); } startRecordingFuture = null; } } storageWriter = null; recordingProperties = null; recordingState = RecordingState.OFF; } }
CmrStorageRecorder { public synchronized void stopRecording() { if (isRecordingOn()) { if (null != stopRecordingFuture) { if (!stopRecordingFuture.isDone() && !stopRecordingFuture.isCancelled()) { stopRecordingFuture.cancel(false); } stopRecordingFuture = null; } Collection<AbstractDataProcessor> recordingDataProcessors = recordingProperties.getRecordingDataProcessors(); if (null != recordingDataProcessors) { for (AbstractDataProcessor abstractDataProcessor : recordingDataProcessors) { abstractDataProcessor.flush(); } } if (!involvedAgentsSet.isEmpty()) { List<SystemInformationData> toRecord = storageDataDao.getSystemInformationData(involvedAgentsSet); for (SystemInformationData defaultData : toRecord) { record(defaultData); } } involvedAgentsSet.clear(); if (log.isDebugEnabled()) { log.info("Recording stopped for storage: " + getStorageData()); } } else if (isRecordingScheduled()) { if (null != startRecordingFuture) { if (!startRecordingFuture.isDone() && !startRecordingFuture.isCancelled()) { startRecordingFuture.cancel(false); } startRecordingFuture = null; } } storageWriter = null; recordingProperties = null; recordingState = RecordingState.OFF; }  }
CmrStorageRecorder { public synchronized void stopRecording() { if (isRecordingOn()) { if (null != stopRecordingFuture) { if (!stopRecordingFuture.isDone() && !stopRecordingFuture.isCancelled()) { stopRecordingFuture.cancel(false); } stopRecordingFuture = null; } Collection<AbstractDataProcessor> recordingDataProcessors = recordingProperties.getRecordingDataProcessors(); if (null != recordingDataProcessors) { for (AbstractDataProcessor abstractDataProcessor : recordingDataProcessors) { abstractDataProcessor.flush(); } } if (!involvedAgentsSet.isEmpty()) { List<SystemInformationData> toRecord = storageDataDao.getSystemInformationData(involvedAgentsSet); for (SystemInformationData defaultData : toRecord) { record(defaultData); } } involvedAgentsSet.clear(); if (log.isDebugEnabled()) { log.info("Recording stopped for storage: " + getStorageData()); } } else if (isRecordingScheduled()) { if (null != startRecordingFuture) { if (!startRecordingFuture.isDone() && !startRecordingFuture.isCancelled()) { startRecordingFuture.cancel(false); } startRecordingFuture = null; } } storageWriter = null; recordingProperties = null; recordingState = RecordingState.OFF; }  void record(DefaultData defaultData); synchronized void startOrScheduleRecording(final StorageWriter stWriter, final RecordingProperties recProperties); synchronized void stopRecording(); boolean isRecordingOn(); boolean isRecordingScheduled(); RecordingState getRecordingState(); StorageWriter getStorageWriter(); RecordingProperties getRecordingProperties(); }
CmrStorageRecorder { public synchronized void stopRecording() { if (isRecordingOn()) { if (null != stopRecordingFuture) { if (!stopRecordingFuture.isDone() && !stopRecordingFuture.isCancelled()) { stopRecordingFuture.cancel(false); } stopRecordingFuture = null; } Collection<AbstractDataProcessor> recordingDataProcessors = recordingProperties.getRecordingDataProcessors(); if (null != recordingDataProcessors) { for (AbstractDataProcessor abstractDataProcessor : recordingDataProcessors) { abstractDataProcessor.flush(); } } if (!involvedAgentsSet.isEmpty()) { List<SystemInformationData> toRecord = storageDataDao.getSystemInformationData(involvedAgentsSet); for (SystemInformationData defaultData : toRecord) { record(defaultData); } } involvedAgentsSet.clear(); if (log.isDebugEnabled()) { log.info("Recording stopped for storage: " + getStorageData()); } } else if (isRecordingScheduled()) { if (null != startRecordingFuture) { if (!startRecordingFuture.isDone() && !startRecordingFuture.isCancelled()) { startRecordingFuture.cancel(false); } startRecordingFuture = null; } } storageWriter = null; recordingProperties = null; recordingState = RecordingState.OFF; }  void record(DefaultData defaultData); synchronized void startOrScheduleRecording(final StorageWriter stWriter, final RecordingProperties recProperties); synchronized void stopRecording(); boolean isRecordingOn(); boolean isRecordingScheduled(); RecordingState getRecordingState(); StorageWriter getStorageWriter(); RecordingProperties getRecordingProperties();  }