client

package
v0.0.0-...-4b22ae8 Latest Latest
Warning

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

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

Documentation

Overview

Package client is a generated GoMock package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BrokerServiceClient

type BrokerServiceClient interface {
	RemoveResource(
		ctx context.Context,
		WorkerID frameModel.WorkerID,
		resourceID resModel.ResourceID,
	) error
}

BrokerServiceClient wraps a pb.BrokerServiceClient

func NewBrokerServiceClient

func NewBrokerServiceClient(cli enginepb.BrokerServiceClient) BrokerServiceClient

NewBrokerServiceClient returns a new BrokerServiceClient.

type DefaultExecutorGroup

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

DefaultExecutorGroup is the default implementation for ExecutorGroup.

func NewExecutorGroup

func NewExecutorGroup(
	credentials *security.Credential,
	logger *zap.Logger,
) *DefaultExecutorGroup

NewExecutorGroup creates a new ExecutorGroup.

func (*DefaultExecutorGroup) AddExecutor

func (g *DefaultExecutorGroup) AddExecutor(executorID model.ExecutorID, addr string) error

AddExecutor adds an executor to the executor group. A new ExecutorClient will be created by this method. Note that since we are using asynchronous Dial, this method usually does not fail even if a bad address is provided.

func (*DefaultExecutorGroup) GetExecutorClient

func (g *DefaultExecutorGroup) GetExecutorClient(id model.ExecutorID) (ExecutorClient, bool)

GetExecutorClient tries to get the ExecutorClient for the given executor.

func (*DefaultExecutorGroup) GetExecutorClientB

func (g *DefaultExecutorGroup) GetExecutorClientB(ctx context.Context, id model.ExecutorID) (ExecutorClient, error)

GetExecutorClientB tries to get the ExecutorClient for the given executor. It blocks until either the context has been canceled or the executor ID becomes valid.

When an Executor goes offline, the ID is added to a tombstone list so that we can fail fast. The assumption here is that executor IDs will not be reused.

func (*DefaultExecutorGroup) RemoveExecutor

func (g *DefaultExecutorGroup) RemoveExecutor(executorID model.ExecutorID) error

RemoveExecutor removes an executor from the group. Note that the ExecutorClient maintained will be closed.

func (*DefaultExecutorGroup) UpdateExecutorList

func (g *DefaultExecutorGroup) UpdateExecutorList(executors map[model.ExecutorID]string) error

UpdateExecutorList updates the stored clients using a map from executor IDs to their addresses. Note: This method will not wait for the clients to be fully connected. In the rare case where grpc.Dial does fail, an error will be returned to the caller of this method, and the caller should retry appropriately.

type DiscoveryClient

type DiscoveryClient interface {
	// RegisterExecutor registers an executor. The server
	// will allocate and records a UUID.
	RegisterExecutor(
		ctx context.Context,
		request *pb.RegisterExecutorRequest,
	) (model.ExecutorID, error)

	// ListExecutors lists all executors.
	ListExecutors(ctx context.Context) ([]*pb.Executor, error)

	// ListMasters lists all masters.
	ListMasters(ctx context.Context) ([]*pb.Master, error)

	// Heartbeat sends a heartbeat message to the server.
	Heartbeat(
		ctx context.Context,
		request *pb.HeartbeatRequest,
	) (*pb.HeartbeatResponse, error)

	// QueryMetaStore queries the details of a metastore.
	QueryMetaStore(
		ctx context.Context,
		request *pb.QueryMetaStoreRequest,
	) (*pb.QueryMetaStoreResponse, error)

	// QueryStorageConfig queries the storage config.
	QueryStorageConfig(
		ctx context.Context,
		in *pb.QueryStorageConfigRequest,
	) (*pb.QueryStorageConfigResponse, error)
}

DiscoveryClient is a client to the Discovery service on the server master.

func NewDiscoveryClient

func NewDiscoveryClient(cli pb.DiscoveryClient) DiscoveryClient

NewDiscoveryClient returns a DiscoveryClient.

type DispatchTaskArgs

