worker

package
v0.0.0-...-fa598ba Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MasterClient

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

MasterClient is used by the BaseWorker to communicate with

func NewMasterClient

func NewMasterClient(
	masterID frameModel.MasterID,
	workerID frameModel.WorkerID,
	messageSender p2p.MessageSender,
	metaCli pkgOrm.Client,
	initTime clock.MonotonicTime,
	clk clock.Clock,
	workerEpoch frameModel.Epoch,
) *MasterClient

NewMasterClient creates a new MasterClient.

func (*MasterClient) CheckMasterTimeout

func (m *MasterClient) CheckMasterTimeout() (ok bool, err error)

CheckMasterTimeout checks whether the master has timed out, i.e. we have lost contact with the master for a while.

func (*MasterClient) Epoch

func (m *MasterClient) Epoch() frameModel.Epoch

Epoch returns the master epoch. Note that the epoch is increased when the master restarts.

func (*MasterClient) HandleHeartbeat

func (m *MasterClient) HandleHeartbeat(sender p2p.NodeID, msg *frameModel.HeartbeatPongMessage)

HandleHeartbeat handles heartbeat messages received from the master.

func (*MasterClient) InitMasterInfoFromMeta

func (m *MasterClient) InitMasterInfoFromMeta(ctx context.Context) error

InitMasterInfoFromMeta reads the meta store and tries to find where the master is.

func (*MasterClient) IsMasterSideClosed

func (m *MasterClient) IsMasterSideClosed() bool

IsMasterSideClosed returns whether the master has marked the worker as closed. It is used when the worker initiates an exit with an error, but the network is fine.

func (*MasterClient) MasterID

func (m *MasterClient) MasterID() frameModel.MasterID

MasterID returns the masterID.

func (*MasterClient) MasterNode

func (m *MasterClient) MasterNode() p2p.NodeID

MasterNode returns the node ID of the executor on which the master is being run.

func (*MasterClient) SendHeartBeat

func (m *MasterClient) SendHeartBeat(ctx context.Context) error

SendHeartBeat sends a heartbeat to the master.

func (*MasterClient) SyncRefreshMasterInfo

func (m *MasterClient) SyncRefreshMasterInfo(ctx context.Context) error

SyncRefreshMasterInfo reloads the master's info. It is useful if the caller anticipates a master failover to have happened.

func (*MasterClient) WaitClosed

func (m *MasterClient) WaitClosed(ctx context.Context) error

WaitClosed marks the current worker as exiting, and blocks until the master has acknowledged the exit. The caller should make sure that no concurrent calls to WaitClosed happens.

func (*MasterClient) WorkerEpoch

func (m *MasterClient) WorkerEpoch() frameModel.Epoch

WorkerEpoch returns the worker epoch. This value is a constant value for the master client of every single worker

type MasterInfoProvider

type MasterInfoProvider interface {
	MasterID() frameModel.MasterID
	MasterNode() p2p.NodeID
	Epoch() frameModel.Epoch
	SyncRefreshMasterInfo(ctx context.Context) error
	IsMasterSideClosed() bool
}

MasterInfoProvider is an object that can provide the caller information on the master.

type MockMasterInfoProvider

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

MockMasterInfoProvider defines a mock provider that implements MasterInfoProvider

func NewMockMasterInfoProvider

func NewMockMasterInfoProvider(
	masterID frameModel.MasterID,
	masterNode p2p.NodeID,
	epoch frameModel.Epoch,
) *MockMasterInfoProvider

NewMockMasterInfoProvider creates a new MockMasterInfoProvider

func (*MockMasterInfoProvider) Epoch

Epoch implements MasterInfoProvider.Epoch

func (*MockMasterInfoProvider) IsMasterSideClosed

func (p *MockMasterInfoProvider) IsMasterSideClosed() bool

IsMasterSideClosed implements MasterInfoProvider.IsMasterSideClosed

func (*MockMasterInfoProvider) MasterID

MasterID implements MasterInfoProvider.MasterID

func (*MockMasterInfoProvider) MasterNode

func (p *MockMasterInfoProvider) MasterNode() p2p.NodeID

MasterNode implements MasterInfoProvider.MasterNode

func (*MockMasterInfoProvider) RefreshCount

func (p *MockMasterInfoProvider) RefreshCount() int

RefreshCount returns refresh time, it is used in unit test only

func (*MockMasterInfoProvider) Set

func (p *MockMasterInfoProvider) Set(masterID frameModel.MasterID, masterNode p2p.NodeID, epoch frameModel.Epoch)

Set sets given information to the MockMasterInfoProvider

func (*MockMasterInfoProvider) SetMasterClosed

func (p *MockMasterInfoProvider) SetMasterClosed()

SetMasterClosed marks the mock master has having marked the current worker closed.

func (*MockMasterInfoProvider) SyncRefreshMasterInfo

func (p *MockMasterInfoProvider) SyncRefreshMasterInfo(ctx context.Context) error

SyncRefreshMasterInfo implements MasterInfoProvider.RefreshMasterInfo

Jump to

Keyboard shortcuts

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