-
Notifications
You must be signed in to change notification settings - Fork 30
/
shell_cluster_event_logger.go
50 lines (45 loc) · 2.09 KB
/
shell_cluster_event_logger.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package shell
import (
"fmt"
"github.com/chrislusf/vasto/pb"
"github.com/chrislusf/vasto/topology"
)
func (s *shell) OnShardCreateEvent(cluster *topology.Cluster, resource *pb.StoreResource, shardInfo *pb.ShardInfo) {
// fmt.Printf("cluster %v, but shell cluster %v", cluster, s.vastoClient.ClusterListener.GetClusterRing(shardInfo.KeyspaceName))
if *s.option.Keyspace == shardInfo.KeyspaceName {
fmt.Printf("\n+ server %d shard %d %s cluster %s\n> ", shardInfo.ServerId, shardInfo.ShardId, resource.Address, cluster)
} else {
fmt.Printf("\n+ %s %s cluster %s\n> ",
shardInfo.IdentifierOnThisServer(), resource.Address, cluster)
}
}
func (s *shell) OnShardUpdateEvent(cluster *topology.Cluster, resource *pb.StoreResource, shardInfo *pb.ShardInfo, oldShardInfo *pb.ShardInfo) {
if oldShardInfo == nil {
} else if oldShardInfo.Status != shardInfo.Status {
if *s.option.Keyspace == shardInfo.KeyspaceName {
fmt.Printf("\n* server %d shard %d %s cluster %s status:%s=>%s\n> ",
shardInfo.ServerId, shardInfo.ShardId, resource.GetAddress(), cluster,
oldShardInfo.Status, shardInfo.Status)
} else {
fmt.Printf("\n* %s %s cluster %s status:%s=>%s\n> ",
shardInfo.IdentifierOnThisServer(), resource.GetAddress(), cluster,
oldShardInfo.Status, shardInfo.Status)
}
}
}
func (s *shell) OnShardRemoveEvent(cluster *topology.Cluster, resource *pb.StoreResource, shardInfo *pb.ShardInfo) {
if *s.option.Keyspace == shardInfo.KeyspaceName {
fmt.Printf("\n- server %d shard %d %s cluster %s\n> ", shardInfo.ServerId, shardInfo.ShardId, resource.Address, cluster)
} else {
fmt.Printf("\n- %s %s cluster %s\n> ",
shardInfo.IdentifierOnThisServer(), resource.Address, cluster)
}
}
func (s *shell) OnShardPromoteEvent(cluster *topology.Cluster, resource *pb.StoreResource, shardInfo *pb.ShardInfo) {
if *s.option.Keyspace == shardInfo.KeyspaceName {
fmt.Printf("\n=> server %d shard %d %s cluster %s\n> ", shardInfo.ServerId, shardInfo.ShardId, resource.Address, cluster)
} else {
fmt.Printf("\n=> %s %s cluster %s\n> ",
shardInfo.IdentifierOnThisServer(), resource.Address, cluster)
}
}