protected void readAction(StorageAction function) { readFunction( (StorageAccessor<Void>) () -> { function.run(); return null; }); }
@Override public boolean layerExists(String layerName) { return readFunction( () -> blobStores .values() .stream() .anyMatch( bs -> bs.config.isEnabled() && bs.liveInstance.layerExists(layerName))); }
@Override public Set<Map<String, String>> getParameters(String layerName) { return readFunction(() -> store(layerName).getParameters(layerName)); }
public Map<String, Optional<Map<String, String>>> getParametersMapping(String layerName) { return readFunction(() -> store(layerName).getParametersMapping(layerName)); }
@Override public String getLayerMetadata(String layerName, String key) { return readFunction(() -> store(layerName).getLayerMetadata(layerName, key)); }
@Override public Set<String> getParameterIds(String layerName) { return readFunction(() -> store(layerName).getParameterIds(layerName)); }
/** Removes the listener from all the enabled blob stores */ @Override public boolean removeListener(BlobStoreListener listener) { return readFunction( () -> { this.listeners.removeListener(listener); return blobStores .values() .stream() .filter(bs -> bs.config.isEnabled()) .map(bs -> bs.liveInstance.removeListener(listener)) .collect(Collectors.reducing((x, y) -> x || y)) // Don't use anyMatch or // findFirst as we don't want it // to shortcut .orElse(false); }); }