/** * {@inheritDoc} */ @Override @MethodLog public List<AbstractStorageLabelType<?>> getAllLabelTypes() { return storageLabelDataDao.getAllLabelTypes(); }
/** * {@inheritDoc} */ @Override @MethodLog public List<AbstractStorageLabel<?>> getAllLabels() { return storageLabelDataDao.getAllLabels(); }
/** * {@inheritDoc} */ @Override @MethodLog public <E> List<AbstractStorageLabel<E>> getLabelSuggestions(AbstractStorageLabelType<E> labeltype) { List<AbstractStorageLabel<E>> results = storageLabelDataDao.getAllLabelsForType(labeltype); return results; }
List<DefaultData> data = storageDataDao.getDataFromIdList(elementIds, platformIdent); toWriteList.addAll(data); List<DefaultData> data = storageDataDao.getDataForTraceIdList(traceIds); toWriteList.addAll(data);
List<SystemInformationData> toRecord = storageDataDao.getSystemInformationData(involvedAgentsSet); for (SystemInformationData defaultData : toRecord) { record(defaultData);
/** * Tests copy buffer action. */ @Test public void copyBufferToStorage() throws IOException, SerializationException, BusinessException { storageData = new StorageData(); storageData.setName("Test"); DefaultData defaultData = mock(DefaultData.class); Timestamp timestamp = mock(Timestamp.class); when(defaultData.getTimeStamp()).thenReturn(timestamp); when(buffer.getOldestElement()).thenReturn(defaultData); List<DefaultData> data = Collections.singletonList(mock(DefaultData.class)); Collection<AbstractDataProcessor> processors = Collections.singleton(mock(AbstractDataProcessor.class)); Long platformId = 10L; List<Long> platformIdents = Collections.singletonList(platformId); storageManager = spy(storageManager); when(storageDataDao.getAllDefaultDataForAgent(eq(platformId), Matchers.<Date> any(), Matchers.<Date> any())).thenReturn(data); // first with no auto-finalize storageManager.copyBufferToStorage(storageData, platformIdents, processors, false); verify(storageDataDao, times(1)).getAllDefaultDataForAgent(eq(platformId), Matchers.<Date> any(), Matchers.<Date> any()); verify(storageManager, times(1)).writeToStorage(storageData, data, processors, true); // first with auto-finalize storageManager.copyBufferToStorage(storageData, platformIdents, processors, true); verify(storageDataDao, times(2)).getAllDefaultDataForAgent(eq(platformId), Matchers.<Date> any(), Matchers.<Date> any()); verify(storageManager, times(2)).writeToStorage(storageData, data, processors, true); assertThat(storageManager.isStorageClosed(storageData), is(true)); }
/** * {@inheritDoc} */ @Override @MethodLog public <E extends AbstractStorageLabelType<?>> List<E> getLabelTypes(Class<E> labelTypeClass) { return storageLabelDataDao.getLabelTypes(labelTypeClass); }
/** * {@inheritDoc} */ @Override @Transactional @MethodLog public void removeLabelType(AbstractStorageLabelType<?> labelType) throws BusinessException { storageLabelDataDao.removeLabelType(labelType); }
/** * {@inheritDoc} * */ @Override @Transactional @MethodLog public void removeLabelFromCmr(AbstractStorageLabel<?> storageLabel, boolean removeFromStoragesAlso) throws BusinessException { storageLabelDataDao.removeLabel(storageLabel); if (removeFromStoragesAlso) { for (StorageData storageData : getExistingStorages()) { removeLabelFromStorage(storageData, storageLabel); } } }
/** * Tests copy data to storage action. */ @SuppressWarnings("unchecked") public void copyDataToStorage() throws IOException, SerializationException, BusinessException { storageData = new StorageData(); storageData.setName("Test"); List<DefaultData> data = Collections.singletonList(mock(DefaultData.class)); List<DefaultData> traceData = Collections.singletonList(mock(DefaultData.class)); Collection<AbstractDataProcessor> processors = Collections.singleton(mock(AbstractDataProcessor.class)); storageManager = spy(storageManager); long platformIdent = 10L; Collection<Long> elementIds = mock(Collection.class); Set<Long> traceIds = mock(Set.class); when(storageDataDao.getDataFromIdList(elementIds, platformIdent)).thenReturn(data); when(storageDataDao.getDataForTraceIdList(traceIds)).thenReturn(traceData); // first with no auto-finalize storageManager.copyDataToStorage(storageData, elementIds, platformIdent, traceIds, processors, false); verify(storageDataDao, times(1)).getDataFromIdList(elementIds, platformIdent); verify(storageManager, times(1)).writeToStorage(storageData, data, processors, true); verify(storageDataDao, times(1)).getDataForTraceIdList(traceIds); verify(storageManager, times(1)).writeToStorage(storageData, traceData, processors, true); // first with auto-finalize storageManager.copyDataToStorage(storageData, elementIds, platformIdent, traceIds, processors, false); verify(storageDataDao, times(2)).getDataFromIdList(elementIds, platformIdent); verify(storageManager, times(2)).writeToStorage(storageData, data, processors, true); verify(storageDataDao, times(2)).getDataForTraceIdList(traceIds); verify(storageManager, times(2)).writeToStorage(storageData, traceData, processors, true); assertThat(storageManager.isStorageClosed(storageData), is(true)); }
/** * Tests that stop recording will correctly flush the data processor and record the system * information data for all recorded platforms. */ @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)); }
List<DefaultData> toWriteList = storageDataDao.getAllDefaultDataForAgent(platformId.longValue(), fromDate, toDate); this.writeToStorage(local, toWriteList, dataProcessors, true);