Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -227,15 +227,15 @@ public final CompletableFuture<Void> delete(String path, Optional<Long> expected
}
// Ensure caches are invalidated before the operation is confirmed
return storeDelete(path, expectedVersion)
.thenRun(() -> {
.thenRunAsync(() -> {
Comment thread
shibd marked this conversation as resolved.
existsCache.synchronous().invalidate(path);
String parent = parent(path);
if (parent != null) {
childrenCache.synchronous().invalidate(parent);
}

metadataCaches.forEach(c -> c.invalidate(path));
});
}, executor);
}

@Override
Expand Down Expand Up @@ -266,7 +266,7 @@ public final CompletableFuture<Stat> put(String path, byte[] data, Optional<Long
}
// Ensure caches are invalidated before the operation is confirmed
return storePut(path, data, optExpectedVersion, options)
.thenApply(stat -> {
.thenApplyAsync(stat -> {
NotificationType type = stat.getVersion() == 0 ? NotificationType.Created
: NotificationType.Modified;
if (type == NotificationType.Created) {
Expand All @@ -279,7 +279,7 @@ public final CompletableFuture<Stat> put(String path, byte[] data, Optional<Long

metadataCaches.forEach(c -> c.refresh(path));
return stat;
});
}, executor);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.NavigableMap;
Expand Down Expand Up @@ -64,6 +65,9 @@ private static class Value {

private static final Map<String, NavigableMap<String, Value>> STATIC_MAPS = new MapMaker()
.weakValues().makeMap();
// Manage all instances to facilitate registration to the same listener
private static final Map<String, Set<AbstractMetadataStore>> STATIC_INSTANCE = new MapMaker()
.weakValues().makeMap();
private static final Map<String, AtomicLong> STATIC_ID_GEN_MAP = new MapMaker()
.weakValues().makeMap();

Expand All @@ -84,6 +88,14 @@ public LocalMemoryMetadataStore(String metadataURL, MetadataStoreConfig metadata
// Use a reference from a shared data set
String name = uri.getHost();
map = STATIC_MAPS.computeIfAbsent(name, __ -> new TreeMap<>());
STATIC_INSTANCE.compute(name, (key, value) -> {
Comment thread
shibd marked this conversation as resolved.
if (value == null) {
value = new HashSet<>();
}
value.forEach(v -> registerListener(v));
value.add(this);
return value;
});
sequentialIdGenerator = STATIC_ID_GEN_MAP.computeIfAbsent(name, __ -> new AtomicLong());
log.info("Created LocalMemoryDataStore for '{}'", name);
}
Expand Down