@Override public BlobStore blobStore() { return blobStoreManager.get(config.blobStoreName); } }
@Override public boolean isBlobstoreUsed(final String blobStoreName) { return blobstoreUsageStream(blobStoreName).findAny().isPresent() || blobStoreManager.blobStoreUsageCount(blobStoreName) > 0; }
/** * Delete orphaned blobs for all repositories */ public void delete() { log.info("Starting delete of orphaned blobs for all known blob stores"); blobStoreManager.browse().forEach(this::delete); log.info("Finished deleting orphaned blobs"); }
@Override protected void doStart() throws Exception { blobStoreManager.start(); List<Configuration> configurations = store.list(); // attempt to provision default repositories if allowed if (configurations.isEmpty()) { if (skipDefaultRepositories || !blobStoreManager.exists(DEFAULT_BLOBSTORE_NAME)) { log.debug("Skipping provisioning of default repositories"); return; } // attempt to discover default repository configurations log.debug("No repositories configured; provisioning default repositories"); provisionDefaultRepositories(); configurations = store.list(); // if we still have no repository configurations, complain and stop if (configurations.isEmpty()) { log.debug("No default repositories to provision"); return; } } restoreRepositories(configurations); startRepositories(); }
ConstraintViolation<?> validateBlobStoreNotInGroup(final String blobStoreName) { return blobStoreManager.getParent(blobStoreName).map(groupName -> constraintViolationFactory .createViolation(format("%s.%s.blobStoreName", P_ATTRIBUTES, STORAGE), format("Blob Store '%s' is a member of Blob Store Group '%s' and cannot be set as storage", blobStoreName, groupName))).orElse(null); }
@Override protected void doStop() throws Exception { log.debug("Stopping {} repositories", repositories.size()); for (Repository repository : repositories.values()) { log.debug("Stopping repository: {}", repository); repository.stop(); } log.debug("Destroying {} repositories", repositories.size()); for (Repository repository : repositories.values()) { log.debug("Destroying repository: {}", repository); repository.destroy(); } repositories.clear(); blobStoreManager.stop(); }
private BlobStore getBlobStoreForRepository(final Repository repository) { String blobStoreName = (String) repository.getConfiguration().getAttributes().get(STORAGE_KEY) .get(BLOB_STORE_NAME_KEY); return blobStoreManager.get(blobStoreName); }
@Override protected Object execute() throws Exception { BlobStore blobStore = blobStoreManager.get(getBlobStoreField()); if (blobStore != null) { blobStore.compact(blobStoreUsageChecker); } else { log.warn("Unable to find blob store: {}", getBlobStoreField()); } return null; }
private void blobStoreIntegrityCheck(final boolean integrityCheck, final String blobStoreId) { if (!integrityCheck) { log.warn("Integrity check operation not selected"); return; } BlobStore blobStore = blobStoreManager.get(blobStoreId); if (blobStore == null) { log.error("Unable to find blob store '{}' in the blob store manager", blobStoreId); return; } StreamSupport.stream(repositoryManager.browseForBlobStore(blobStoreId).spliterator(), false) .filter(r -> !(r.getType() instanceof GroupType)) .forEach(repository -> integrityCheckStrategies .getOrDefault(repository.getFormat().getValue(), defaultIntegrityCheckStrategy) .check(repository, blobStore, this::isCanceled) ); }
private void deleteBlob(final Set<String> deletedBlobStores, final BlobRef blobRef) { String blobStoreName = blobRef.getStore(); if (deletedBlobStores.contains(blobStoreName)) { return; } BlobStore blobStore = blobStoreManager.get(blobRef.getStore()); if (blobStore == null) { if (deletedBlobStores.add(blobStoreName)) { log.info("Not deleting blobs for blob store {}, blob store not found", blobStoreName); } return; } try { blobStore.delete(blobRef.getBlobId(), "Deleting Bucket"); } catch (InvalidStateException e) { if (deletedBlobStores.add(blobStoreName)) { log.info("Not deleting blobs for blob store {}, invalid state {}", blobStoreName, e.getInvalidState(), log.isDebugEnabled() ? e : null); } } catch (Exception e) { log.warn("Error deleting blob {}, skipping", blobRef, e); } } }
@Override public TempBlob createTempBlob(final InputStream inputStream, final Iterable<HashAlgorithm> hashAlgorithms) { BlobStore blobStore = checkNotNull(blobStoreManager.get(config.blobStoreName)); MultiHashingInputStream hashingStream = new MultiHashingInputStream(hashAlgorithms, inputStream); Blob blob = blobStore.create(hashingStream, ImmutableMap.of( BlobStore.BLOB_NAME_HEADER, "temp", BlobStore.CREATED_BY_HEADER, createdBy(), BlobStore.CREATED_BY_IP_HEADER, createdByIp(), BlobStore.TEMPORARY_BLOB_HEADER, "")); return new TempBlob(blob, hashingStream.hashes(), true, blobStore); }
BlobStore store = blobStoreManager.get(blobStoreName);
.filter(asset -> Strings2.isEmpty(asset.createdBy())) .filter(asset -> asset.blobRef() != null).map(asset -> { BlobStore blobStore = blobStoreManager.get(asset.blobRef().getStore()); Blob blob = blobStore.get(asset.blobRef().getBlobId()); if (blob != null) {
@Override protected void doDelete() throws Exception { // skip when replicating, origin node will delete the bucket blobs if (!EventHelper.isReplicating()) { inTxRetry(databaseInstanceProvider).run(db -> { Bucket bucket = bucketEntityAdapter.read(db, getRepository().getName()); storageFacetManager.enqueueDeletion(getRepository(), blobStoreManager.get(config.blobStoreName), bucket); }); } }
@TransactionalStoreMetadata protected void doCreateAssetFromBlob(final RestoreBlobData blobData, final T restoreData, final Blob blob) throws IOException { List<HashAlgorithm> hashTypes = getHashAlgorithms(); AssetBlob assetBlob = new AssetBlob(nodeAccess, blobStoreManager.get(blobData.getBlobStoreName()), blobStore -> blob, blobData.getProperty(HEADER_PREFIX + CONTENT_TYPE_HEADER), hash(hashTypes, blob.getInputStream()), true); createAssetFromBlob(assetBlob, restoreData); }
@Nonnull private StorageTx openStorageTx(final ODatabaseDocumentTx db) { BlobStore blobStore = blobStoreManager.get(config.blobStoreName); return StateGuardAspect.around( new StorageTxImpl( createdBy(), createdByIp(), new BlobTx(nodeAccess, blobStore), db, getRepository().getName(), config.writePolicy == null ? WritePolicy.ALLOW : config.writePolicy, writePolicySelector, bucketEntityAdapter, componentEntityAdapter, assetEntityAdapter, config.strictContentTypeValidation, contentValidatorSelector.validator(getRepository()), mimeRulesSourceSelector.ruleSource(getRepository()), componentFactory) ); }