private void cleanupStoredData() { try { for (final String storageReference: storageReferences) { dataStore.delete(storageReference); } } catch (DataStoreException e) { e.printStackTrace(); } storageReferences.clear(); }
private void writeStoredDocumentFile(SharedDocument document, String storageReference, String messageOutputDir) throws IOException { //retrieve the file InputStream rawFile = null; try { rawFile = dataStore.retrieve(storageReference); } catch (DataStoreException e) { LOGGER.error("Cannot write file to disk. Unable to retrieve file from storage. Folder: " +messageOutputDir); return; } outputHelper.outputStream(messageOutputDir, FileNameHelper.getDocumentOutputFilename(document), rawFile); }
private void initComponentMetrics(final MetricRegistry metrics, final ManagedConfigurationSource config, final ManagedDataStore store, final WorkerCore core) { metrics.register(MetricRegistry.name("config.lookups"), (Gauge<Integer>) config::getConfigurationRequests); metrics.register(MetricRegistry.name("config.errors"), (Gauge<Integer>) config::getConfigurationErrors); if (store.getMetrics() != null) { metrics.register(MetricRegistry.name("store.writes"), (Gauge<Integer>) store.getMetrics()::getStoreRequests); metrics.register(MetricRegistry.name("store.reads"), (Gauge<Integer>) store.getMetrics()::getRetrieveRequests); metrics.register(MetricRegistry.name("store.deletes"), (Gauge<Integer>) store.getMetrics()::getDeleteRequests); metrics.register(MetricRegistry.name("store.errors"), (Gauge<Integer>) store.getMetrics()::getErrors); } if (core.getWorkerQueue().getMetrics() != null) { metrics.register(MetricRegistry.name("queue.received"), (Gauge<Integer>) core.getWorkerQueue().getMetrics()::getMessagesReceived); metrics.register(MetricRegistry.name("queue.published"), (Gauge<Integer>) core.getWorkerQueue().getMetrics()::getMessagesPublished); metrics.register(MetricRegistry.name("queue.rejected"), (Gauge<Integer>) core.getWorkerQueue().getMetrics()::getMessagesRejected); metrics.register(MetricRegistry.name("queue.dropped"), (Gauge<Integer>) core.getWorkerQueue().getMetrics()::getMessagesDropped); metrics.register(MetricRegistry.name("queue.errors"), (Gauge<Integer>) core.getWorkerQueue().getMetrics()::getQueueErrors); } } }
private static String getDataStoreReferenceForFile(FileObject file) throws DataStoreException, IOException { try{ File f = new File(file.getName().getPath()); return dataStore.store(f.toPath(), dataDir); } catch(Exception e){ throw new DataStoreException("Failure storing file. File path: "+file.getName().getPath(), e); } }
private void writeMetadataReference(SharedDocument document, String messageOutputDir, Map.Entry<String, ReferencedData> metadataReference) throws IOException { //retrieve the file String metadataReferenceValue = metadataReference.getValue().getReference(); storageReferences.add(metadataReferenceValue); InputStream rawFile = null; try { rawFile = dataStore.retrieve(metadataReferenceValue); } catch (DataStoreException e) { LOGGER.error("Cannot write file to disk. Unable to retrieve file from storage. Folder: " +messageOutputDir+", reference: "+metadataReferenceValue); return; } outputHelper.outputStream(messageOutputDir, FileNameHelper.getMetadataRefOutputFilename(metadataReference), rawFile); }