github.com/matrixorigin/matrixone@v1.2.0/pkg/hakeeper/checker.go (about)

     1  // Copyright 2021 - 2022 Matrix Origin
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //      http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package hakeeper
    16  
    17  import (
    18  	"github.com/matrixorigin/matrixone/pkg/hakeeper/checkers/util"
    19  	pb "github.com/matrixorigin/matrixone/pkg/pb/logservice"
    20  )
    21  
    22  type IDAllocator interface {
    23  	// Next returns a new ID that can be used as the replica ID of a TN shard or
    24  	// Log shard. When the return boolean value is false, it means no more ID
    25  	// can be allocated at this time.
    26  	Next() (uint64, bool)
    27  	Set(first uint64, last uint64)
    28  	Capacity() uint64
    29  }
    30  
    31  // Checker is the interface suppose to be implemented by HAKeeper's
    32  // coordinator. Checker is supposed to be stateless - Checker is free to
    33  // maintain whatever internal states, but those states should never be
    34  // assumed to be persistent across reboots.
    35  type Checker interface {
    36  	// Check is periodically called by the HAKeeper for checking the cluster
    37  	// health status, a list of Operator instances will be returned describing
    38  	// actions required to ensure the high availability of the cluster.
    39  	Check(alloc util.IDAllocator, state pb.CheckerState) []pb.ScheduleCommand
    40  }
    41  
    42  // BootstrapManager is the interface suppose to be implemented by HAKeeper's
    43  // bootstrap manager.
    44  type BootstrapManager interface {
    45  	Bootstrap(util.IDAllocator, pb.TNState, pb.LogState) ([]pb.ScheduleCommand, error)
    46  
    47  	CheckBootstrap(pb.LogState) bool
    48  }
    49  
    50  type TaskScheduler interface {
    51  	Schedule(cnState pb.CNState, currentTick uint64)
    52  	// StartScheduleCronTask start schedule cron tasks. A timer will be started to pull the latest CronTask
    53  	// from the TaskStore at regular intervals, and a timer will be maintained in memory for all Cron's to be
    54  	// triggered at regular intervals.
    55  	StartScheduleCronTask()
    56  	// StopScheduleCronTask stop schedule cron tasks.
    57  	StopScheduleCronTask()
    58  }