Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

*: make code clear by rename isServing to isRunning #6258

Merged
merged 2 commits into from
Apr 3, 2023
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
10 changes: 5 additions & 5 deletions pkg/mcs/resource_manager/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ import (

// Server is the resource manager server, and it implements bs.Server.
type Server struct {
// Server state. 0 is not serving, 1 is serving.
isServing int64
// Server state. 0 is not running, 1 is running.
isRunning int64

ctx context.Context
serverLoopCtx context.Context
Expand Down Expand Up @@ -196,7 +196,7 @@ func (s *Server) campaignLeader() {

// Close closes the server.
func (s *Server) Close() {
if !atomic.CompareAndSwapInt64(&s.isServing, 1, 0) {
if !atomic.CompareAndSwapInt64(&s.isRunning, 1, 0) {
// server is already closed
return
}
Expand Down Expand Up @@ -247,7 +247,7 @@ func (s *Server) IsServing() bool {

// IsClosed checks if the server loop is closed
func (s *Server) IsClosed() bool {
return s != nil && atomic.LoadInt64(&s.isServing) == 0
return s != nil && atomic.LoadInt64(&s.isRunning) == 0
}

// AddServiceReadyCallback adds callbacks when the server becomes the leader, if there is embedded etcd, or the primary otherwise.
Expand Down Expand Up @@ -411,7 +411,7 @@ func (s *Server) startServer() (err error) {
log.Error("failed to regiser the service", zap.String("service-name", utils.ResourceManagerServiceName), errs.ZapError(err))
return err
}
atomic.StoreInt64(&s.isServing, 1)
atomic.StoreInt64(&s.isRunning, 1)
return nil
}

Expand Down
12 changes: 6 additions & 6 deletions pkg/mcs/tso/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ var _ tso.ElectionMember = (*member.Participant)(nil)
type Server struct {
diagnosticspb.DiagnosticsServer

// Server state. 0 is not serving, 1 is serving.
isServing int64
// Server state. 0 is not running, 1 is running.
isRunning int64
// Server start timestamp
startTimestamp int64

Expand Down Expand Up @@ -157,7 +157,7 @@ func (s *Server) Run() error {

// Close closes the server.
func (s *Server) Close() {
if !atomic.CompareAndSwapInt64(&s.isServing, 1, 0) {
if !atomic.CompareAndSwapInt64(&s.isRunning, 1, 0) {
// server is already closed
return
}
Expand Down Expand Up @@ -200,7 +200,7 @@ func (s *Server) AddStartCallback(callbacks ...func()) {
// IsServing implements basicserver. It returns whether the server is the leader
// if there is embedded etcd, or the primary otherwise.
func (s *Server) IsServing() bool {
return atomic.LoadInt64(&s.isServing) == 1 && s.keyspaceGroupManager.GetElectionMember(mcsutils.DefaultKeySpaceGroupID).IsLeader()
return atomic.LoadInt64(&s.isRunning) == 1 && s.keyspaceGroupManager.GetElectionMember(mcsutils.DefaultKeySpaceGroupID).IsLeader()
}

// GetLeaderListenUrls gets service endpoints from the leader in election group.
Expand All @@ -225,7 +225,7 @@ func (s *Server) ClusterID() uint64 {

// IsClosed checks if the server loop is closed
func (s *Server) IsClosed() bool {
return atomic.LoadInt64(&s.isServing) == 0
return atomic.LoadInt64(&s.isRunning) == 0
}

// GetTSOAllocatorManager returns the manager of TSO Allocator.
Expand Down Expand Up @@ -460,7 +460,7 @@ func (s *Server) startServer() (err error) {
return err
}

atomic.StoreInt64(&s.isServing, 1)
atomic.StoreInt64(&s.isRunning, 1)
return nil
}

Expand Down
10 changes: 5 additions & 5 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ var (
type Server struct {
diagnosticspb.DiagnosticsServer

// Server state.
isServing int64
// Server state. 0 is not running, 1 is running.
isRunning int64

// Server start timestamp
startTimestamp int64
Expand Down Expand Up @@ -456,7 +456,7 @@ func (s *Server) startServer(ctx context.Context) error {
}

// Server has started.
atomic.StoreInt64(&s.isServing, 1)
atomic.StoreInt64(&s.isRunning, 1)
serverMaxProcs.Set(float64(runtime.GOMAXPROCS(0)))
return nil
}
Expand All @@ -468,7 +468,7 @@ func (s *Server) AddCloseCallback(callbacks ...func()) {

// Close closes the server.
func (s *Server) Close() {
if !atomic.CompareAndSwapInt64(&s.isServing, 1, 0) {
if !atomic.CompareAndSwapInt64(&s.isRunning, 1, 0) {
// server is already closed
return
}
Expand Down Expand Up @@ -513,7 +513,7 @@ func (s *Server) Close() {

// IsClosed checks whether server is closed or not.
func (s *Server) IsClosed() bool {
return atomic.LoadInt64(&s.isServing) == 0
return atomic.LoadInt64(&s.isRunning) == 0
}

// Run runs the pd server.
Expand Down