Esempio n. 1
0
 /**
  * Stops recording.
  *
  * @throws SerializationException If serialization fails during write {@link StorageData} to disk.
  * @throws IOException If IOException occurs during write {@link StorageData} to disk.
  * @throws BusinessException If {@link BusinessException} is throw during auto-finalize process.
  */
 public void stopRecording() throws IOException, SerializationException, BusinessException {
   synchronized (this) {
     if (storageRecorder.isRecordingOn() || storageRecorder.isRecordingScheduled()) {
       boolean autoFinalize = storageRecorder.getRecordingProperties().isAutoFinalize();
       StorageWriter storageWriter = storageRecorder.getStorageWriter();
       storageRecorder.stopRecording();
       recorderStorageData.markOpened();
       openedStoragesMap.put(recorderStorageData, storageWriter);
       if (autoFinalize) {
         this.closeStorage(recorderStorageData);
       }
       writeStorageDataToDisk(recorderStorageData);
       recorderStorageData = null; // NOPMD
     }
   }
 }
Esempio n. 2
0
 /**
  * Opens existing storage if it is not already opened.
  *
  * @param storageData Storage to open.
  * @return {@link StorageWriter} created for this storage. Of <code>null</code> if no new writer
  *     is created.
  * @throws IOException If {@link IOException} occurs.
  * @throws SerializationException If exception occurs during update of storage data.
  * @throws BusinessException If provided storage data does not exist or if the storage is closed.
  */
 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;
 }