implement cluster stubs: cross-node routing, rebalancing, and actor migration
CI / build (pull_request) Successful in 42s
CI / build (pull_request) Successful in 42s
- Fix ConsistentHashPlacement.PlaceActor() to use consistent hash ring - Implement ConsistentHashPlacement.RebalanceShards() to redistribute shards - Implement ClusterManager.handleRebalanceRequest() with actual rebalancing - Implement ClusterManager.handleMigrationRequest() for actor state transfer - Implement ClusterManager.triggerShardRebalancing() to compute and broadcast - Implement DistributedVM.SendMessage() with cross-node NATS routing - Implement DistributedVM.handleRebalanceRequest() to update shard map - Fix route_message handler to check if actor is local before delivery - Update ConsistentHashPlacement.RebalanceShards() test for new behavior - Add handleShardMapUpdate() and broadcastShardMap() to ClusterManager
This commit is contained in:
+20
-4
@@ -650,7 +650,8 @@ func TestConsistentHashPlacement_RebalanceShards(t *testing.T) {
|
||||
placement := &ConsistentHashPlacement{}
|
||||
currentMap := &ShardMap{
|
||||
Version: 1,
|
||||
Shards: map[int][]string{0: {"node-1"}},
|
||||
Shards: map[int][]string{0: {"node-1"}, 1: {"node-1"}, 2: {"node-2"}},
|
||||
Nodes: map[string]NodeInfo{},
|
||||
}
|
||||
nodes := map[string]*NodeInfo{
|
||||
"node-1": {ID: "node-1"},
|
||||
@@ -662,9 +663,24 @@ func TestConsistentHashPlacement_RebalanceShards(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
// Current implementation returns unchanged map
|
||||
if result != currentMap {
|
||||
t.Error("expected same map returned (simplified implementation)")
|
||||
if result == nil {
|
||||
t.Fatal("rebalance returned nil")
|
||||
}
|
||||
if result.Version != currentMap.Version+1 {
|
||||
t.Errorf("expected version %d, got %d", currentMap.Version+1, result.Version)
|
||||
}
|
||||
if len(result.Shards) != len(currentMap.Shards) {
|
||||
t.Errorf("expected %d shards, got %d", len(currentMap.Shards), len(result.Shards))
|
||||
}
|
||||
for shardID, shardNodes := range result.Shards {
|
||||
if len(shardNodes) == 0 {
|
||||
t.Errorf("shard %d has no nodes assigned", shardID)
|
||||
}
|
||||
for _, node := range shardNodes {
|
||||
if _, exists := nodes[node]; !exists {
|
||||
t.Errorf("shard %d assigned to unknown node %s", shardID, node)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user