Repository: matrixorigin/matrixcube
Pull request #712 (2022-03-17 08:37:17)

refactor event related code & fix typos in comments
**What type of PR is this?**

- [ ] API-change
- [ ] BUG
- [ ] Improvement
- [ ] Documentation
- [ ] Feature
- [ ] Test and CI
- [x] Code Refactoring

**Which issue(s) this PR fixes:**

Fixes #

**What this PR does / why we need it:**

Not Available

**Special notes for your reviewer:**

Not Available

**Additional documentation (e.g. design docs, usage docs, etc.):**

Not Available



Patch:
diff --git a/components/prophet/client.go b/components/prophet/client.go
index dc3b6f9..d0c8f12 100644
--- a/components/prophet/client.go
+++ b/components/prophet/client.go
@@ -53,7 +53,7 @@ type Client interface {
 	ShardHeartbeat(meta metapb.Shard, hb rpcpb.ShardHeartbeatReq) error
 	StoreHeartbeat(hb rpcpb.StoreHeartbeatReq) (rpcpb.StoreHeartbeatRsp, error)
 	AskBatchSplit(res metapb.Shard, count uint32) ([]rpcpb.SplitID, error)
-	NewWatcher(flag uint32) (Watcher, error)
+	NewWatcher(flag uint32) (EventWatcher, error)
 	GetShardHeartbeatRspNotifier() (chan rpcpb.ShardHeartbeatRsp, error)
 	// AsyncAddShards add resources asynchronously. The operation add new resources meta on the
 	// prophet leader cache and embed etcd. And porphet leader has a background goroutine to notify
@@ -345,7 +345,7 @@ func (c *asyncClient) AskBatchSplit(res metapb.Shard, count uint32) ([]rpcpb.Spl
 	return resp.AskBatchSplit.SplitIDs, nil
 }
 
-func (c *asyncClient) NewWatcher(flag uint32) (Watcher, error) {
+func (c *asyncClient) NewWatcher(flag uint32) (EventWatcher, error) {
 	if !c.running() {
 		return nil, ErrClosed
 	}
diff --git a/components/prophet/cluster/cluster.go b/components/prophet/cluster/cluster.go
index baafd65..6ef606e 100644
--- a/components/prophet/cluster/cluster.go
+++ b/components/prophet/cluster/cluster.go
@@ -865,7 +865,7 @@ func (c *RaftCluster) UpdateStoreLabels(containerID uint64, labels []metapb.Labe
 	if container == nil {
 		return fmt.Errorf("invalid container ID %d, not found", containerID)
 	}
-	newStore := container.Meta.CloneValue()
+	newStore := container.Meta
 	newStore.SetLabels(labels)
 	// PutStore will perform label merge.
 	return c.putStoreImpl(newStore, force)
diff --git a/components/prophet/core/shard_option.go b/components/prophet/core/shard_option.go
index 5cd198e..37a78e4 100644
--- a/components/prophet/core/shard_option.go
+++ b/components/prophet/core/shard_option.go
@@ -21,20 +21,20 @@ import (
 	"github.com/matrixorigin/matrixcube/pb/metapb"
 )
 
-// ShardOption is used to select resource.
+// ShardOption is used to select shard.
 type ShardOption func(res *CachedShard) bool
 
-// ShardCreateOption used to create resource.
+// ShardCreateOption used to create shard.
 type ShardCreateOption func(res *CachedShard)
 
-// WithState sets state for the resource.
+// WithState sets state for the shard.
 func WithState(state metapb.ShardState) ShardCreateOption {
 	return func(res *CachedShard) {
 		res.Meta.SetState(state)
 	}
 }
 
-// WithDownPeers sets the down peers for the resource.
+// WithDownPeers sets the down peers for the shard.
 func WithDownPeers(downReplicas []metapb.ReplicaStats) ShardCreateOption {
 	return func(res *CachedShard) {
 		res.downReplicas = append(downReplicas[:0:0], downReplicas...)
@@ -42,7 +42,7 @@ func WithDownPeers(downReplicas []metapb.ReplicaStats) ShardCreateOption {
 	}
 }
 
-// WithPendingPeers sets the pending peers for the resource.
+// WithPendingPeers sets the pending peers for the shard.
 func WithPendingPeers(pendingReplicas []metapb.Replica) ShardCreateOption {
 	return func(res *CachedShard) {
 		res.pendingReplicas = append(pendingReplicas[:0:0], pendingReplicas...)
@@ -50,7 +50,7 @@ func WithPendingPeers(pendingReplicas []metapb.Replica) ShardCreateOption {
 	}
 }
 
-// WithLearners sets the learners for the resource.
+// WithLearners sets the learners for the shard.
 func WithLearners(learners []metapb.Replica) ShardCreateOption {
 	return func(res *CachedShard) {
 		peers := res.Meta.GetReplicas()
@@ -65,35 +65,35 @@ func WithLearners(learners []metapb.Replica) ShardCreateOption {
 	}
 }
 
-// WithLeader sets the leader for the resource.
+// WithLeader sets the leader for the shard.
 func WithLeader(leader *metapb.Replica) ShardCreateOption {
 	return func(res *CachedShard) {
 		res.leader = leader
 	}
 }
 
-// WithStartKey sets the start key for the resource.
+// WithStartKey sets the start key for the shard.
 func WithStartKey(key []byte) ShardCreateOption {
 	return func(res *CachedShard) {
 		res.Meta.SetStartKey(key)
 	}
 }
 
-// WithEndKey sets the end key for the resource.
+// WithEndKey sets the end key for the shard.
 func WithEndKey(key []byte) ShardCreateOption {
 	return func(res *CachedShard) {
 		res.Meta.SetEndKey(key)
 	}
 }
 
-// WithNewShardID sets new id for the resource.
+// WithNewShardID sets new id for the shard.
 func WithNewShardID(id uint64) ShardCreateOption {
 	return func(res *CachedShard) {
 		res.Meta.SetID(id)
 	}
 }
 
-// WithIncVersion increases the version of the resource.
+// WithIncVersion increases the version of the shard.
 func WithIncVersion() ShardCreateOption {
 	return func(res *CachedShard) {
 		e := res.Meta.GetEpoch()
@@ -102,7 +102,7 @@ func WithIncVersion() ShardCreateOption {
 	}
 }
 
-// WithDecVersion decreases the version of the resource.
+// WithDecVersion decreases the version of the shard.
 func WithDecVersion() ShardCreateOption {
 	return func(res *CachedShard) {
 		e := res.Meta.GetEpoch()
@@ -111,7 +111,7 @@ func WithDecVersion() ShardCreateOption {
 	}
 }
 
-// WithIncConfVer increases the config version of the resource.
+// WithIncConfVer increases the config version of the shard.
 func WithIncConfVer() ShardCreateOption {
 	return func(res *CachedShard) {
 		e := res.Meta.GetEpoch()
@@ -120,21 +120,21 @@ func WithIncConfVer() ShardCreateOption {
 	}
 }
 
-// SetWrittenBytes sets the written bytes for the resource.
+// SetWrittenBytes sets the written bytes for the shard.
 func SetWrittenBytes(v uint64) ShardCreateOption {
 	return func(res *CachedShard) {
 		res.stats.WrittenBytes = v
 	}
 }
 
-// SetWrittenKeys sets the written keys for the resource.
+// SetWrittenKeys sets the written keys for the shard.
 func SetWrittenKeys(v uint64) ShardCreateOption {
 	return func(res *CachedShard) {
 		res.stats.WrittenKeys = v
 	}
 }
 
-// WithRemoveStorePeer removes the specified peer for the resource.
+// WithRemoveStorePeer removes the specified peer for the shard.
 func WithRemoveStorePeer(containerID uint64) ShardCreateOption {
 	return func(res *CachedShard) {
 		var peers []metapb.Replica
@@ -147,49 +147,49 @@ func WithRemoveStorePeer(containerID uint64) ShardCreateOption {
 	}
 }
 
-// SetReadBytes sets the read bytes for the resource.
+// SetReadBytes sets the read bytes for the shard.
 func SetReadBytes(v uint64) ShardCreateOption {
 	return func(res *CachedShard) {
 		res.stats.ReadBytes = v
 	}
 }
 
-// SetReadKeys sets the read keys for the resource.
+// SetReadKeys sets the read keys for the shard.
 func SetReadKeys(v uint64) ShardCreateOption {
 	return func(res *CachedShard) {
 		res.stats.ReadKeys = v
 	}
 }
 
-// SetApproximateSize sets the approximate size for the resource.
+// SetApproximateSize sets the approximate size for the shard.
 func SetApproximateSize(v int64) ShardCreateOption {
 	return func(res *CachedShard) {
 		res.stats.ApproximateSize = uint64(v)
 	}
 }
 
-// SetApproximateKeys sets the approximate keys for the resource.
+// SetApproximateKeys sets the approximate keys for the shard.
 func SetApproximateKeys(v int64) ShardCreateOption {
 	return func(res *CachedShard) {
 		res.stats.ApproximateKeys = uint64(v)
 	}
 }
 
-// SetReportInterval sets the report interval for the resource.
+// SetReportInterval sets the report interval for the shard.
 func SetReportInterval(v uint64) ShardCreateOption {
 	return func(res *CachedShard) {
 		res.stats.Interval = &metapb.TimeInterval{Start: 0, End: v}
 	}
 }
 
-// SetPeers sets the peers for the resource.
+// SetPeers sets the peers for the shard.
 func SetPeers(peers []metapb.Replica) ShardCreateOption {
 	return func(res *CachedShard) {
 		res.Meta.SetReplicas(peers)
 	}
 }
 
-// WithAddPeer adds a peer for the resource.
+// WithAddPeer adds a peer for the shard.
 func WithAddPeer(peer metapb.Replica) ShardCreateOption {
 	return func(res *CachedShard) {
 		peers := res.Meta.GetReplicas()
diff --git a/components/prophet/core/shard_tree.go b/components/prophet/core/shard_tree.go
index 4d14f12..c1d9d90 100644
--- a/components/prophet/core/shard_tree.go
+++ b/components/prophet/core/shard_tree.go
@@ -29,7 +29,7 @@ type shardItem struct {
 	shard *CachedShard
 }
 
-// Less returns true if the resource start key is less than the other.
+// Less returns true if the shard start key is less than the other.
 func (r *shardItem) Less(other btree.Item) bool {
 	left := r.shard.GetStartKey()
 	right := other.(*shardItem).shard.GetStartKey()
@@ -63,15 +63,15 @@ func (t *shardTree) length() int {
 	return t.tree.Len()
 }
 
-// getOverlaps gets the shards which are overlapped with the specified resource range.
+// getOverlaps gets the shards which are overlapped with the specified shard range.
 func (t *shardTree) getOverlaps(res *CachedShard) []*CachedShard {
 	item := &shardItem{shard: res}
 
-	// note that find() gets the last item that is less or equal than the resource.
+	// note that find() gets the last item that is less or equal than the shard.
 	// in the case: |_______a_______|_____b_____|___c___|
-	// new resource is   |______d______|
-	// find() will return shardItem of resource_a
-	// and both startKey of resource_a and resource_b are less than endKey of resource_d,
+	// new shard is   |______d______|
+	// find() will return shardItem of shard_a
+	// and both startKey of shard_a and shard_b are less than endKey of shard_d,
 	// thus they are regarded as overlapped shards.
 	result := t.find(res)
 	if result == nil {
@@ -90,9 +90,9 @@ func (t *shardTree) getOverlaps(res *CachedShard) []*CachedShard {
 	return overlaps
 }
 
-// update updates the tree with the resource.
+// update updates the tree with the shard.
 // It finds and deletes all the overlapped shards first, and then
-// insert the resource.
+// insert the shard.
 func (t *shardTree) update(res *CachedShard) []*CachedShard {
 	overlaps := t.getOverlaps(res)
 	for _, item := range overlaps {
@@ -104,9 +104,9 @@ func (t *shardTree) update(res *CachedShard) []*CachedShard {
 	return overlaps
 }
 
-// remove removes a resource if the resource is in the tree.
-// It will do nothing if it cannot find the resource or the found resource
-// is not the same with the resource.
+// remove removes a shard if the shard is in the tree.
+// It will do nothing if it cannot find the shard or the found shard
+// is not the same with the shard.
 func (t *shardTree) remove(res *CachedShard) btree.Item {
 	if t.length() == 0 {
 		return nil
@@ -119,7 +119,7 @@ func (t *shardTree) remove(res *CachedShard) btree.Item {
 	return t.tree.Delete(result)
 }
 
-// search returns a resource that contains the key.
+// search returns a shard that contains the key.
 func (t *shardTree) search(resKey []byte) *CachedShard {
 	res := t.newSearchRes(resKey)
 	result := t.find(res)
@@ -129,7 +129,7 @@ func (t *shardTree) search(resKey []byte) *CachedShard {
 	return result.shard
 }
 
-// searchPrev returns the previous resource of the resource where the resourceKey is located.
+// searchPrev returns the previous shard of the shard where the shardKey is located.
 func (t *shardTree) searchPrev(resKey []byte) *CachedShard {
 	curRes := t.newSearchRes(resKey)
 	curResItem := t.find(curRes)
@@ -164,11 +164,11 @@ func (t *shardTree) find(res *CachedShard) *shardItem {
 	return result
 }
 
-// scanRage scans from the first resource containing or behind the start key
+// scanRage scans from the first shard containing or behind the start key
 // until f return false
 func (t *shardTree) scanRange(startKey []byte, f func(*CachedShard) bool) {
 	res := t.newSearchRes(startKey)
-	// find if there is a resource with key range [s, d), s < startKey < d
+	// find if there is a shard with key range [s, d), s < startKey < d
 	startItem := t.find(res)
 	if startItem == nil {
 		startItem = &shardItem{shard: t.newSearchRes(startKey)}
@@ -198,7 +198,7 @@ func (t *shardTree) getAdjacentShards(res *CachedShard) (*shardItem, *shardItem)
 	return prev, next
 }
 
-// RandomShard is used to get a random resource within ranges.
+// RandomShard is used to get a random shard within ranges.
 func (t *shardTree) RandomShard(ranges []KeyRange) *CachedShard {
 	if t.length() == 0 {
 		return nil
diff --git a/components/prophet/core/store.go b/components/prophet/core/store.go
index 91f81ad..cecbfba 100644
--- a/components/prophet/core/store.go
+++ b/components/prophet/core/store.go
@@ -27,11 +27,11 @@ import (
 )
 
 const (
-	// Interval to save container meta (including heartbeat ts) to etcd.
-	containerPersistInterval = 5 * time.Minute
-	gb                       = 1 << 30 // 1GB size
-	initialMaxShardCounts    = 30      // exclude storage Threshold Filter when resource less than 30
-	initialMinSpace          = 1 << 33 // 2^3=8GB
+	// Interval to save store meta (including heartbeat ts) to etcd.
+	storePersistInterval  = 5 * time.Minute
+	gb                    = 1 << 30 // 1GB size
+	initialMaxShardCounts = 30      // exclude storage Threshold Filter when resource less than 30
+	initialMinSpace       = 1 << 33 // 2^3=8GB
 )
 
 type counterAndSize struct {
@@ -39,7 +39,7 @@ type counterAndSize struct {
 	size  int64
 }
 
-// CachedStore is the container runtime info cached in the cache
+// CachedStore is the store runtime info cached in the cache
 type CachedStore struct {
 	Meta metapb.Store
 	*storeStats
@@ -73,7 +73,7 @@ func NewCachedStore(meta metapb.Store, opts ...StoreCreateOption) *CachedStore {
 // Clone creates a copy of current CachedStore.
 func (cr *CachedStore) Clone(opts ...StoreCreateOption) *CachedStore {
 	store := &CachedStore{
-		Meta:                cr.Meta.CloneValue(),
+		Meta:                cr.Meta,
 		storeStats:          cr.storeStats,
 		pauseLeaderTransfer: cr.pauseLeaderTransfer,
 		shardInfo:           make(map[string]counterAndSize),
@@ -132,13 +132,13 @@ func (cr *CachedStore) ShallowClone(opts ...StoreCreateOption) *CachedStore {
 	return shard
 }
 
-// AllowLeaderTransfer returns if the container is allowed to be selected
+// AllowLeaderTransfer returns if the store is allowed to be selected
 // as source or target of transfer leader.
 func (cr *CachedStore) AllowLeaderTransfer() bool {
 	return !cr.pauseLeaderTransfer
 }
 
-// IsAvailable returns if the container bucket of limitation is available
+// IsAvailable returns if the store bucket of limitation is available
 func (cr *CachedStore) IsAvailable(limitType limit.Type) bool {
 	if cr.available != nil && cr.available[limitType] != nil {
 		return cr.available[limitType]()
@@ -146,17 +146,17 @@ func (cr *CachedStore) IsAvailable(limitType limit.Type) bool {
 	return true
 }
 
-// IsUp checks if the container's state is Up.
+// IsUp checks if the store's state is Up.
 func (cr *CachedStore) IsUp() bool {
 	return cr.GetState() == metapb.StoreState_Up
 }
 
-// IsOffline checks if the container's state is Offline.
+// IsOffline checks if the store's state is Offline.
 func (cr *CachedStore) IsOffline() bool {
 	return cr.GetState() == metapb.StoreState_Down
 }
 
-// IsTombstone checks if the container's state is Tombstone.
+// IsTombstone checks if the store's state is Tombstone.
 func (cr *CachedStore) IsTombstone() bool {
 	return cr.GetState() == metapb.StoreState_StoreTombstone
 }
@@ -171,17 +171,17 @@ func (cr *CachedStore) DownTime() time.Duration {
 	return time.Since(cr.GetLastHeartbeatTS())
 }
 
-// GetState returns the state of the container.
+// GetState returns the state of the store.
 func (cr *CachedStore) GetState() metapb.StoreState {
 	return cr.Meta.GetState()
 }
 
-// GetLeaderCount returns the leader count of the container.
+// GetLeaderCount returns the leader count of the store.
 func (cr *CachedStore) GetLeaderCount(groupKey string) int {
 	return cr.leaderInfo[groupKey].count
 }
 
-// GetTotalLeaderCount returns the leader count of the container.
+// GetTotalLeaderCount returns the leader count of the store.
 func (cr *CachedStore) GetTotalLeaderCount() int {
 	n := 0
 	for _, v := range cr.leaderInfo {
@@ -190,12 +190,12 @@ func (cr *CachedStore) GetTotalLeaderCount() int {
 	return n
 }
 
-// GetShardCount returns the Shard count of the container.
+// GetShardCount returns the Shard count of the store.
 func (cr *CachedStore) GetShardCount(groupKey string) int {
 	return cr.shardInfo[groupKey].count
 }
 
-// GetTotalShardCount returns the Shard count of the container.
+// GetTotalShardCount returns the Shard count of the store.
 func (cr *CachedStore) GetTotalShardCount() int {
 	n := 0
 	for _, v := range cr.shardInfo {
@@ -215,12 +215,12 @@ func (cr *CachedStore) GetGroupKeys() string {
 	return v.String()
 }
 
-// GetLeaderSize returns the leader size of the container.
+// GetLeaderSize returns the leader size of the store.
 func (cr *CachedStore) GetLeaderSize(groupKey string) int64 {
 	return cr.leaderInfo[groupKey].size
 }
 
-// GetTotalLeaderSize returns the leader size of the container.
+// GetTotalLeaderSize returns the leader size of the store.
 func (cr *CachedStore) GetTotalLeaderSize() int64 {
 	n := int64(0)
 	for _, v := range cr.leaderInfo {
@@ -229,12 +229,12 @@ func (cr *CachedStore) GetTotalLeaderSize() int64 {
 	return n
 }
 
-// GetShardSize returns the Shard size of the container.
+// GetShardSize returns the Shard size of the store.
 func (cr *CachedStore) GetShardSize(groupKey string) int64 {
 	return cr.shardInfo[groupKey].size
 }
 
-// GetTotalShardSize returns the Shard size of the container.
+// GetTotalShardSize returns the Shard size of the store.
 func (cr *CachedStore) GetTotalShardSize() int64 {
 	n := int64(0)
 	for _, v := range cr.shardInfo {
@@ -243,7 +243,7 @@ func (cr *CachedStore) GetTotalShardSize() int64 {
 	return n
 }
 
-// GetPendingPeerCount returns the pending peer count of the container.
+// GetPendingPeerCount returns the pending peer count of the store.
 func (cr *CachedStore) GetPendingPeerCount() int {
 	cnt := 0
 	for _, v := range cr.pendingPeerCounts {
@@ -252,29 +252,29 @@ func (cr *CachedStore) GetPendingPeerCount() int {
 	return cnt
 }
 
-// GetLeaderWeight returns the leader weight of the container.
+// GetLeaderWeight returns the leader weight of the store.
 func (cr *CachedStore) GetLeaderWeight() float64 {
 	return cr.leaderWeight
 }
 
-// GetShardWeight returns the Shard weight of the container.
+// GetShardWeight returns the Shard weight of the store.
 func (cr *CachedStore) GetShardWeight() float64 {
 	return cr.shardWeight
 }
 
-// GetLastHeartbeatTS returns the last heartbeat timestamp of the container.
+// GetLastHeartbeatTS returns the last heartbeat timestamp of the store.
 func (cr *CachedStore) GetLastHeartbeatTS() time.Time {
 	return time.Unix(0, cr.Meta.GetLastHeartbeatTime())
 }
 
 // NeedPersist returns if it needs to save to etcd.
 func (cr *CachedStore) NeedPersist() bool {
-	return cr.GetLastHeartbeatTS().Sub(cr.lastPersistTime) > containerPersistInterval
+	return cr.GetLastHeartbeatTS().Sub(cr.lastPersistTime) > storePersistInterval
 }
 
 const minWeight = 1e-6
 
-// LeaderScore returns the container's leader score.
+// LeaderScore returns the store's leader score.
 func (cr *CachedStore) LeaderScore(groupKey string, policy SchedulePolicy, delta int64) float64 {
 	switch policy {
 	case BySize:
@@ -286,10 +286,10 @@ func (cr *CachedStore) LeaderScore(groupKey string, policy SchedulePolicy, delta
 	}
 }
 
-// ShardScore returns the container's resource score.
+// ShardScore returns the store's resource score.
 // Deviation It is used to control the direction of the deviation considered
 // when calculating the resource score. It is set to -1 when it is the source
-// container of balance, 1 when it is the target, and 0 in the rest of cases.
+// store of balance, 1 when it is the target, and 0 in the rest of cases.
 func (cr *CachedStore) ShardScore(groupKey string, highSpaceRatio, lowSpaceRatio float64, delta int64, deviation int) float64 {
 	A := float64(float64(cr.GetAvgAvailable())-float64(deviation)*float64(cr.GetAvailableDeviation())) / gb
 	C := float64(cr.GetCapacity()) / gb
@@ -316,12 +316,12 @@ func (cr *CachedStore) ShardScore(groupKey string, highSpaceRatio, lowSpaceRatio
 	return score / math.Max(cr.GetShardWeight(), minWeight)
 }
 
-// StorageSize returns container's used storage size reported from your storage.
+// StorageSize returns store's used storage size reported from your storage.
 func (cr *CachedStore) StorageSize() uint64 {
 	return cr.GetUsedSize()
 }
 
-// AvailableRatio is container's freeSpace/capacity.
+// AvailableRatio is store's freeSpace/capacity.
 func (cr *CachedStore) AvailableRatio() float64 {
 	if cr.GetCapacity() == 0 {
 		return 0
@@ -329,7 +329,7 @@ func (cr *CachedStore) AvailableRatio() float64 {
 	return float64(cr.GetAvailable()) / float64(cr.GetCapacity())
 }
 
-// IsLowSpace checks if the container is lack of space.
+// IsLowSpace checks if the store is lack of space.
 func (cr *CachedStore) IsLowSpace(lowSpaceRatio float64) bool {
 	if cr.GetStoreStats() == nil {
 		return false
@@ -341,7 +341,7 @@ func (cr *CachedStore) IsLowSpace(lowSpaceRatio float64) bool {
 	return cr.AvailableRatio() < 1-lowSpaceRatio
 }
 
-// ShardCount returns count of leader/resource-replica in the container.
+// ShardCount returns count of leader/resource-replica in the store.
 func (cr *CachedStore) ShardCount(groupKey string, kind metapb.ShardType) uint64 {
 	switch kind {
 	case metapb.ShardType_LeaderOnly:
@@ -353,7 +353,7 @@ func (cr *CachedStore) ShardCount(groupKey string, kind metapb.ShardType) uint64
 	}
 }
 
-// ShardSize returns size of leader/resource-replica in the container
+// ShardSize returns size of leader/resource-replica in the store
 func (cr *CachedStore) ShardSize(groupKey string, kind metapb.ShardType) int64 {
 	switch kind {
 	case metapb.ShardType_LeaderOnly:
@@ -386,23 +386,23 @@ func (cr *CachedStore) ShardWeight(kind metapb.ShardType) float64 {
 }
 
 var (
-	// If a container's last heartbeat is containerDisconnectDuration ago, the container will
+	// If a store's last heartbeat is storeDisconnectDuration ago, the store will
 	// be marked as disconnected state. The value should be greater than storage application's
-	// container heartbeat interval (default 10s).
-	containerDisconnectDuration = 20 * time.Second
-	containerUnhealthyDuration  = 10 * time.Minute
+	// store heartbeat interval (default 10s).
+	storeDisconnectDuration = 20 * time.Second
+	storeUnhealthyDuration  = 10 * time.Minute
 )
 
-// IsDisconnected checks if a container is disconnected, which means Prophet misses
-// storage application's container heartbeat for a short time, maybe caused by process restart or
+// IsDisconnected checks if a store is disconnected, which means Prophet misses
+// storage application's store heartbeat for a short time, maybe caused by process restart or
 // temporary network failure.
 func (cr *CachedStore) IsDisconnected() bool {
-	return cr.DownTime() > containerDisconnectDuration
+	return cr.DownTime() > storeDisconnectDuration
 }
 
-// IsUnhealthy checks if a container is unhealthy.
+// IsUnhealthy checks if a store is unhealthy.
 func (cr *CachedStore) IsUnhealthy() bool {
-	return cr.DownTime() > containerUnhealthyDuration
+	return cr.DownTime() > storeUnhealthyDuration
 }
 
 // GetLabelValue returns a label's value (if exists).
@@ -420,8 +420,8 @@ func (cr *CachedStore) GetLabelValue(key string) string {
 func (cr *CachedStore) CompareLocation(other *CachedStore, labels []string) int {
 	for i, key := range labels {
 		v1, v2 := cr.GetLabelValue(key), other.GetLabelValue(key)
-		// If label is not set, the container is considered at the same location
-		// with any other container.
+		// If label is not set, the store is considered at the same location
+		// with any other store.
 		if v1 != "" && v2 != "" && !strings.EqualFold(v1, v2) {
 			return i
 		}
@@ -432,10 +432,10 @@ func (cr *CachedStore) CompareLocation(other *CachedStore, labels []string) int
 const replicaBaseScore = 100
 
 // DistinctScore returns the score that the other is distinct from the stores.
-// A higher score means the other container is more different from the existed stores.
-func DistinctScore(labels []string, containers []*CachedStore, other *CachedStore) float64 {
+// A higher score means the other store is more different from the existed stores.
+func DistinctScore(labels []string, stores []*CachedStore, other *CachedStore) float64 {
 	var score float64
-	for _, s := range containers {
+	for _, s := range stores {
 		if s.Meta.GetID() == other.Meta.GetID() {
 			continue
 		}
@@ -448,20 +448,21 @@ func DistinctScore(labels []string, containers []*CachedStore, other *CachedStor
 
 // MergeLabels merges the passed in labels with origins, overriding duplicated
 // ones.
+// ones.
 func (cr *CachedStore) MergeLabels(labels []metapb.Label) []metapb.Label {
-	containerLabels := cr.Meta.Clone().GetLabels()
+	storeLabels := cr.Meta.GetLabels()
 L:
 	for _, newLabel := range labels {
-		for idx := range containerLabels {
-			if strings.EqualFold(containerLabels[idx].Key, newLabel.Key) {
-				containerLabels[idx].Value = newLabel.Value
+		for idx := range storeLabels {
+			if strings.EqualFold(storeLabels[idx].Key, newLabel.Key) {
+				storeLabels[idx].Value = newLabel.Value
 				continue L
 			}
 		}
-		containerLabels = append(containerLabels, newLabel)
+		storeLabels = append(storeLabels, newLabel)
 	}
-	res := containerLabels[:0]
-	for _, l := range containerLabels {
+	res := storeLabels[:0]
+	for _, l := range storeLabels {
 		if l.Value != "" {
 			res = append(res, l)
 		}
@@ -469,19 +470,19 @@ L:
 	return res
 }
 
-// StoresContainer contains information about all container.
+// StoresContainer contains information about all stores.
 type StoresContainer struct {
 	stores map[uint64]*CachedStore
 }
 
-// NewCachedStores create a CachedStore with map of containerID to CachedStore
+// NewCachedStores create a CachedStore with map of storeID to CachedStore
 func NewCachedStores() *StoresContainer {
 	return &StoresContainer{
 		stores: make(map[uint64]*CachedStore),
 	}
 }
 
-// GetStore returns CachedStore with the specified containerID.
+// GetStore returns CachedStore with the specified storeID.
 func (s *StoresContainer) GetStore(storeID uint64) *CachedStore {
 	store, ok := s.stores[storeID]
 	if !ok {
@@ -490,12 +491,12 @@ func (s *StoresContainer) GetStore(storeID uint64) *CachedStore {
 	return store
 }
 
-// SetStore sets a CachedStore with containerID.
+// SetStore sets a CachedStore with storeID.
 func (s *StoresContainer) SetStore(store *CachedStore) {
 	s.stores[store.Meta.GetID()] = store
 }
 
-// PauseLeaderTransfer pauses a CachedStore with containerID.
+// PauseLeaderTransfer pauses a CachedStore with storeID.
 func (s *StoresContainer) PauseLeaderTransfer(storeID uint64) error {
 	store, ok := s.stores[storeID]
 	if !ok {
@@ -519,7 +520,7 @@ func (s *StoresContainer) ResumeLeaderTransfer(storeID uint64) {
 	s.stores[storeID] = store.Clone(ResumeLeaderTransfer())
 }
 
-// AttachAvailableFunc attaches f to a specific container.
+// AttachAvailableFunc attaches f to a specific store.
 func (s *StoresContainer) AttachAvailableFunc(storeID uint64, limitType limit.Type, f func() bool) {
 	if store, ok := s.stores[storeID]; ok {
 		s.stores[storeID] = store.Clone(AttachAvailableFunc(limitType, f))
@@ -554,7 +555,7 @@ func (s *StoresContainer) GetStoreCount() int {
 	return len(s.stores)
 }
 
-// UpdateStoreStatus updates the information of the container.
+// UpdateStoreStatus updates the information of the store.
 func (s *StoresContainer) UpdateStoreStatus(groupKey string, storeID uint64, leaderCount int, resourceCount int, pendingPeerCount int, leaderSize int64, resourceSize int64) {
 	if store, ok := s.stores[storeID]; ok {
 		newStore := store.ShallowClone(SetLeaderCount(groupKey, leaderCount),
diff --git a/components/prophet/core/store_option.go b/components/prophet/core/store_option.go
index 7ac7e84..83ccaa7 100644
--- a/components/prophet/core/store_option.go
+++ b/components/prophet/core/store_option.go
@@ -21,193 +21,177 @@ import (
 	"github.com/matrixorigin/matrixcube/pb/metapb"
 )
 
-// StoreCreateOption is used to create container.
-type StoreCreateOption func(container *CachedStore)
+// StoreCreateOption is used to create cachedStore.
+type StoreCreateOption func(cachedStore *CachedStore)
 
-// SetStoreAddress sets the address for the container.
+// SetStoreAddress sets the address for the cachedStore.
 func SetStoreAddress(address, shardAddress string) StoreCreateOption {
-	return func(container *CachedStore) {
-		meta := container.Meta.CloneValue()
-		meta.SetAddrs(address, shardAddress)
-		container.Meta = meta
+	return func(cachedStore *CachedStore) {
+		cachedStore.Meta.SetAddrs(address, shardAddress)
 	}
 }
 
-// SetStoreLabels sets the labels for the container.
+// SetStoreLabels sets the labels for the cachedStore.
 func SetStoreLabels(labels []metapb.Label) StoreCreateOption {
-	return func(container *CachedStore) {
-		meta := container.Meta.CloneValue()
-		meta.SetLabels(labels)
-		container.Meta = meta
+	return func(cachedStore *CachedStore) {
+		cachedStore.Meta.SetLabels(labels)
 	}
 }
 
-// SetStoreStartTime sets the start timestamp for the container.
+// SetStoreStartTime sets the start timestamp for the cachedStore.
 func SetStoreStartTime(startTS int64) StoreCreateOption {
-	return func(container *CachedStore) {
-		meta := container.Meta.CloneValue()
-		meta.SetStartTime(startTS)
-		container.Meta = meta
+	return func(cachedStore *CachedStore) {
+		cachedStore.Meta.SetStartTime(startTS)
 	}
 }
 
-// SetStoreVersion sets the version for the container.
+// SetStoreVersion sets the version for the cachedStore.
 func SetStoreVersion(commitID, version string) StoreCreateOption {
 	return func(cachedStore *CachedStore) {
-		meta := cachedStore.Meta.CloneValue()
-		meta.SetVersionAndCommitID(version, commitID)
-		cachedStore.Meta = meta
+		cachedStore.Meta.SetVersionAndCommitID(version, commitID)
 	}
 }
 
-// SetStoreDeployPath sets the deploy-path for the container.
+// SetStoreDeployPath sets the deploy-path for the cachedStore.
 func SetStoreDeployPath(deployPath string) StoreCreateOption {
-	return func(container *CachedStore) {
-		meta := container.Meta.CloneValue()
-		meta.SetDeployPath(deployPath)
-		container.Meta = meta
+	return func(cachedStore *CachedStore) {
+		cachedStore.Meta.SetDeployPath(deployPath)
 	}
 }
 
-// OfflineStore offline a container
+// OfflineStore offline a cachedStore
 func OfflineStore(physicallyDestroyed bool) StoreCreateOption {
-	return func(container *CachedStore) {
-		meta := container.Meta.CloneValue()
-		meta.SetDestroyed(physicallyDestroyed)
-		meta.SetState(metapb.StoreState_Down)
-		container.Meta = meta
+	return func(cachedStore *CachedStore) {
+		cachedStore.Meta.SetDestroyed(physicallyDestroyed)
+		cachedStore.Meta.SetState(metapb.StoreState_Down)
 	}
 }
 
-// UpStore up a container
+// UpStore up a cachedStore
 func UpStore() StoreCreateOption {
-	return func(container *CachedStore) {
-		meta := container.Meta.CloneValue()
-		meta.SetState(metapb.StoreState_Up)
-		container.Meta = meta
+	return func(cachedStore *CachedStore) {
+		cachedStore.Meta.SetState(metapb.StoreState_Up)
 	}
 }
 
-// TombstoneStore set a container to tombstone.
+// TombstoneStore set a cachedStore to tombstone.
 func TombstoneStore() StoreCreateOption {
-	return func(container *CachedStore) {
-		meta := container.Meta.CloneValue()
-		meta.SetState(metapb.StoreState_StoreTombstone)
-		container.Meta = meta
+	return func(cachedStore *CachedStore) {
+		cachedStore.Meta.SetState(metapb.StoreState_StoreTombstone)
 	}
 }
 
-// PauseLeaderTransfer prevents the container from been selected as source or
-// target container of TransferLeader.
+// PauseLeaderTransfer prevents the cachedStore from been selected as source or
+// target cachedStore of TransferLeader.
 func PauseLeaderTransfer() StoreCreateOption {
-	return func(container *CachedStore) {
-		container.pauseLeaderTransfer = true
+	return func(cachedStore *CachedStore) {
+		cachedStore.pauseLeaderTransfer = true
 	}
 }
 
-// ResumeLeaderTransfer cleans a container's pause state. The container can be selected
+// ResumeLeaderTransfer cleans a cachedStore's pause state. The cachedStore can be selected
 // as source or target of TransferLeader again.
 func ResumeLeaderTransfer() StoreCreateOption {
-	return func(container *CachedStore) {
-		container.pauseLeaderTransfer = false
+	return func(cachedStore *CachedStore) {
+		cachedStore.pauseLeaderTransfer = false
 	}
 }
 
-// SetLeaderCount sets the leader count for the container.
+// SetLeaderCount sets the leader count for the cachedStore.
 func SetLeaderCount(groupKey string, leaderCount int) StoreCreateOption {
-	return func(container *CachedStore) {
-		info := container.leaderInfo[groupKey]
+	return func(cachedStore *CachedStore) {
+		info := cachedStore.leaderInfo[groupKey]
 		info.count = leaderCount
-		container.leaderInfo[groupKey] = info
+		cachedStore.leaderInfo[groupKey] = info
 	}
 }
 
-// SetShardCount sets the Shard count for the container.
+// SetShardCount sets the Shard count for the cachedStore.
 func SetShardCount(groupKey string, resourceCount int) StoreCreateOption {
-	return func(container *CachedStore) {
-		info := container.shardInfo[groupKey]
+	return func(cachedStore *CachedStore) {
+		info := cachedStore.shardInfo[groupKey]
 		info.count = resourceCount
-		container.shardInfo[groupKey] = info
+		cachedStore.shardInfo[groupKey] = info
 	}
 }
 
-// SetPendingPeerCount sets the pending peer count for the container.
+// SetPendingPeerCount sets the pending peer count for the cachedStore.
 func SetPendingPeerCount(groupKey string, pendingPeerCount int) StoreCreateOption {
-	return func(container *CachedStore) {
-		container.pendingPeerCounts[groupKey] = pendingPeerCount
+	return func(cachedStore *CachedStore) {
+		cachedStore.pendingPeerCounts[groupKey] = pendingPeerCount
 	}
 }
 
-// SetLeaderSize sets the leader size for the container.
+// SetLeaderSize sets the leader size for the cachedStore.
 func SetLeaderSize(groupKey string, leaderSize int64) StoreCreateOption {
-	return func(container *CachedStore) {
-		info := container.leaderInfo[groupKey]
+	return func(cachedStore *CachedStore) {
+		info := cachedStore.leaderInfo[groupKey]
 		info.size = leaderSize
-		container.leaderInfo[groupKey] = info
+		cachedStore.leaderInfo[groupKey] = info
 	}
 }
 
-// SetShardSize sets the Shard size for the container.
+// SetShardSize sets the Shard size for the cachedStore.
 func SetShardSize(groupKey string, resourceSize int64) StoreCreateOption {
-	return func(container *CachedStore) {
-		info := container.shardInfo[groupKey]
+	return func(cachedStore *CachedStore) {
+		info := cachedStore.shardInfo[groupKey]
 		info.size = resourceSize
-		container.shardInfo[groupKey] = info
+		cachedStore.shardInfo[groupKey] = info
 	}
 }
 
-// SetLeaderWeight sets the leader weight for the container.
+// SetLeaderWeight sets the leader weight for the cachedStore.
 func SetLeaderWeight(leaderWeight float64) StoreCreateOption {
-	return func(container *CachedStore) {
-		container.leaderWeight = leaderWeight
+	return func(cachedStore *CachedStore) {
+		cachedStore.leaderWeight = leaderWeight
 	}
 }
 
-// SetShardWeight sets the Shard weight for the container.
+// SetShardWeight sets the Shard weight for the cachedStore.
 func SetShardWeight(resourceWeight float64) StoreCreateOption {
-	return func(container *CachedStore) {
-		container.shardWeight = resourceWeight
+	return func(cachedStore *CachedStore) {
+		cachedStore.shardWeight = resourceWeight
 	}
 }
 
-// SetLastHeartbeatTS sets the time of last heartbeat for the container.
+// SetLastHeartbeatTS sets the time of last heartbeat for the cachedStore.
 func SetLastHeartbeatTS(lastHeartbeatTS time.Time) StoreCreateOption {
-	return func(container *CachedStore) {
-		container.Meta.SetLastHeartbeat(lastHeartbeatTS.UnixNano())
+	return func(cachedStore *CachedStore) {
+		cachedStore.Meta.SetLastHeartbeat(lastHeartbeatTS.UnixNano())
 	}
 }
 
 // SetLastPersistTime updates the time of last persistent.
 func SetLastPersistTime(lastPersist time.Time) StoreCreateOption {
-	return func(container *CachedStore) {
-		container.lastPersistTime = lastPersist
+	return func(cachedStore *CachedStore) {
+		cachedStore.lastPersistTime = lastPersist
 	}
 }
 
-// SetStoreStats sets the statistics information for the container.
+// SetStoreStats sets the statistics information for the cachedStore.
 func SetStoreStats(stats *metapb.StoreStats) StoreCreateOption {
-	return func(container *CachedStore) {
-		container.storeStats.updateRawStats(stats)
+	return func(cachedStore *CachedStore) {
+		cachedStore.storeStats.updateRawStats(stats)
 	}
 }
 
-// SetNewStoreStats sets the raw statistics information for the container.
+// SetNewStoreStats sets the raw statistics information for the cachedStore.
 func SetNewStoreStats(stats *metapb.StoreStats) StoreCreateOption {
-	return func(container *CachedStore) {
-		// There is no clone in default container stats, we create new one to avoid modifying others.
+	return func(cachedStore *CachedStore) {
+		// There is no clone in default cachedStore stats, we create new one to avoid modifying others.
 		// And range cluster cannot use HMA because the last value is not cached
-		container.storeStats = &storeStats{
+		cachedStore.storeStats = &storeStats{
 			rawStats: stats,
 		}
 	}
 }
 
-// AttachAvailableFunc attaches a customize function for the container. The function f returns true if the container limit is not exceeded.
+// AttachAvailableFunc attaches a customize function for the cachedStore. The function f returns true if the cachedStore limit is not exceeded.
 func AttachAvailableFunc(limitType limit.Type, f func() bool) StoreCreateOption {
-	return func(container *CachedStore) {
-		if container.available == nil {
-			container.available = make(map[limit.Type]func() bool)
+	return func(cachedStore *CachedStore) {
+		if cachedStore.available == nil {
+			cachedStore.available = make(map[limit.Type]func() bool)
 		}
-		container.available[limitType] = f
+		cachedStore.available[limitType] = f
 	}
 }
diff --git a/components/prophet/core/store_stats.go b/components/prophet/core/store_stats.go
index 6f87e01..378c290 100644
--- a/components/prophet/core/store_stats.go
+++ b/components/prophet/core/store_stats.go
@@ -60,91 +60,91 @@ func (ss *storeStats) updateRawStats(rawStats *metapb.StoreStats) {
 	ss.avgMaxAvailableDeviation.Add(ss.maxAvailableDeviation.Get())
 }
 
-// GetStoreStats returns the statistics information of the container.
+// GetStoreStats returns the statistics information of the store.
 func (ss *storeStats) GetStoreStats() *metapb.StoreStats {
 	ss.mu.RLock()
 	defer ss.mu.RUnlock()
 	return ss.rawStats
 }
 
-// GetCapacity returns the capacity size of the container.
+// GetCapacity returns the capacity size of the store.
 func (ss *storeStats) GetCapacity() uint64 {
 	ss.mu.RLock()
 	defer ss.mu.RUnlock()
 	return ss.rawStats.GetCapacity()
 }
 
-// GetAvailable returns the available size of the container.
+// GetAvailable returns the available size of the store.
 func (ss *storeStats) GetAvailable() uint64 {
 	ss.mu.RLock()
 	defer ss.mu.RUnlock()
 	return ss.rawStats.GetAvailable()
 }
 
-// GetUsedSize returns the used size of the container.
+// GetUsedSize returns the used size of the store.
 func (ss *storeStats) GetUsedSize() uint64 {
 	ss.mu.RLock()
 	defer ss.mu.RUnlock()
 	return ss.rawStats.GetUsedSize()
 }
 
-// GetUsedRatio returns the used ratio of the container.
+// GetUsedRatio returns the used ratio of the store.
 func (ss *storeStats) GetUsedRatio() float64 {
 	ss.mu.RLock()
 	defer ss.mu.RUnlock()
 	return float64(ss.rawStats.GetUsedSize()) / float64(ss.rawStats.GetCapacity())
 }
 
-// GetBytesWritten returns the bytes written for the container during this period.
+// GetBytesWritten returns the bytes written for the store during this period.
 func (ss *storeStats) GetBytesWritten() uint64 {
 	ss.mu.RLock()
 	defer ss.mu.RUnlock()
 	return ss.rawStats.GetWrittenBytes()
 }
 
-// GetBytesRead returns the bytes read for the container during this period.
+// GetBytesRead returns the bytes read for the store during this period.
 func (ss *storeStats) GetBytesRead() uint64 {
 	ss.mu.RLock()
 	defer ss.mu.RUnlock()
 	return ss.rawStats.GetReadBytes()
 }
 
-// GetKeysWritten returns the keys written for the container during this period.
+// GetKeysWritten returns the keys written for the store during this period.
 func (ss *storeStats) GetKeysWritten() uint64 {
 	ss.mu.RLock()
 	defer ss.mu.RUnlock()
 	return ss.rawStats.GetWrittenKeys()
 }
 
-// GetKeysRead returns the keys read for the container during this period.
+// GetKeysRead returns the keys read for the store during this period.
 func (ss *storeStats) GetKeysRead() uint64 {
 	ss.mu.RLock()
 	defer ss.mu.RUnlock()
 	return ss.rawStats.GetReadKeys()
 }
 
-// IsBusy returns if the container is busy.
+// IsBusy returns if the store is busy.
 func (ss *storeStats) IsBusy() bool {
 	ss.mu.RLock()
 	defer ss.mu.RUnlock()
 	return ss.rawStats.GetIsBusy()
 }
 
-// GetSendingSnapCount returns the current sending snapshot count of the container.
+// GetSendingSnapCount returns the current sending snapshot count of the store.
 func (ss *storeStats) GetSendingSnapCount() uint64 {
 	ss.mu.RLock()
 	defer ss.mu.RUnlock()
 	return ss.rawStats.GetSendingSnapCount()
 }
 
-// GetReceivingSnapCount returns the current receiving snapshot count of the container.
+// GetReceivingSnapCount returns the current receiving snapshot count of the store.
 func (ss *storeStats) GetReceivingSnapCount() uint64 {
 	ss.mu.RLock()
 	defer ss.mu.RUnlock()
 	return ss.rawStats.GetReceivingSnapCount()
 }
 
-// GetApplyingSnapCount returns the current applying snapshot count of the container.
+// GetApplyingSnapCount returns the current applying snapshot count of the store.
 func (ss *storeStats) GetApplyingSnapCount() uint64 {
 	ss.mu.RLock()
 	defer ss.mu.RUnlock()
diff --git a/components/prophet/event/event.go b/components/prophet/event/event.go
index 349c1bf..bdd1002 100644
--- a/components/prophet/event/event.go
+++ b/components/prophet/event/event.go
@@ -19,37 +19,38 @@ import (
 )
 
 var (
-	// EventInit event init
-	EventInit uint32 = 1 << 1
-	// EventShard resource event
-	EventShard uint32 = 1 << 2
-	// EventStore container create event
-	EventStore uint32 = 1 << 3
-	// EventShardStats resource stats
-	EventShardStats uint32 = 1 << 4
-	// EventStoreStats container stats
-	EventStoreStats uint32 = 1 << 5
-	// EventFlagAll all event
-	EventFlagAll = 0xffffffff
+	// InitEvent event init
+	InitEvent uint32 = 1 << 1
+	// ShardEvent shard event
+	ShardEvent uint32 = 1 << 2
+	// StoreEvent store creation event
+	StoreEvent uint32 = 1 << 3
+	// ShardStatsEvent shard stats
+	ShardStatsEvent uint32 = 1 << 4
+	// StoreStatsEvent store stats
+	StoreStatsEvent uint32 = 1 << 5
+	// AllEvent all event
+	AllEvent uint32 = 0xffffffff
 
 	names = map[uint32]string{
-		EventInit:       "init",
-		EventShard:      "resource",
-		EventShardStats: "resource-stats",
-		EventStore:      "container",
-		EventStoreStats: "container-stats",
+		InitEvent:       "init",
+		ShardEvent:      "shard",
+		ShardStatsEvent: "shard-stats",
+		StoreEvent:      "store",
+		StoreStatsEvent: "store-stats",
+		AllEvent:        "all",
 	}
 )
 
-// EventTypeName returns event type name
-func EventTypeName(value uint32) string {
+// TypeName returns event type name
+func TypeName(value uint32) string {
 	return names[value]
 }
 
 // Snapshot cache snapshot
 type Snapshot struct {
-	Shards  []*metapb.Shard
-	Stores  []*metapb.Store
+	Shards  []metapb.Shard
+	Stores  []metapb.Store
 	Leaders map[uint64]uint64
 }
 
@@ -84,7 +85,7 @@ func NewInitEvent(snap Snapshot) (*rpcpb.InitEventData, error) {
 	return resp, nil
 }
 
-// NewShardEvent create resource event
+// NewShardEvent create shard event
 func NewShardEvent(target metapb.Shard, leaderID uint64, removed bool, create bool) rpcpb.EventNotify {
 	value, err := target.Marshal()
 	if err != nil {
@@ -92,7 +93,7 @@ func NewShardEvent(target metapb.Shard, leaderID uint64, removed bool, create bo
 	}
 
 	return rpcpb.EventNotify{
-		Type: EventShard,
+		Type: ShardEvent,
 		ShardEvent: &rpcpb.ShardEventData{
 			Data:    value,
 			Leader:  leaderID,
@@ -102,23 +103,23 @@ func NewShardEvent(target metapb.Shard, leaderID uint64, removed bool, create bo
 	}
 }
 
-// NewShardStatsEvent create resource stats event
+// NewShardStatsEvent create shard stats event
 func NewShardStatsEvent(stats *metapb.ShardStats) rpcpb.EventNotify {
 	return rpcpb.EventNotify{
-		Type:            EventShardStats,
+		Type:            ShardStatsEvent,
 		ShardStatsEvent: stats,
 	}
 }
 
-// NewStoreStatsEvent create container stats event
+// NewStoreStatsEvent create store stats event
 func NewStoreStatsEvent(stats *metapb.StoreStats) rpcpb.EventNotify {
 	return rpcpb.EventNotify{
-		Type:            EventStoreStats,
+		Type:            StoreStatsEvent,
 		StoreStatsEvent: stats,
 	}
 }
 
-// NewStoreEvent create container event
+// NewStoreEvent create store event
 func NewStoreEvent(target metapb.Store) rpcpb.EventNotify {
 	value, err := target.Marshal()
 	if err != nil {
@@ -126,7 +127,7 @@ func NewStoreEvent(target metapb.Store) rpcpb.EventNotify {
 	}
 
 	return rpcpb.EventNotify{
-		Type: EventStore,
+		Type: StoreEvent,
 		StoreEvent: &rpcpb.StoreEventData{
 			Data: value,
 		},
diff --git a/components/prophet/prophet_watcher.go b/components/prophet/event_notifier.go
similarity index 78%
rename from components/prophet/prophet_watcher.go
rename to components/prophet/event_notifier.go
index d71072d..f57d133 100644
--- a/components/prophet/prophet_watcher.go
+++ b/components/prophet/event_notifier.go
@@ -45,7 +45,7 @@ func (wt *watcherSession) notify(evt rpcpb.EventNotify) error {
 	return nil
 }
 
-type watcherNotifier struct {
+type eventNotifier struct {
 	sync.Mutex
 
 	logger   *zap.Logger
@@ -54,8 +54,8 @@ type watcherNotifier struct {
 	stopper  *stop.Stopper
 }
 
-func newWatcherNotifier(cluster *cluster.RaftCluster, logger *zap.Logger) *watcherNotifier {
-	wn := &watcherNotifier{
+func newWatcherNotifier(cluster *cluster.RaftCluster, logger *zap.Logger) *eventNotifier {
+	wn := &eventNotifier{
 		logger:   log.Adjust(logger).Named("watch-notify"),
 		cluster:  cluster,
 		watchers: make(map[uint64]*watcherSession),
@@ -64,22 +64,22 @@ func newWatcherNotifier(cluster *cluster.RaftCluster, logger *zap.Logger) *watch
 	return wn
 }
 
-func (wn *watcherNotifier) handleCreateWatcher(req *rpcpb.ProphetRequest, resp *rpcpb.ProphetResponse, session goetty.IOSession) error {
+func (wn *eventNotifier) handleCreateWatcher(req *rpcpb.ProphetRequest, resp *rpcpb.ProphetResponse, session goetty.IOSession) error {
 	if wn != nil {
 		wn.logger.Info("watcher added",
 			zap.String("address", session.RemoteAddr()))
 
 		wn.cluster.RLock()
 		defer wn.cluster.RUnlock()
-		if event.MatchEvent(event.EventInit, req.CreateWatcher.Flag) {
+		if event.MatchEvent(event.InitEvent, req.CreateWatcher.Flag) {
 			snap := event.Snapshot{
 				Leaders: make(map[uint64]uint64),
 			}
 			for _, c := range wn.cluster.GetStores() {
-				snap.Stores = append(snap.Stores, c.Meta.Clone())
+				snap.Stores = append(snap.Stores, c.Meta)
 			}
 			for _, res := range wn.cluster.GetShards() {
-				snap.Shards = append(snap.Shards, res.Meta.Clone())
+				snap.Shards = append(snap.Shards, res.Meta)
 				leader := res.GetLeader()
 				if leader != nil {
 					snap.Leaders[res.Meta.GetID()] = leader.ID
@@ -91,7 +91,7 @@ func (wn *watcherNotifier) handleCreateWatcher(req *rpcpb.ProphetRequest, resp *
 				return err
 			}
 
-			resp.Event.Type = event.EventInit
+			resp.Event.Type = event.InitEvent
 			resp.Event.InitEvent = rsp
 		}
 
@@ -101,7 +101,7 @@ func (wn *watcherNotifier) handleCreateWatcher(req *rpcpb.ProphetRequest, resp *
 	return nil
 }
 
-func (wn *watcherNotifier) addWatcher(flag uint32, session goetty.IOSession) error {
+func (wn *eventNotifier) addWatcher(flag uint32, session goetty.IOSession) error {
 	wn.Lock()
 	defer wn.Unlock()
 
@@ -116,14 +116,14 @@ func (wn *watcherNotifier) addWatcher(flag uint32, session goetty.IOSession) err
 	return nil
 }
 
-func (wn *watcherNotifier) doClearWatcherLocked(w *watcherSession) {
+func (wn *eventNotifier) doClearWatcherLocked(w *watcherSession) {
 	delete(wn.watchers, w.session.ID())
 	w.session.Close()
 	wn.logger.Info("watcher removed",
 		zap.String("address", w.session.RemoteAddr()))
 }
 
-func (wn *watcherNotifier) doNotify(evt rpcpb.EventNotify) {
+func (wn *eventNotifier) doNotify(evt rpcpb.EventNotify) {
 	wn.Lock()
 	defer wn.Unlock()
 
@@ -135,22 +135,22 @@ func (wn *watcherNotifier) doNotify(evt rpcpb.EventNotify) {
 	}
 }
 
-func (wn *watcherNotifier) start() {
+func (wn *eventNotifier) start() {
 	wn.stopper.RunTask(context.Background(), func(ctx context.Context) {
 		eventC := wn.cluster.ChangedEventNotifier()
 		if eventC == nil {
-			wn.logger.Info("watcher notifer exit with nil event channel")
+			wn.logger.Info("watcher notifier exit with nil event channel")
 			return
 		}
 
 		for {
 			select {
 			case <-ctx.Done():
-				wn.logger.Info("watcher notifer exit")
+				wn.logger.Info("watcher notifier exit")
 				return
 			case evt, ok := <-eventC:
 				if !ok {
-					wn.logger.Info("watcher notifer exit with channel closed")
+					wn.logger.Info("watcher notifier exit with channel closed")
 					return
 				}
 				wn.doNotify(evt)
@@ -159,7 +159,7 @@ func (wn *watcherNotifier) start() {
 	})
 }
 
-func (wn *watcherNotifier) stop() {
+func (wn *eventNotifier) stop() {
 	wn.Lock()
 	for _, wt := range wn.watchers {
 		wn.doClearWatcherLocked(wt)
diff --git a/components/prophet/watcher.go b/components/prophet/event_watcher.go
similarity index 95%
rename from components/prophet/watcher.go
rename to components/prophet/event_watcher.go
index 52fbc86..f57c2af 100644
--- a/components/prophet/watcher.go
+++ b/components/prophet/event_watcher.go
@@ -23,11 +23,11 @@ import (
 	"go.uber.org/zap"
 )
 
-// Watcher watcher
-type Watcher interface {
+// EventWatcher event watcher
+type EventWatcher interface {
 	// GetNotify returns event notify channel
 	GetNotify() chan rpcpb.EventNotify
-	// Close close watcher
+	// Close closes watcher
 	Close()
 }
 
@@ -41,7 +41,7 @@ type watcher struct {
 	conn   goetty.IOSession
 }
 
-func newWatcher(flag uint32, client *asyncClient, logger *zap.Logger) Watcher {
+func newWatcher(flag uint32, client *asyncClient, logger *zap.Logger) EventWatcher {
 	ctx, cancel := context.WithCancel(context.Background())
 	w := &watcher{
 		logger: log.Adjust(logger).Named("watcher"),
@@ -139,7 +139,7 @@ func (w *watcher) startReadLoop() {
 			return
 		}
 
-		// we lost some event notify, close the conection, and retry
+		// we lost some events, close the connection, and retry
 		if expectSeq != resp.Event.Seq {
 			w.logger.Error("lost some event notify, close and retry",
 				zap.Uint64("expect", expectSeq),
diff --git a/components/prophet/mock/mockclient/client.go b/components/prophet/mock/mockclient/client.go
index fc4ea0f..e39461c 100644
--- a/components/prophet/mock/mockclient/client.go
+++ b/components/prophet/mock/mockclient/client.go
@@ -280,10 +280,10 @@ func (mr *MockClientMockRecorder) GetStore(containerID interface{}) *gomock.Call
 }
 
 // NewWatcher mocks base method.
-func (m *MockClient) NewWatcher(flag uint32) (prophet.Watcher, error) {
+func (m *MockClient) NewWatcher(flag uint32) (prophet.EventWatcher, error) {
 	m.ctrl.T.Helper()
 	ret := m.ctrl.Call(m, "NewWatcher", flag)
-	ret0, _ := ret[0].(prophet.Watcher)
+	ret0, _ := ret[0].(prophet.EventWatcher)
 	ret1, _ := ret[1].(error)
 	return ret0, ret1
 }
diff --git a/components/prophet/prophet.go b/components/prophet/prophet.go
index bbbc839..ef82aa0 100644
--- a/components/prophet/prophet.go
+++ b/components/prophet/prophet.go
@@ -107,7 +107,7 @@ type defaultProphet struct {
 
 	mu struct {
 		sync.RWMutex
-		wn *watcherNotifier
+		wn *eventNotifier
 	}
 }
 
diff --git a/pb/metapb/meta_ext.go b/pb/metapb/meta_ext.go
index f34cf5e..8bdde19 100644
--- a/pb/metapb/meta_ext.go
+++ b/pb/metapb/meta_ext.go
@@ -121,16 +121,3 @@ func (m *Store) SetState(value StoreState) {
 func (m *Store) SetLastHeartbeat(value int64) {
 	m.LastHeartbeatTime = value
 }
-
-func (m *Store) Clone() *Store {
-	value := &Store{}
-	protoc.MustUnmarshal(value, protoc.MustMarshal(m))
-	return value
-}
-
-// CloneValue clones the shard and returns the value
-func (m Store) CloneValue() Store {
-	var value Store
-	protoc.MustUnmarshal(&value, protoc.MustMarshal(&m))
-	return value
-}
diff --git a/raftstore/router.go b/raftstore/router.go
index 7702e94..5a5af85 100644
--- a/raftstore/router.go
+++ b/raftstore/router.go
@@ -274,9 +274,9 @@ func (r *defaultRouter) handleEvent(evt rpcpb.EventNotify) {
 	defer r.mu.Unlock()
 
 	switch evt.Type {
-	case event.EventInit:
+	case event.InitEvent:
 		r.logger.Info("reset",
-			zap.String("event", event.EventTypeName(evt.Type)),
+			zap.String("event", event.TypeName(evt.Type)),
 			zap.Int("shard-count", len(evt.InitEvent.Shards)),
 			zap.Int("store-count", len(evt.InitEvent.Stores)))
 		for key := range r.mu.keyRanges {
@@ -290,14 +290,14 @@ func (r *defaultRouter) handleEvent(evt rpcpb.EventNotify) {
 		for i, data := range evt.InitEvent.Shards {
 			r.updateShardLocked(data, evt.InitEvent.Leaders[i], false, false)
 		}
-	case event.EventShard:
+	case event.ShardEvent:
 		r.updateShardLocked(evt.ShardEvent.Data, evt.ShardEvent.Leader,
 			evt.ShardEvent.Removed, evt.ShardEvent.Create)
-	case event.EventStore:
+	case event.StoreEvent:
 		r.updateStoreLocked(evt.StoreEvent.Data)
-	case event.EventShardStats:
+	case event.ShardStatsEvent:
 		r.mu.shardStats[evt.ShardStatsEvent.ShardID] = *evt.ShardStatsEvent
-	case event.EventStoreStats:
+	case event.StoreStatsEvent:
 		r.mu.storeStats[evt.StoreStatsEvent.StoreID] = *evt.StoreStatsEvent
 	}
 }
diff --git a/raftstore/store.go b/raftstore/store.go
index c2164c2..6d76c4c 100644
--- a/raftstore/store.go
+++ b/raftstore/store.go
@@ -15,7 +15,6 @@ package raftstore
 
 import (
 	"fmt"
-	"github.com/matrixorigin/matrixcube/pb/rpcpb"
 	"sync"
 	"sync/atomic"
 	"time"
@@ -32,6 +31,7 @@ import (
 	"github.com/matrixorigin/matrixcube/logdb"
 	"github.com/matrixorigin/matrixcube/pb/errorpb"
 	"github.com/matrixorigin/matrixcube/pb/metapb"
+	"github.com/matrixorigin/matrixcube/pb/rpcpb"
 	"github.com/matrixorigin/matrixcube/storage"
 	"github.com/matrixorigin/matrixcube/storage/kv/pebble"
 	"github.com/matrixorigin/matrixcube/transport"
@@ -63,11 +63,11 @@ type Store interface {
 	OnRequest(rpcpb.Request) error
 	// OnRequestWithCB receive a request, and call cb while the request is completed
 	OnRequestWithCB(req rpcpb.Request, cb func(resp rpcpb.ResponseBatch)) error
-	// DataStorage returns a DataStorage of the shard group
+	// DataStorageByGroup returns a DataStorage of the shard group
 	DataStorageByGroup(uint64) storage.DataStorage
 	// MaybeLeader returns the shard replica maybe leader
 	MaybeLeader(uint64) bool
-	// AllocID returns a uint64 id, panic if has a error
+	// MustAllocID returns an uint64 id, panic if it has an error
 	MustAllocID() uint64
 	// Prophet return current prophet instance
 	Prophet() prophet.Prophet
@@ -96,7 +96,7 @@ type store struct {
 	shardsProxy           ShardsProxy
 	router                Router
 	splitChecker          *splitChecker
-	watcher               prophet.Watcher
+	watcher               prophet.EventWatcher
 	vacuumCleaner         *vacuumCleaner
 	createShardsProtector *createShardsProtector
 	keyRanges             sync.Map // group id -> *util.ShardTree
@@ -254,7 +254,7 @@ func (s *store) Stop() {
 		s.workerPool.close()
 		s.logger.Info("worker pool stopped",
 			s.storeField())
-		// worker pool stopped, its now safe to check whether all replicas have been
+		// worker pool stopped, it's now safe to check whether all replicas have been
 		// shutdown, shutdown the replica if it is not stopped.
 		s.forEachReplica(func(pr *replica) bool {
 			if !pr.unloaded() {
@@ -292,7 +292,7 @@ func (s *store) GetRouter() Router {
 }
 
 func (s *store) startRouter() {
-	watcher, err := s.pd.GetClient().NewWatcher(uint32(event.EventFlagAll))
+	watcher, err := s.pd.GetClient().NewWatcher(event.AllEvent)
 	if err != nil {
 		s.logger.Fatal("fail to create router",
 			s.storeField(),
@@ -324,7 +324,7 @@ func (s *store) startRouter() {
 }
 
 func (s *store) Meta() metapb.Store {
-	return *s.meta.Clone()
+	return s.meta
 }
 
 func (s *store) OnRequest(req rpcpb.Request) error {
@@ -596,11 +596,11 @@ func (s *store) getReplica(id uint64, mustLeader bool) *replica {
 	return nil
 }
 
-// In some case, the vote raft msg maybe dropped, so follower node can't response the vote msg
+// In some case, the vote raft msg maybe dropped, so follower node can't respond the vote msg
 // shard a has 3 replicas p1, p2, p3. The p1 split to new shard b
-// case 1: in most sence, p1 apply split raft log is before p2 and p3.
+// case 1: in most case, p1 apply split raft log is before p2 and p3.
 //         At this time, if p2, p3 received the shard b's vote msg,
-//         and this vote will dropped by p2 and p3 node,
+//         and this vote will be dropped by p2 and p3 node,
 //         because shard a and shard b has overlapped range at p2 and p3 node
 // case 2: p2 or p3 apply split log is before p1, we can't mock shard b's vote msg
 func (s *store) cacheDroppedVoteMsg(id uint64, msg metapb.RaftMessage) {
@@ -708,10 +708,10 @@ func checkEpoch(shard Shard, req rpcpb.RequestBatch) bool {
 		return false
 	}
 
-	lastestEpoch := shard.Epoch
+	latestEpoch := shard.Epoch
 	isStale := func(fromEpoch Epoch) bool {
-		return (checkConfVer && fromEpoch.ConfigVer < lastestEpoch.ConfigVer) ||
-			(checkVer && fromEpoch.Generation < lastestEpoch.Generation)
+		return (checkConfVer && fromEpoch.ConfigVer < latestEpoch.ConfigVer) ||
+			(checkVer && fromEpoch.Generation < latestEpoch.Generation)
 	}
 
 	// only check first request, because requests inside a batch have the same epoch


Test patch:
diff --git a/components/prophet/client_test.go b/components/prophet/client_test.go
index bbbe9d3..684477d 100644
--- a/components/prophet/client_test.go
+++ b/components/prophet/client_test.go
@@ -97,13 +97,13 @@ func TestAsyncCreateShards(t *testing.T) {
 	assert.NoError(t, c.PutStore(newTestStoreMeta(3)))
 	_, err = c.StoreHeartbeat(newTestStoreHeartbeat(3, 1))
 	assert.NoError(t, err)
-	w, err := c.NewWatcher(uint32(event.EventFlagAll))
+	w, err := c.NewWatcher(event.AllEvent)
 	assert.NoError(t, err)
 	assert.NoError(t, c.AsyncAddShards(newTestShardMeta(1)))
 
 	select {
 	case e := <-w.GetNotify():
-		assert.Equal(t, event.EventInit, e.Type)
+		assert.Equal(t, event.InitEvent, e.Type)
 	case <-time.After(time.Second):
 		assert.FailNow(t, "timeout")
 	}
diff --git a/components/prophet/cluster/cluster_worker_test.go b/components/prophet/cluster/cluster_worker_test.go
index 0db87aa..946d705 100644
--- a/components/prophet/cluster/cluster_worker_test.go
+++ b/components/prophet/cluster/cluster_worker_test.go
@@ -76,7 +76,7 @@ func TestCreateShards(t *testing.T) {
 
 	cluster.doNotifyCreateShards()
 	e := <-cluster.ChangedEventNotifier()
-	assert.Equal(t, event.EventShard, e.Type)
+	assert.Equal(t, event.ShardEvent, e.Type)
 	assert.True(t, e.ShardEvent.Create)
 
 	for _, res := range cluster.core.WaitingCreateShards {
@@ -121,7 +121,7 @@ func TestCreateShardsRestart(t *testing.T) {
 	assert.Equal(t, 1, len(tc.core.WaitingCreateShards))
 	tc.doNotifyCreateShards()
 	e := <-tc.ChangedEventNotifier()
-	assert.Equal(t, event.EventShard, e.Type)
+	assert.Equal(t, event.ShardEvent, e.Type)
 	assert.True(t, e.ShardEvent.Create)
 }
 
@@ -138,7 +138,7 @@ func TestRemoveShards(t *testing.T) {
 	// add 1,2,3,4,5,6
 	for i := uint64(1); i < n; i++ {
 		cluster.processShardHeartbeat(resources[i])
-		checkNotifyCount(t, nc, event.EventShard, event.EventShardStats)
+		checkNotifyCount(t, nc, event.ShardEvent, event.ShardStatsEvent)
 	}
 
 	removed := []uint64{1, 2, 3, 4, 5}
@@ -149,7 +149,7 @@ func TestRemoveShards(t *testing.T) {
 	assert.Equal(t, uint64(1), cluster.core.DestroyedShards.GetCardinality())
 	assert.True(t, cluster.core.DestroyedShards.Contains(removed[0]))
 	assert.Error(t, cluster.processShardHeartbeat(resources[1]))
-	checkNotifyCount(t, nc, event.EventShard)
+	checkNotifyCount(t, nc, event.ShardEvent)
 
 	_, err = cluster.HandleRemoveShards(&rpcpb.ProphetRequest{
 		RemoveShards: rpcpb.RemoveShardsReq{IDs: removed},
@@ -160,7 +160,7 @@ func TestRemoveShards(t *testing.T) {
 		RemoveShards: rpcpb.RemoveShardsReq{IDs: removed[1:]},
 	})
 	assert.NoError(t, err)
-	checkNotifyCount(t, nc, event.EventShard, event.EventShard, event.EventShard, event.EventShard)
+	checkNotifyCount(t, nc, event.ShardEvent, event.ShardEvent, event.ShardEvent, event.ShardEvent)
 	assert.Equal(t, uint64(5), cluster.core.DestroyedShards.GetCardinality())
 	for _, id := range removed {
 		assert.True(t, cluster.core.DestroyedShards.Contains(id))
diff --git a/raftstore/router_test.go b/raftstore/router_test.go
index 254f82e..bec2e26 100644
--- a/raftstore/router_test.go
+++ b/raftstore/router_test.go
@@ -35,7 +35,7 @@ func TestHandleInitEvent(t *testing.T) {
 	shard := b.CreateShard(1, "100/101,200/201,300/301")
 	store := metapb.Store{ID: 101}
 	e := rpcpb.EventNotify{}
-	e.Type = event.EventInit
+	e.Type = event.InitEvent
 	e.InitEvent = &rpcpb.InitEventData{
 		Shards:  [][]byte{protoc.MustMarshal(&shard)},
 		Stores:  [][]byte{protoc.MustMarshal(&store)},
@@ -62,7 +62,7 @@ func TestHandleShardEvent(t *testing.T) {
 	shard := b.CreateShard(1, "100/101,200/201,300/301")
 
 	e := rpcpb.EventNotify{}
-	e.Type = event.EventShard
+	e.Type = event.ShardEvent
 	e.ShardEvent = &rpcpb.ShardEventData{
 		Data: protoc.MustMarshal(&shard),
 	}
@@ -87,13 +87,13 @@ func TestHandleShardEventWithLeader(t *testing.T) {
 	store := metapb.Store{ID: 101}
 
 	e := rpcpb.EventNotify{}
-	e.Type = event.EventStore
+	e.Type = event.StoreEvent
 	e.StoreEvent = &rpcpb.StoreEventData{
 		Data: protoc.MustMarshal(&store),
 	}
 	r.handleEvent(e)
 
-	e.Type = event.EventShard
+	e.Type = event.ShardEvent
 	e.ShardEvent = &rpcpb.ShardEventData{
 		Data:   protoc.MustMarshal(&shard),
 		Leader: 100,
@@ -120,7 +120,7 @@ func TestHandleShardEventWithMissingLeaderStore(t *testing.T) {
 	store := metapb.Store{ID: 101}
 
 	e := rpcpb.EventNotify{}
-	e.Type = event.EventShard
+	e.Type = event.ShardEvent
 	e.ShardEvent = &rpcpb.ShardEventData{
 		Data:   protoc.MustMarshal(&shard),
 		Leader: 100,
@@ -132,7 +132,7 @@ func TestHandleShardEventWithMissingLeaderStore(t *testing.T) {
 	assert.Equal(t, metapb.Store{}, r.mu.leaders[shard.ID])
 	assert.Equal(t, Replica{ID: 100, StoreID: 101}, r.mu.missingLeaderStoreShards[shard.ID])
 
-	e.Type = event.EventStore
+	e.Type = event.StoreEvent
 	e.StoreEvent = &rpcpb.StoreEventData{
 		Data: protoc.MustMarshal(&store),
 	}
@@ -153,7 +153,7 @@ func TestHandleStoreEvent(t *testing.T) {
 	store := metapb.Store{ID: 101}
 
 	e := rpcpb.EventNotify{}
-	e.Type = event.EventStore
+	e.Type = event.StoreEvent
 	e.StoreEvent = &rpcpb.StoreEventData{
 		Data: protoc.MustMarshal(&store),
 	}