diff --git a/base-kv/base-kv-store-client/src/main/java/com/baidu/bifromq/basekv/client/BaseKVStoreClient.java b/base-kv/base-kv-store-client/src/main/java/com/baidu/bifromq/basekv/client/BaseKVStoreClient.java index f3ddd0137..bca2dece7 100644 --- a/base-kv/base-kv-store-client/src/main/java/com/baidu/bifromq/basekv/client/BaseKVStoreClient.java +++ b/base-kv/base-kv-store-client/src/main/java/com/baidu/bifromq/basekv/client/BaseKVStoreClient.java @@ -29,7 +29,6 @@ import static com.baidu.bifromq.basekv.utils.DescriptorUtil.getEffectiveEpoch; import static com.baidu.bifromq.basekv.utils.DescriptorUtil.toLeaderRanges; import static java.util.Collections.emptyMap; -import static java.util.Collections.emptyNavigableMap; import com.baidu.bifromq.basecrdt.core.api.IORMap; import com.baidu.bifromq.basecrdt.service.ICRDTService; @@ -57,6 +56,7 @@ import com.baidu.bifromq.basekv.store.proto.ReplyCode; import com.baidu.bifromq.basekv.store.proto.TransferLeadershipReply; import com.baidu.bifromq.basekv.store.proto.TransferLeadershipRequest; +import com.baidu.bifromq.basekv.utils.BoundaryUtil; import com.baidu.bifromq.basekv.utils.DescriptorUtil; import com.baidu.bifromq.basekv.utils.KeySpaceDAG; import com.baidu.bifromq.baserpc.BluePrint; @@ -79,6 +79,7 @@ import java.util.List; import java.util.Map; import java.util.NavigableMap; +import java.util.TreeMap; import java.util.Optional; import java.util.Set; import java.util.concurrent.CompletableFuture; @@ -111,7 +112,7 @@ private record ClusterInfo(Map storeDescriptors, private final Subject> storeToServerSubject = BehaviorSubject.createDefault(Maps.newHashMap()); private final Observable clusterInfoObservable; private final BehaviorSubject> effectiveRouterSubject = - BehaviorSubject.createDefault(emptyNavigableMap()); + BehaviorSubject.createDefault(new TreeMap<>(BoundaryUtil::compare)); // key: serverId, val: storeId private volatile Map serverToStoreMap = Maps.newHashMap();