Skip to content
Merged
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 @@ -126,7 +126,7 @@ final class BaseKVStoreClient implements IBaseKVStoreClient {
// key: storeId
private final Map<String, List<IQueryPipeline>> lnrQueryPplns = Maps.newHashMap();
private final AtomicReference<NavigableMap<Boundary, KVRangeSetting>> effectiveRouter =
new AtomicReference<>(new TreeMap<>(BoundaryUtil::compare));
new AtomicReference<>(Collections.unmodifiableNavigableMap(new TreeMap<>(BoundaryUtil::compare)));

// key: serverId, val: storeId
private volatile Map<String, String> serverToStoreMap = Maps.newHashMap();
Expand Down Expand Up @@ -486,7 +486,7 @@ private boolean refreshRangeRoute(ClusterInfo clusterInfo) {
}
NavigableMap<Boundary, KVRangeSetting> last = effectiveRouter.get();
if (!router.equals(last)) {
effectiveRouter.set(router);
effectiveRouter.set(Collections.unmodifiableNavigableMap(router));
return true;
}
return false;
Expand Down Expand Up @@ -519,7 +519,7 @@ private void patchRouter(String leaderStoreId, KVRangeDescriptor latest) {
}
}
patched.put(setting.boundary, setting);
effectiveRouter.compareAndSet(router, patched);
effectiveRouter.compareAndSet(router, Collections.unmodifiableNavigableMap(patched));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,18 @@
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* under the License.
*/

package org.apache.bifromq.inbox.store;

import static org.apache.bifromq.basekv.client.KVRangeRouterUtil.findByBoundary;
import static org.apache.bifromq.basekv.utils.BoundaryUtil.FULL_BOUNDARY;

import com.google.common.collect.Sets;
import java.util.Collection;
import java.util.concurrent.CompletableFuture;
import lombok.extern.slf4j.Slf4j;
import org.apache.bifromq.basekv.client.IBaseKVStoreClient;
import org.apache.bifromq.basekv.client.KVRangeSetting;
import org.apache.bifromq.basekv.client.exception.BadRequestException;
Expand All @@ -33,9 +37,6 @@
import org.apache.bifromq.inbox.storage.proto.GCReply;
import org.apache.bifromq.inbox.storage.proto.GCRequest;
import org.apache.bifromq.inbox.storage.proto.InboxServiceROCoProcInput;
import java.util.Collection;
import java.util.concurrent.CompletableFuture;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class InboxStoreGCProcessor implements IInboxStoreGCProcessor {
Expand All @@ -49,8 +50,8 @@ public InboxStoreGCProcessor(IBaseKVStoreClient storeClient, String localStoreId

@Override
public final CompletableFuture<Result> gc(long reqId, long now) {
Collection<KVRangeSetting> rangeSettingList = findByBoundary(FULL_BOUNDARY,
storeClient.latestEffectiveRouter());
Collection<KVRangeSetting> rangeSettingList = Sets.newHashSet(findByBoundary(FULL_BOUNDARY,
storeClient.latestEffectiveRouter()));
if (localServerId != null) {
rangeSettingList.removeIf(rangeSetting -> !rangeSetting.leader.equals(localServerId));
}
Expand Down
Loading