type DispatchTaskArgs struct {
	ProjectInfo  tenant.ProjectInfo
	WorkerID     string
	MasterID     string
	WorkerType   int64
	WorkerConfig []byte
	WorkerEpoch  int64
}

DispatchTaskArgs contains the required parameters for creating a worker.

type ExecutorClient

type ExecutorClient interface {
	ExecutorServiceClient
	BrokerServiceClient

	// Close closes the gRPC connection used to create the client.
	Close()
}

ExecutorClient is the public interface for an executor client. It is only for one executor. For a client to a group of executors, refer to ExecutorGroup.

func NewExecutorClient

func NewExecutorClient(conn *grpc.ClientConn) ExecutorClient

NewExecutorClient creates a new executor client. Note that conn will be closed if the returned client is closed.

type ExecutorGroup

type ExecutorGroup interface {
	// GetExecutorClient tries to get the ExecutorClient for the given executor.
	// It will return (nil, false) immediately if no such executor is found.
	GetExecutorClient(id model.ExecutorID) (ExecutorClient, bool)

	// GetExecutorClientB tries to get the ExecutorClient for the given executor.
	// It blocks until either the context has been canceled or the executor ID becomes valid.
	GetExecutorClientB(ctx context.Context, id model.ExecutorID) (ExecutorClient, error)
}

ExecutorGroup holds a group of ExecutorClients. It is used by any component that would like to invoke RPC methods on the executors.

type ExecutorServiceClient

type ExecutorServiceClient interface {
	DispatchTask(
		ctx context.Context,
		args *DispatchTaskArgs,
		startWorkerTimer StartWorkerCallback,
	) error
}

ExecutorServiceClient wraps a pb.ExecutorServiceClient and provides a DispatchTask method, which will call PreDispatchTask and ConfirmDispatchTask. TODO The service called "Executor" should be renamed "Dispatch", so that we have separate services for two sets of functionalities, i.e., dispatching tasks and managing resources (broker service).

func NewExecutorServiceClient

func NewExecutorServiceClient(cli pb.ExecutorServiceClient) ExecutorServiceClient

NewExecutorServiceClient creates a new ExecutorServiceClient.

type MasterServerList

type MasterServerList = internal.MasterServerList

MasterServerList is an alias for map[string]bool. It is a mapping from servers' address to whether they are the leader.

type MockExecutorClient

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

MockExecutorClient is a mock of ExecutorClient interface.

func NewMockExecutorClient

func NewMockExecutorClient(ctrl *gomock.Controller) *MockExecutorClient

NewMockExecutorClient creates a new mock instance.

func (*MockExecutorClient) Close

func (m *MockExecutorClient) Close()

Close mocks base method.

func (*MockExecutorClient) DispatchTask

func (m *MockExecutorClient) DispatchTask(arg0 context.Context, arg1 *DispatchTaskArgs, arg2 func()) error

DispatchTask mocks base method.

func (*MockExecutorClient) EXPECT

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

func (*MockExecutorClient) RemoveResource

func (m *MockExecutorClient) RemoveResource(arg0 context.Context, arg1, arg2 string) error

RemoveResource mocks base method.

type MockExecutorClientMockRecorder

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

MockExecutorClientMockRecorder is the mock recorder for MockExecutorClient.

func (*MockExecutorClientMockRecorder) Close

Close indicates an expected call of Close.

func (*MockExecutorClientMockRecorder) DispatchTask

func (mr *MockExecutorClientMockRecorder) DispatchTask(arg0, arg1, arg2 interface{}) *gomock.Call

DispatchTask indicates an expected call of DispatchTask.

func (*MockExecutorClientMockRecorder) RemoveResource

func (mr *MockExecutorClientMockRecorder) RemoveResource(arg0, arg1, arg2 interface{}) *gomock.Call

RemoveResource indicates an expected call of RemoveResource.

type MockExecutorGroup

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

MockExecutorGroup is a stub implementation for ExecutorGroup.

func NewMockExecutorGroup

func NewMockExecutorGroup() *MockExecutorGroup

NewMockExecutorGroup returns a new MockExecutorGroup.

