@Override protected void doStop() throws Exception { blobStore.stop(); entityType = null; }
@Override protected void doStop() throws Exception { if (stores.isEmpty()) { log.debug("No BlobStores defined"); return; } log.debug("Stopping {} BlobStores", stores.size()); for (Map.Entry<String, BlobStore> entry : stores.entrySet()) { String name = entry.getKey(); BlobStore store = entry.getValue(); log.debug("Stopping blob-store: {}", name); store.stop(); // TODO - event publishing } stores.clear(); }
@Subscribe public void on(final BlobStoreConfigurationDeletedEvent event) { handleRemoteOnly(event, evt -> { try { // only delete if tracked String name = evt.getName(); if (stores.containsKey(name)) { BlobStore blobStore = blobStore(name); blobStore.stop(); blobStore.remove(); untrack(name); } } catch (Exception e) { log.warn("delete blob store from remote event failed: {}", evt.getName(), e); } }); }
@Subscribe public void on(final BlobStoreConfigurationUpdatedEvent event) { handleRemoteOnly(event, evt -> { try { // only update if tracked String name = evt.getName(); if (stores.containsKey(name)) { BlobStore blobStore = blobStore(name); blobStore.stop(); blobStore.init(event.getEntity()); blobStore.start(); } } catch (Exception e) { log.warn("update blob store from remote event failed: {}", evt.getName(), e); } }); }
@Override @Guarded(by = STARTED) public void forceDelete(final String name) throws Exception { checkNotNull(name); databaseFreezeService.checkUnfrozen("Unable to delete a BlobStore while database is frozen."); BlobStore blobStore = blobStore(name); log.debug("Deleting BlobStore: {}", name); blobStore.stop(); blobStore.remove(); untrack(name); store.delete(blobStore.getBlobStoreConfiguration()); eventManager.post(new BlobStoreDeletedEvent(blobStore)); }
@Override @Guarded(by = STARTED) public BlobStore update(final BlobStoreConfiguration configuration) throws Exception { checkNotNull(configuration); BlobStore blobStore = get(configuration.getName()); checkNotNull(blobStore); log.debug("Updating BlobStore: {} with attributes: {}", configuration.getName(), configuration.getAttributes()); BlobStoreDescriptor blobStoreDescriptor = blobStoreDescriptors.get(configuration.getType()); blobStoreDescriptor.validateConfig(configuration); BlobStoreConfiguration currentConfig = blobStore.getBlobStoreConfiguration(); blobStore.stop(); try { blobStore.init(configuration); blobStore.start(); store.update(configuration); eventManager.post(new BlobStoreUpdatedEvent(blobStore)); } catch (Exception e) { log.error("Failed to update configuration", e); if (blobStore.isStarted()) { blobStore.stop(); } blobStore.init(currentConfig); blobStore.start(); throw new BlobStoreException("Failed to start blob store with new configuration.", null); } return blobStore; }