snwatcher

package
v0.10.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 4, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package snwatcher is a generated GoMock package.

Index

Constants

View Source
const (
	DefaultTick                  = 100 * time.Millisecond
	DefaultReportInterval        = 10
	DefaultHeartbeatTimeout      = 10
	DefaultHeartbeatDeadline     = 3 * time.Second
	DefaultFailureHandlerTimeout = 1 * time.Second
	DefaultReportDeadline        = 3 * time.Second
)

Variables

This section is empty.

Functions

This section is empty.

Types

type EventHandler

type EventHandler interface {
	// HandleHeartbeatTimeout handles the storage node that is timed out heartbeat deadline.
	HandleHeartbeatTimeout(context.Context, types.StorageNodeID)

	// HandleReport reports the metadata of storage node collected by the repository.
	HandleReport(context.Context, *snpb.StorageNodeMetadataDescriptor)
}

type MockEventHandler

type MockEventHandler struct {
	// contains filtered or unexported fields
}

MockEventHandler is a mock of EventHandler interface.

func NewMockEventHandler

func NewMockEventHandler(ctrl *gomock.Controller) *MockEventHandler

NewMockEventHandler creates a new mock instance.

func (*MockEventHandler) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockEventHandler) HandleHeartbeatTimeout

func (m *MockEventHandler) HandleHeartbeatTimeout(arg0 context.Context, arg1 types.StorageNodeID)

HandleHeartbeatTimeout mocks base method.

func (*MockEventHandler) HandleReport

func (m *MockEventHandler) HandleReport(arg0 context.Context, arg1 *snpb.StorageNodeMetadataDescriptor)

HandleReport mocks base method.

type MockEventHandlerMockRecorder

type MockEventHandlerMockRecorder struct {
	// contains filtered or unexported fields
}

MockEventHandlerMockRecorder is the mock recorder for MockEventHandler.

func (*MockEventHandlerMockRecorder) HandleHeartbeatTimeout

func (mr *MockEventHandlerMockRecorder) HandleHeartbeatTimeout(arg0, arg1 interface{}) *gomock.Call

HandleHeartbeatTimeout indicates an expected call of HandleHeartbeatTimeout.

func (*MockEventHandlerMockRecorder) HandleReport

func (mr *MockEventHandlerMockRecorder) HandleReport(arg0, arg1 interface{}) *gomock.Call

HandleReport indicates an expected call of HandleReport.

type Option

type Option interface {
	// contains filtered or unexported methods
}

func WithClusterMetadataView

func WithClusterMetadataView(cmview mrmanager.ClusterMetadataView) Option

func WithFailureHandlerTimeout added in v0.0.2

func WithFailureHandlerTimeout(failureHandlerTimeout time.Duration) Option

WithFailureHandlerTimeout sets a timeout to handle the heartbeat timeout of the storage node.

func WithHeartbeatCheckDeadline

func WithHeartbeatCheckDeadline(heartbeatCheckTimeout time.Duration) Option

WithHeartbeatCheckDeadline sets a deadline that the watcher checks storage nodes and handles failed storage nodes. If it is too small, the watcher cannot complete checking the heartbeat of all storage nodes in the cluster.

func WithHeartbeatTimeout

func WithHeartbeatTimeout(heartbeatTimeout int) Option

WithHeartbeatTimeout sets the heartbeat timeout, which is a unit of a tick, to decide whether a storage node is live. It should be a positive number. If the tick is 1 second and the heartbeat timeout is 10, the watcher decides that the storage node that has not responded over 10 seconds is failed.

func WithLogger

func WithLogger(logger *zap.Logger) Option

func WithReportDeadline

func WithReportDeadline(reportDeadline time.Duration) Option

WithReportDeadline sets a deadline that the watcher fetches metadata of storage nodes and reports them by using HandleReport. If it is too small, the watcher cannot complete reporting the metadata of all storage nodes in the cluster.

func WithReportInterval

func WithReportInterval(reportInterval int) Option

WithReportInterval sets the interval between each report in a unit of tick. It should be a positive number. If the tick is 1 second and the report interval is 10, the watcher reports metadata of storage nodes every 10 seconds.

func WithStatisticsRepository

func WithStatisticsRepository(statsRepos stats.Repository) Option

func WithStorageNodeManager

func WithStorageNodeManager(snmgr snmanager.StorageNodeManager) Option

func WithStorageNodeWatcherHandler

func WithStorageNodeWatcherHandler(eventHandler EventHandler) Option

func WithTick

func WithTick(tick time.Duration) Option

WithTick sets tick interval of storage node watcher. It fetches cluster metadata from ClusterMetadataView and metadata from all storage nodes at each tick. It can make overload to cluster if the tick is too small. On the other hand, it can be too slow to handle the failure of nodes if the tick is too large.

type StorageNodeWatcher

type StorageNodeWatcher struct {
	// contains filtered or unexported fields
}

StorageNodeWatcher watches storage nodes in a cluster. It finds all storage nodes by fetching metadata from mrmanager.ClusterMetadataView periodically. It, then, calls proto/snpb.GetMetadata to check the health status of all storage nodes. The storage nodes that seem to be stuck are reported by the HandleHeartbeatTimeout method of the EventHandler interface. It also reports metadata of storage nodes by using HandleReport of the EventHandler interface.

func New

func New(opts ...Option) (*StorageNodeWatcher, error)

func (*StorageNodeWatcher) Start

func (snw *StorageNodeWatcher) Start() error

func (*StorageNodeWatcher) Stop

func (snw *StorageNodeWatcher) Stop() error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL