@Override public String getMessage() { final StringJoiner joiner = new StringJoiner(", "); if (blobId != null) { joiner.add("BlobId: " + blobId); } joiner.add(super.getMessage()); if (getCause() != null && getCause().getMessage() != null) { joiner.add("Cause: " + getCause().getMessage()); } return joiner.toString(); } }
public BlobStoreConfiguration copy(String name) { BlobStoreConfiguration clone = new BlobStoreConfiguration(); clone.setName(name); clone.setType(getType()); if (attributes != null && attributes.size() > 0) { String attribsJson; try { attribsJson = MAPPER.writer().writeValueAsString(getAttributes()); } catch (JsonProcessingException e) { throw new BlobStoreException("failed to marshal blob store configuration attributes to JSON", e, null); } Map<String, Map<String,Object>> clonedAttributes; try { clonedAttributes = MAPPER.readValue(attribsJson, new TypeReference<Map<String,Map<String,Object>>>(){}); } catch (IOException e) { throw new BlobStoreException("failed to parse blob store configuration attributes from JSON", e, null); } clone.setAttributes(clonedAttributes); } return clone; }
@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; }