@Test public void objectWriteNoSerializerAvailable() throws InterruptedException { when(serializerQueue.take()).thenReturn(null); storageWriter.writeNonDefaultDataObject(new Object(), "myFile"); verifyZeroInteractions(writingChannelManager, streamProvider, extendedByteBufferOutputStream); }
public boolean writeNonDefaultDataObject(Object object, String fileName) { try { ISerializer serializer = null; try { serializer = serializerQueue.take(); } catch (InterruptedException e1) { Thread.interrupted(); } if (null == serializer) { log.error("Serializer instance could not be obtained."); return false; } Path path = writingFolderPath.resolve(fileName); if (Files.exists(path)) { try { Files.delete(path); } catch (IOException e) { log.error("Exception thrown trying to delete file from disk", e); return false; } } try (OutputStream outputStream = Files.newOutputStream(path, StandardOpenOption.CREATE_NEW)) { Output output = new Output(outputStream); serializer.serialize(object, output); } catch (SerializationException e) { log.error("Serialization for the object " + object + " failed. Data will be skipped.", e); return false; } finally { serializerQueue.add(serializer); } return true; } catch (Throwable throwable) { log.error("Exception occurred while attempting to write data to disk", throwable); return false; } }
StorageWriter implements IWriter { public boolean writeNonDefaultDataObject(Object object, String fileName) { try { ISerializer serializer = null; try { serializer = serializerQueue.take(); } catch (InterruptedException e1) { Thread.interrupted(); } if (null == serializer) { log.error("Serializer instance could not be obtained."); return false; } Path path = writingFolderPath.resolve(fileName); if (Files.exists(path)) { try { Files.delete(path); } catch (IOException e) { log.error("Exception thrown trying to delete file from disk", e); return false; } } try (OutputStream outputStream = Files.newOutputStream(path, StandardOpenOption.CREATE_NEW)) { Output output = new Output(outputStream); serializer.serialize(object, output); } catch (SerializationException e) { log.error("Serialization for the object " + object + " failed. Data will be skipped.", e); return false; } finally { serializerQueue.add(serializer); } return true; } catch (Throwable throwable) { log.error("Exception occurred while attempting to write data to disk", throwable); return false; } } }
StorageWriter implements IWriter { public boolean writeNonDefaultDataObject(Object object, String fileName) { try { ISerializer serializer = null; try { serializer = serializerQueue.take(); } catch (InterruptedException e1) { Thread.interrupted(); } if (null == serializer) { log.error("Serializer instance could not be obtained."); return false; } Path path = writingFolderPath.resolve(fileName); if (Files.exists(path)) { try { Files.delete(path); } catch (IOException e) { log.error("Exception thrown trying to delete file from disk", e); return false; } } try (OutputStream outputStream = Files.newOutputStream(path, StandardOpenOption.CREATE_NEW)) { Output output = new Output(outputStream); serializer.serialize(object, output); } catch (SerializationException e) { log.error("Serialization for the object " + object + " failed. Data will be skipped.", e); return false; } finally { serializerQueue.add(serializer); } return true; } catch (Throwable throwable) { log.error("Exception occurred while attempting to write data to disk", throwable); return false; } }  }
StorageWriter implements IWriter { public boolean writeNonDefaultDataObject(Object object, String fileName) { try { ISerializer serializer = null; try { serializer = serializerQueue.take(); } catch (InterruptedException e1) { Thread.interrupted(); } if (null == serializer) { log.error("Serializer instance could not be obtained."); return false; } Path path = writingFolderPath.resolve(fileName); if (Files.exists(path)) { try { Files.delete(path); } catch (IOException e) { log.error("Exception thrown trying to delete file from disk", e); return false; } } try (OutputStream outputStream = Files.newOutputStream(path, StandardOpenOption.CREATE_NEW)) { Output output = new Output(outputStream); serializer.serialize(object, output); } catch (SerializationException e) { log.error("Serialization for the object " + object + " failed. Data will be skipped.", e); return false; } finally { serializerQueue.add(serializer); } return true; } catch (Throwable throwable) { log.error("Exception occurred while attempting to write data to disk", throwable); return false; } }  Collection<Future<Void>> process(Collection<? extends DefaultData> defaultDataList, Collection<AbstractDataProcessor> processors); void processSynchronously(Collection<? extends DefaultData> defaultDataList, Collection<AbstractDataProcessor> processors); @Override Future<Void> write(DefaultData defaultData); @Override Future<Void> write(DefaultData defaultData, Map<?, ?> kryoPreferences); synchronized boolean prepareForWrite(StorageData storageData); final synchronized void cancel(); final synchronized void closeStorageWriter(); long getQueuedTaskCount(); boolean writeNonDefaultDataObject(Object object, String fileName); Path getWritingFolderPath(); String getExecutorServiceStatus(); boolean isWritingOn(); StorageData getStorageData(); WritingStatus getWritingStatus(); @PostConstruct void postConstruct(); @Override String toString(); }
StorageWriter implements IWriter { public boolean writeNonDefaultDataObject(Object object, String fileName) { try { ISerializer serializer = null; try { serializer = serializerQueue.take(); } catch (InterruptedException e1) { Thread.interrupted(); } if (null == serializer) { log.error("Serializer instance could not be obtained."); return false; } Path path = writingFolderPath.resolve(fileName); if (Files.exists(path)) { try { Files.delete(path); } catch (IOException e) { log.error("Exception thrown trying to delete file from disk", e); return false; } } try (OutputStream outputStream = Files.newOutputStream(path, StandardOpenOption.CREATE_NEW)) { Output output = new Output(outputStream); serializer.serialize(object, output); } catch (SerializationException e) { log.error("Serialization for the object " + object + " failed. Data will be skipped.", e); return false; } finally { serializerQueue.add(serializer); } return true; } catch (Throwable throwable) { log.error("Exception occurred while attempting to write data to disk", throwable); return false; } }  Collection<Future<Void>> process(Collection<? extends DefaultData> defaultDataList, Collection<AbstractDataProcessor> processors); void processSynchronously(Collection<? extends DefaultData> defaultDataList, Collection<AbstractDataProcessor> processors); @Override Future<Void> write(DefaultData defaultData); @Override Future<Void> write(DefaultData defaultData, Map<?, ?> kryoPreferences); synchronized boolean prepareForWrite(StorageData storageData); final synchronized void cancel(); final synchronized void closeStorageWriter(); long getQueuedTaskCount(); boolean writeNonDefaultDataObject(Object object, String fileName); Path getWritingFolderPath(); String getExecutorServiceStatus(); boolean isWritingOn(); StorageData getStorageData(); WritingStatus getWritingStatus(); @PostConstruct void postConstruct(); @Override String toString();  }