/** * Identifies if the instance is writable. The writable state is a configuration option and not representative of the * underlying storage implementation. To communicate the underlying implementations status see * {@link #isStorageAvailable()} * * @return {@code true} if the blob store is writable * @since 3.15 */ default boolean isWritable() { return getBlobStoreConfiguration().isWritable(); }
@Override public long blobStoreUsageCount(final String blobStoreName) { long count = 0; for (BlobStore otherBlobStore : stores.values()) { BlobStoreConfiguration otherBlobStoreConfig = otherBlobStore.getBlobStoreConfiguration(); BlobStoreDescriptor otherBlobStoreDescriptor = blobStoreDescriptors.get(otherBlobStoreConfig.getType()); if (otherBlobStoreDescriptor.configHasDependencyOn(otherBlobStoreConfig, blobStoreName)) { count += 1; } } return count; }
private void delete(final BlobStore blobStore) { detect(blobStore, blobId -> { log.info("Deleting orphaned blob {} from blobstore {}", blobId, blobStore.getBlobStoreConfiguration().getName()); blobStore.deleteHard(new BlobId(blobId)); }); }
@Override public void close() { try { blobStore.deleteHard(blob.getId()); } catch (BlobStoreException e) { log.debug("Unable to delete blob {} in blob store {}", blob.getId(), blobStore.getBlobStoreConfiguration().getName(), e); } }
@Override public boolean isPromotable(final String blobStoreName) { BlobStore blobStore = get(blobStoreName); return blobStore != null && blobStore.isGroupable() && blobStore.isWritable() && !store.findParent(blobStore.getBlobStoreConfiguration().getName()).isPresent(); }
/** * The blob reference this instance is pointing to. */ @Nonnull public BlobRef getBlobRef() { return new BlobRef( nodeAccess.getId(), blobStore.getBlobStoreConfiguration().getName(), getBlob().getId().asUniqueString()); }
@Override @Timed public boolean test(final BlobStore blobStore, final BlobId blobId, final String blobName) { BlobRef blobRef = new BlobRef(ANY_NODE, blobStore.getBlobStoreConfiguration().getName(), blobId.asUniqueString()); try (ODatabaseDocumentTx tx = txSupplier.get()) { tx.begin(); List<ODocument> results = tx.command(assetBlobRefQuery).execute(blobName, blobRef.toString()); return !results.isEmpty(); } } }
@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)); }
@Subscribe @AllowConcurrentEvents public void on(final BlobStoreEvent event) { if (isRecording()) { BlobStore blobStore = event.getBlobStore(); BlobStoreConfiguration configuration = blobStore.getBlobStoreConfiguration(); AuditData data = new AuditData(); data.setDomain(DOMAIN); data.setType(type(event.getClass())); data.setContext(configuration.getName()); Map<String, String> attributes = data.getAttributes(); attributes.put("name", configuration.getName()); attributes.put("type", configuration.getType()); record(data); } } }
@Override public void check(final Repository repository, final BlobStore blobStore, final Supplier<Boolean> isCancelled) { log.info("Checking integrity of assets in repository '{}' with blob store '{}'", repository.getName(), blobStore.getBlobStoreConfiguration().getName()); ProgressLogIntervalHelper progressLogger = new ProgressLogIntervalHelper(log, 60); long processed = 0;
@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; }