From 7389a6fa52a2fedf19ff3c4f83f512fe86c61113 Mon Sep 17 00:00:00 2001 From: Nick Nassar Date: Mon, 24 May 2021 13:07:10 -0400 Subject: [PATCH] Add a profile string to the AppendOnlyStoreBuilder This prevents name collisions when swapping between stores on the fly --- .../uppend/AppendOnlyStoreBuilder.java | 26 ++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/upserve/uppend/AppendOnlyStoreBuilder.java b/src/main/java/com/upserve/uppend/AppendOnlyStoreBuilder.java index 676c9cde..7dde71ed 100644 --- a/src/main/java/com/upserve/uppend/AppendOnlyStoreBuilder.java +++ b/src/main/java/com/upserve/uppend/AppendOnlyStoreBuilder.java @@ -45,17 +45,35 @@ public AppendOnlyStoreBuilder withCacheBuffers(boolean cacheBuffers) { } public AppendOnlyStore build() { - return build(false); + return build(false, null); } - public AppendOnlyStore build(boolean readOnly) { + + /** + * Constructs the store + * + * @param readOnly make the store readonly? + * @param storeProfile Identifier to use for metrics. This should be unique to the server instance to avoid + * name collisions when registering metrics + * @return the new store + */ + public AppendOnlyStore build(boolean readOnly, String storeProfile) { + String rootName = getMetricsRootName(); + if (null != storeProfile) { + rootName = rootName+ "." + storeProfile; + } + if (readOnly) rootName = rootName + ".readonly"; AppendOnlyStore store = new FileAppendOnlyStore(readOnly, this); - if (isStoreMetrics()) store = new AppendOnlyStoreWithMetrics(store, getStoreMetricsRegistry(), getMetricsRootName()); + if (isStoreMetrics()) store = new AppendOnlyStoreWithMetrics(store, getStoreMetricsRegistry(), rootName); return store; } + public AppendOnlyStore build(boolean readOnly) { + return build(readOnly, null); + } + public ReadOnlyAppendOnlyStore buildReadOnly() { - return build(true); + return build(true, null); } public int getBlobsPerBlock() {