func (*MockExecutorGroup) AddClient

func (g *MockExecutorGroup) AddClient(id model.ExecutorID, client ExecutorClient)

AddClient adds a client to the client map.

func (*MockExecutorGroup) GetExecutorClient

func (g *MockExecutorGroup) GetExecutorClient(id model.ExecutorID) (ExecutorClient, bool)

GetExecutorClient returns the ExecutorClient associated with id.

func (*MockExecutorGroup) GetExecutorClientB

func (g *MockExecutorGroup) GetExecutorClientB(ctx context.Context, id model.ExecutorID) (ExecutorClient, error)

GetExecutorClientB tries to get the ExecutorClient blockingly.

func (*MockExecutorGroup) RemoveClient

func (g *MockExecutorGroup) RemoveClient(id model.ExecutorID) bool

RemoveClient removes a client from the client map.

type MockServerMasterClient

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

MockServerMasterClient is a mock of ServerMasterClient interface.

func NewMockServerMasterClient

func NewMockServerMasterClient(ctrl *gomock.Controller) *MockServerMasterClient

NewMockServerMasterClient creates a new mock instance.

func (*MockServerMasterClient) Close

func (m *MockServerMasterClient) Close()

Close mocks base method.

func (*MockServerMasterClient) CreateResource

CreateResource mocks base method.

func (*MockServerMasterClient) EXPECT

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

func (*MockServerMasterClient) Heartbeat

Heartbeat mocks base method.

func (*MockServerMasterClient) ListExecutors

func (m *MockServerMasterClient) ListExecutors(arg0 context.Context) ([]*enginepb.Executor, error)

ListExecutors mocks base method.

func (*MockServerMasterClient) ListMasters

func (m *MockServerMasterClient) ListMasters(arg0 context.Context) ([]*enginepb.Master, error)

ListMasters mocks base method.

func (*MockServerMasterClient) QueryMetaStore

QueryMetaStore mocks base method.

func (*MockServerMasterClient) QueryResource

QueryResource mocks base method.

func (*MockServerMasterClient) QueryStorageConfig

QueryStorageConfig mocks base method.

func (*MockServerMasterClient) RegisterExecutor

RegisterExecutor mocks base method.

func (*MockServerMasterClient) RemoveResource

RemoveResource mocks base method.

func (*MockServerMasterClient) ScheduleTask

ScheduleTask mocks base method.

type MockServerMasterClientMockRecorder

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

MockServerMasterClientMockRecorder is the mock recorder for MockServerMasterClient.

func (*MockServerMasterClientMockRecorder) Close

Close indicates an expected call of Close.

func (*MockServerMasterClientMockRecorder) CreateResource

func (mr *MockServerMasterClientMockRecorder) CreateResource(arg0, arg1 interface{}) *gomock.Call

CreateResource indicates an expected call of CreateResource.

func (*MockServerMasterClientMockRecorder) Heartbeat

func (mr *MockServerMasterClientMockRecorder) Heartbeat(arg0, arg1 interface{}) *gomock.Call

Heartbeat indicates an expected call of Heartbeat.

func (*MockServerMasterClientMockRecorder) ListExecutors

func (mr *MockServerMasterClientMockRecorder) ListExecutors(arg0 interface{}) *gomock.Call

ListExecutors indicates an expected call of ListExecutors.

func (*MockServerMasterClientMockRecorder) ListMasters

func (mr *MockServerMasterClientMockRecorder) ListMasters(arg0 interface{}) *gomock.Call

ListMasters indicates an expected call of ListMasters.

func (*MockServerMasterClientMockRecorder) QueryMetaStore

func (mr *MockServerMasterClientMockRecorder) QueryMetaStore(arg0, arg1 interface{}) *gomock.Call

QueryMetaStore indicates an expected call of QueryMetaStore.

func (*MockServerMasterClientMockRecorder) QueryResource

func (mr *MockServerMasterClientMockRecorder) QueryResource(arg0, arg1 interface{}) *gomock.Call

QueryResource indicates an expected call of QueryResource.

