@Test public void openStorage() throws IOException, SerializationException, BusinessException { storageData = new StorageData(); storageData.setName("Test"); storageManager.createStorage(storageData); storageManager.openStorage(storageData); assertThat(storageManager.isStorageExisting(storageData), is(true)); assertThat(storageManager.isStorageOpen(storageData), is(true)); assertThat(storageManager.isStorageClosed(storageData), is(false)); assertThat(storageManager.getExistingStorages(), hasSize(1)); assertThat(storageManager.getOpenedStorages(), hasSize(1)); assertThat(storageManager.getReadableStorages(), is(empty())); verify(storageWriterProvider, times(1)).getCmrStorageWriter(); verify(storageWriter, times(1)).prepareForWrite(storageData); }
public StorageWriter openStorage(StorageData storageData) throws IOException, SerializationException, BusinessException { StorageData local = getLocalStorageDataObject(storageData); synchronized (local) { if (isStorageClosed(local)) { throw new BusinessException("Open the storage " + local + ".", StorageErrorCodeEnum.STORAGE_ALREADY_CLOSED); } if (!isStorageOpen(local)) { local.markOpened(); StorageWriter writer = storageWriterProvider.getCmrStorageWriter(); openedStoragesMap.put(local, writer); writer.prepareForWrite(local); writeStorageDataToDisk(local); return writer; } } return null; }
CmrStorageManager extends StorageManager implements ApplicationListener<ContextClosedEvent> { public StorageWriter openStorage(StorageData storageData) throws IOException, SerializationException, BusinessException { StorageData local = getLocalStorageDataObject(storageData); synchronized (local) { if (isStorageClosed(local)) { throw new BusinessException("Open the storage " + local + ".", StorageErrorCodeEnum.STORAGE_ALREADY_CLOSED); } if (!isStorageOpen(local)) { local.markOpened(); StorageWriter writer = storageWriterProvider.getCmrStorageWriter(); openedStoragesMap.put(local, writer); writer.prepareForWrite(local); writeStorageDataToDisk(local); return writer; } } return null; } }
CmrStorageManager extends StorageManager implements ApplicationListener<ContextClosedEvent> { public StorageWriter openStorage(StorageData storageData) throws IOException, SerializationException, BusinessException { StorageData local = getLocalStorageDataObject(storageData); synchronized (local) { if (isStorageClosed(local)) { throw new BusinessException("Open the storage " + local + ".", StorageErrorCodeEnum.STORAGE_ALREADY_CLOSED); } if (!isStorageOpen(local)) { local.markOpened(); StorageWriter writer = storageWriterProvider.getCmrStorageWriter(); openedStoragesMap.put(local, writer); writer.prepareForWrite(local); writeStorageDataToDisk(local); return writer; } } return null; }  }
CmrStorageManager extends StorageManager implements ApplicationListener<ContextClosedEvent> { public StorageWriter openStorage(StorageData storageData) throws IOException, SerializationException, BusinessException { StorageData local = getLocalStorageDataObject(storageData); synchronized (local) { if (isStorageClosed(local)) { throw new BusinessException("Open the storage " + local + ".", StorageErrorCodeEnum.STORAGE_ALREADY_CLOSED); } if (!isStorageOpen(local)) { local.markOpened(); StorageWriter writer = storageWriterProvider.getCmrStorageWriter(); openedStoragesMap.put(local, writer); writer.prepareForWrite(local); writeStorageDataToDisk(local); return writer; } } return null; }  void createStorage(StorageData storageData); StorageWriter openStorage(StorageData storageData); void closeStorage(StorageData storageData); void deleteStorage(StorageData storageData); StorageData getRecordingStorage(); RecordingProperties getRecordingProperties(); RecordingState getRecordingState(); WritingStatus getRecordingStatus(); void startOrScheduleRecording(StorageData storageData, RecordingProperties recordingProperties); void stopRecording(); void record(DefaultData dataToRecord); void writeToStorage(StorageData storageData, Collection<? extends DefaultData> dataToWrite, Collection<AbstractDataProcessor> dataProcessors, boolean synchronously); void copyBufferToStorage(StorageData storageData, List<Long> platformIdents, Collection<AbstractDataProcessor> dataProcessors, boolean autoFinalize); void copyDataToStorage(StorageData storageData, Collection<Long> elementIds, long platformIdent, Set<Long> traceIds, Collection<AbstractDataProcessor> dataProcessors, boolean autoFinalize); StorageData getStorageData(String id); List<StorageData> getExistingStorages(); List<StorageData> getOpenedStorages(); List<StorageData> getReadableStorages(); boolean isStorageOpen(StorageData storageData); boolean isStorageExisting(StorageData storageData); boolean isStorageClosed(StorageData storageData); long getStorageQueuedWriteTaskCount(StorageData storageData); @Override Path getStoragePath(IStorageData storageData); Map<String, Long> getFilesHttpLocation(StorageData storageData, final String extension); void addLabelToStorage(StorageData storageData, AbstractStorageLabel<?> storageLabel, boolean doOverwrite); boolean removeLabelFromStorage(StorageData storageData, AbstractStorageLabel<?> storageLabel); void updateStorageData(StorageData storageData); Map<StorageData, String> getWritersStatus(); void unpackUploadedStorage(final IStorageData packedStorageData); void createStorageFromUploadedDir(final IStorageData localStorageData); String getCachedStorageDataFileLocation(StorageData storageData, int hash); @PostConstruct void postConstruct(); @Override void onApplicationEvent(ContextClosedEvent event); @Override String toString(); }
CmrStorageManager extends StorageManager implements ApplicationListener<ContextClosedEvent> { public StorageWriter openStorage(StorageData storageData) throws IOException, SerializationException, BusinessException { StorageData local = getLocalStorageDataObject(storageData); synchronized (local) { if (isStorageClosed(local)) { throw new BusinessException("Open the storage " + local + ".", StorageErrorCodeEnum.STORAGE_ALREADY_CLOSED); } if (!isStorageOpen(local)) { local.markOpened(); StorageWriter writer = storageWriterProvider.getCmrStorageWriter(); openedStoragesMap.put(local, writer); writer.prepareForWrite(local); writeStorageDataToDisk(local); return writer; } } return null; }  void createStorage(StorageData storageData); StorageWriter openStorage(StorageData storageData); void closeStorage(StorageData storageData); void deleteStorage(StorageData storageData); StorageData getRecordingStorage(); RecordingProperties getRecordingProperties(); RecordingState getRecordingState(); WritingStatus getRecordingStatus(); void startOrScheduleRecording(StorageData storageData, RecordingProperties recordingProperties); void stopRecording(); void record(DefaultData dataToRecord); void writeToStorage(StorageData storageData, Collection<? extends DefaultData> dataToWrite, Collection<AbstractDataProcessor> dataProcessors, boolean synchronously); void copyBufferToStorage(StorageData storageData, List<Long> platformIdents, Collection<AbstractDataProcessor> dataProcessors, boolean autoFinalize); void copyDataToStorage(StorageData storageData, Collection<Long> elementIds, long platformIdent, Set<Long> traceIds, Collection<AbstractDataProcessor> dataProcessors, boolean autoFinalize); StorageData getStorageData(String id); List<StorageData> getExistingStorages(); List<StorageData> getOpenedStorages(); List<StorageData> getReadableStorages(); boolean isStorageOpen(StorageData storageData); boolean isStorageExisting(StorageData storageData); boolean isStorageClosed(StorageData storageData); long getStorageQueuedWriteTaskCount(StorageData storageData); @Override Path getStoragePath(IStorageData storageData); Map<String, Long> getFilesHttpLocation(StorageData storageData, final String extension); void addLabelToStorage(StorageData storageData, AbstractStorageLabel<?> storageLabel, boolean doOverwrite); boolean removeLabelFromStorage(StorageData storageData, AbstractStorageLabel<?> storageLabel); void updateStorageData(StorageData storageData); Map<StorageData, String> getWritersStatus(); void unpackUploadedStorage(final IStorageData packedStorageData); void createStorageFromUploadedDir(final IStorageData localStorageData); String getCachedStorageDataFileLocation(StorageData storageData, int hash); @PostConstruct void postConstruct(); @Override void onApplicationEvent(ContextClosedEvent event); @Override String toString();  }