@Override protected void doStart() throws Exception { blobStore.start(); try (ODatabaseDocumentTx db = databaseInstance.get().connect()) { // register schema entityType = entityAdapter.register(db); } log.info("OrientRawBinaryStore started."); }
@Subscribe public void on(final BlobStoreConfigurationCreatedEvent event) { handleRemoteOnly(event, evt -> { // only create if not tracked String name = evt.getName(); if (!stores.containsKey(name)) { store.list().stream() .filter(c -> c.getName().equals(name)) .findFirst() .ifPresent(c -> { try { BlobStore blobStore = newBlobStore(c); track(name, blobStore); blobStore.start(); } catch (Exception e) { log.warn("create blob store from remote event failed: {}", name, e); } }); } }); }
log.debug("Starting BlobStore: {}", name); try { blobStore.start();
@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 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; }
@Override @Guarded(by = STARTED) public BlobStore create(final BlobStoreConfiguration configuration) throws Exception { checkNotNull(configuration); log.debug("Creating BlobStore: {} with attributes: {}", configuration.getName(), configuration.getAttributes()); BlobStoreDescriptor blobStoreDescriptor = blobStoreDescriptors.get(configuration.getType()); blobStoreDescriptor.validateConfig(configuration); BlobStore blobStore = newBlobStore(configuration); try { store.create(configuration); } catch (Exception e) { try { blobStore.remove(); } catch (Exception removeException) { // if an error occurs on remove log and rethrow original to avoid losing the root cause log.error("Error removing BlobStore {} after create failed", configuration.getName(), removeException); } throw e; } track(configuration.getName(), blobStore); blobStore.start(); eventManager.post(new BlobStoreCreatedEvent(blobStore)); return blobStore; }