func (*MockServerMasterClientMockRecorder) QueryStorageConfig

func (mr *MockServerMasterClientMockRecorder) QueryStorageConfig(arg0, arg1 interface{}) *gomock.Call

QueryStorageConfig indicates an expected call of QueryStorageConfig.

func (*MockServerMasterClientMockRecorder) RegisterExecutor

func (mr *MockServerMasterClientMockRecorder) RegisterExecutor(arg0, arg1 interface{}) *gomock.Call

RegisterExecutor indicates an expected call of RegisterExecutor.

func (*MockServerMasterClientMockRecorder) RemoveResource

func (mr *MockServerMasterClientMockRecorder) RemoveResource(arg0, arg1 interface{}) *gomock.Call

RemoveResource indicates an expected call of RemoveResource.

func (*MockServerMasterClientMockRecorder) ScheduleTask

func (mr *MockServerMasterClientMockRecorder) ScheduleTask(arg0, arg1 interface{}) *gomock.Call

ScheduleTask indicates an expected call of ScheduleTask.

type ResourceManagerClient

type ResourceManagerClient interface {
	CreateResource(ctx context.Context, request *enginepb.CreateResourceRequest) error
	QueryResource(ctx context.Context, request *enginepb.QueryResourceRequest) (*enginepb.QueryResourceResponse, error)
	RemoveResource(ctx context.Context, request *enginepb.RemoveResourceRequest) error
}

ResourceManagerClient is a client to the service ResourceManager, which currently is part of the server master.

func NewResourceManagerClient

func NewResourceManagerClient(cli enginepb.ResourceManagerClient) ResourceManagerClient

NewResourceManagerClient returns a ResourceManagerClient.

type ServerMasterClient

type ServerMasterClient interface {
	TaskSchedulerClient
	DiscoveryClient
	ResourceManagerClient

	// Close closes the gRPC connection used to create the client.
	Close()
}

ServerMasterClient is a client for connecting to the server master.

type ServerMasterClientWithFailOver

type ServerMasterClientWithFailOver struct {
	TaskSchedulerClient
	DiscoveryClient
	ResourceManagerClient
	// contains filtered or unexported fields
}

ServerMasterClientWithFailOver implements ServerMasterClient. It maintains an updatable list of servers and records the leader's address.

func NewServerMasterClientWithEndpointList

func NewServerMasterClientWithEndpointList(
	endpoints []string,
	credentials *security.Credential,
) (*ServerMasterClientWithFailOver, error)

NewServerMasterClientWithEndpointList creates a new ServerMasterClientWithFailOver with an endpoint list.

func NewServerMasterClientWithFailOver

func NewServerMasterClientWithFailOver(
	serverList MasterServerList,
	credentials *security.Credential,
) (*ServerMasterClientWithFailOver, error)

NewServerMasterClientWithFailOver creates a new ServerMasterClientWithFailOver. It is recommended that we use a singleton pattern here: Create one ServerMasterClientWithFailOver in each executor process.

func (*ServerMasterClientWithFailOver) Close

func (c *ServerMasterClientWithFailOver) Close()

Close closes the NewServerMasterClientWithFailOver.

func (*ServerMasterClientWithFailOver) UpdateServerList

func (c *ServerMasterClientWithFailOver) UpdateServerList(serverList MasterServerList)

UpdateServerList updates the server list maintained by the client. It is thread-safe.

type StartWorkerCallback

type StartWorkerCallback = func()

StartWorkerCallback alias to the function that is called after the pre dispatch task is successful and before confirm dispatch task.

type TaskSchedulerClient

type TaskSchedulerClient interface {
	ScheduleTask(
		ctx context.Context,
		request *enginepb.ScheduleTaskRequest,
	) (*enginepb.ScheduleTaskResponse, error)
}

TaskSchedulerClient is an interface for a client to the task scheduler in the server master.

func NewTaskSchedulerClient

func NewTaskSchedulerClient(cli enginepb.TaskSchedulerClient) TaskSchedulerClient

NewTaskSchedulerClient returns a TaskSchedulerClient.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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