application

package
v0.0.0-...-1c2232c Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Version pb.BrokerProtocolVersion = 1
)

Variables

This section is empty.

Functions

func GenerateJobID

func GenerateJobID() (string, error)

func GenerateProjectID

func GenerateProjectID() (string, error)

remove hyphens due to project id may work as db name.

func GetCCLsChecksum

func GetCCLsChecksum(ccls []storage.ColumnPriv) string

func GetTableChecksum

func GetTableChecksum(meta storage.TableMeta) string

TODO(jingshi): DRY, use ChecksumHasher.InfeedTable instead

Types

type App

type App struct {
	Sessions     *cache.Cache
	PartyMgr     partymgr.PartyMgr
	MetaMgr      *storage.MetaManager
	Conf         *config.Config
	Auth         *auth.Auth
	EngineClient executor.EngineClient
	InterStub    *InterStub

	Scheduler scheduler.EngineScheduler

	JobWatcher *executor.JobWatcher
}

func NewApp

func NewApp(partyMgr partymgr.PartyMgr, metaMgr *storage.MetaManager, cfg *config.Config) (*App, error)

func (*App) AddSession

func (app *App) AddSession(sid string, session *Session)

func (*App) CancelSession

func (app *App) CancelSession(info *storage.SessionInfo) error

cancel session to release memory and engine resource

func (*App) DeleteSession

func (app *App) DeleteSession(sid string)

func (*App) GetSession

func (app *App) GetSession(sid string) (*Session, bool)

func (*App) GetSessionInfo

func (app *App) GetSessionInfo(sid string) (*storage.SessionInfo, error)

func (*App) GetSessionResult

func (app *App) GetSessionResult(sid string) (*pb.QueryResponse, error)

func (*App) PersistSessionInfo

func (app *App) PersistSessionInfo(session *Session) error

func (*App) PersistSessionResult

func (app *App) PersistSessionResult(sid string, resp *pb.QueryResponse) error

func (*App) SessionGc

func (app *App) SessionGc()

NOTE: SessionGc will continue GC until program exits

func (*App) StorageGc

func (app *App) StorageGc()

NOTE: StorageGc will continue GC until program exits

type Checksum

type Checksum struct {
	TableSchema []byte
	CCL         []byte
}

func NewChecksumFromProto

func NewChecksumFromProto(checksumProto *pb.Checksum) Checksum

func (*Checksum) CompareWith

func (c *Checksum) CompareWith(checksum Checksum) pb.ChecksumCompareResult

func (*Checksum) String

func (c *Checksum) String() string

func (*Checksum) TruncateString

func (c *Checksum) TruncateString() string

type ChecksumHasher

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

func NewChecksumHasher

func NewChecksumHasher() *ChecksumHasher

func (*ChecksumHasher) Finalize

func (c *ChecksumHasher) Finalize() Checksum

func (*ChecksumHasher) InfeedCCLs

func (c *ChecksumHasher) InfeedCCLs(ccls []*pb.SecurityConfig_ColumnControl)

func (*ChecksumHasher) InfeedTable

func (c *ChecksumHasher) InfeedTable(tableName string, columnInfos []*model.ColumnInfo)

type ChecksumStorage

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

func (*ChecksumStorage) CompareChecksumFor

func (s *ChecksumStorage) CompareChecksumFor(partyCode string) (pb.ChecksumCompareResult, error)

func (*ChecksumStorage) GetLocal

func (s *ChecksumStorage) GetLocal(partyCode string) (Checksum, error)

func (*ChecksumStorage) GetRemote

func (s *ChecksumStorage) GetRemote(partyCode string) (Checksum, error)

func (*ChecksumStorage) SaveLocal

func (s *ChecksumStorage) SaveLocal(partyCode string, sum Checksum) error

func (*ChecksumStorage) SaveRemote

func (s *ChecksumStorage) SaveRemote(partyCode string, pbChecksum *pb.Checksum) error

type ExecutionInfo

type ExecutionInfo struct {
	Issuer    *pb.PartyId
	ProjectID string
	JobID     string
	Query     string
	// map from party to engine endpoint
	EngineEndpoints sync.Map
	EngineClient    exe.EngineClient
	InterStub       *InterStub
	// sorted parties who's data has been used in current session
	DataParties []string
	// sorted parties who work in current session
	WorkParties []string

	Checksums ChecksumStorage

	CompileOpts *pb.CompileOptions
	// for debug
	DebugOpts *pb.DebugOptions
}

func (*ExecutionInfo) CheckProjectConf

func (e *ExecutionInfo) CheckProjectConf() error

type InterStub

type InterStub struct {
	Timeout      time.Duration
	EncodingType message.ContentEncodingType
	Auth         *auth.Auth
}

func (*InterStub) AskInfo

func (stub *InterStub) AskInfo(url string, req *pb.AskInfoRequest, response *pb.AskInfoResponse) (err error)

func (*InterStub) CancelQueryJob

func (stub *InterStub) CancelQueryJob(url string, req *pb.CancelQueryJobRequest, response *pb.CancelQueryJobResponse) (err error)

func (*InterStub) DistributeQuery

func (stub *InterStub) DistributeQuery(url string, req *pb.DistributeQueryRequest, response *pb.DistributeQueryResponse) (err error)

func (*InterStub) ExchangeJobInfo

func (stub *InterStub) ExchangeJobInfo(url string, req *pb.ExchangeJobInfoRequest, response *pb.ExchangeJobInfoResponse) (err error)

func (*InterStub) InviteToProject

func (stub *InterStub) InviteToProject(url string, req *pb.InviteToProjectRequest, response *pb.InviteToProjectResponse) (err error)

func (*InterStub) ReplyInvitation

func (stub *InterStub) ReplyInvitation(url string, req *pb.ReplyInvitationRequest, response *pb.ReplyInvitationResponse) (err error)

func (*InterStub) SyncInfo

func (stub *InterStub) SyncInfo(url string, req *pb.SyncInfoRequest, response *pb.SyncInfoResponse) (err error)

type IntraStub

type IntraStub struct {
	Timeout time.Duration
}

func (*IntraStub) CancelJob

func (stub *IntraStub) CancelJob(url string, req *pb.CancelQueryRequest, response *pb.CancelQueryResponse) (err error)

func (*IntraStub) CheckAndUpdateStatus

func (stub *IntraStub) CheckAndUpdateStatus(url string, req *pb.CheckAndUpdateStatusRequest, response *pb.CheckAndUpdateStatusResponse) (err error)

func (*IntraStub) CreateJob

func (stub *IntraStub) CreateJob(url string, req *pb.QueryRequest, response *pb.SubmitResponse) (err error)

func (*IntraStub) CreateProject

func (stub *IntraStub) CreateProject(url string, req *pb.CreateProjectRequest, response *pb.CreateProjectResponse) (err error)

func (*IntraStub) CreateTable

func (stub *IntraStub) CreateTable(url string, req *pb.CreateTableRequest, response *pb.CreateTableResponse) (err error)

func (*IntraStub) DropTable

func (stub *IntraStub) DropTable(url string, req *pb.DropTableRequest, response *pb.DropTableResponse) (err error)

func (*IntraStub) GetResult

func (stub *IntraStub) GetResult(url string, req *pb.FetchResultRequest, response *pb.QueryResponse) (err error)

func (*IntraStub) GrantCCL

func (stub *IntraStub) GrantCCL(url string, req *pb.GrantCCLRequest, response *pb.GrantCCLResponse) (err error)

func (*IntraStub) InviteMember

func (stub *IntraStub) InviteMember(url string, req *pb.InviteMemberRequest, response *pb.InviteMemberResponse) (err error)

func (*IntraStub) ListCCLs

func (stub *IntraStub) ListCCLs(url string, req *pb.ShowCCLRequest, response *pb.ShowCCLResponse) (err error)

func (*IntraStub) ListInvitations

func (stub *IntraStub) ListInvitations(url string, req *pb.ListInvitationsRequest, response *pb.ListInvitationsResponse) (err error)

func (*IntraStub) ListProjects

func (stub *IntraStub) ListProjects(url string, req *pb.ListProjectsRequest, response *pb.ListProjectsResponse) (err error)

func (*IntraStub) ListTables

func (stub *IntraStub) ListTables(url string, req *pb.ListTablesRequest, response *pb.ListTablesResponse) (err error)

func (*IntraStub) ProcessInvitation

func (stub *IntraStub) ProcessInvitation(url string, req *pb.ProcessInvitationRequest, response *pb.ProcessInvitationResponse) (err error)

func (*IntraStub) RevokeCCL

func (stub *IntraStub) RevokeCCL(url string, req *pb.RevokeCCLRequest, response *pb.RevokeCCLResponse) (err error)

func (*IntraStub) RunQuery

func (stub *IntraStub) RunQuery(url string, req *pb.QueryRequest, response *pb.QueryResponse) (err error)

type Session

type Session struct {
	CreatedAt   time.Time
	SessionVars *variable.SessionVars
	Ctx         context.Context
	App         *App
	// all sessions have independent stub to avoid concurrent problems
	ExecuteInfo *ExecutionInfo
	Engine      scheduler.EngineInstance
	// current broker host for local engine to call back
	CallBackHost string

	Values map[fmt.Stringer]interface{}

	DryRun bool

	AsyncMode   bool
	OutputNames []string
	Warning     *pb.Warning

	Result *pb.QueryResponse
	// contains filtered or unexported fields
}

session stores information that is unrelated to the query.

func NewSession

func NewSession(ctx context.Context, info *ExecutionInfo, app *App, asyncMode bool, dryRun bool) (session *Session, err error)

func (*Session) CheckChecksum

func (s *Session) CheckChecksum() error

CheckChecksum checks data consistency with other parties via comparing checksum

func (*Session) GetEndpoint

func (s *Session) GetEndpoint(partyCode string) (string, error)

func (*Session) GetLocalChecksum

func (s *Session) GetLocalChecksum(partyCode string) (Checksum, error)

func (*Session) GetRemoteChecksum

func (s *Session) GetRemoteChecksum(partyCode string) (Checksum, error)

func (*Session) GetResultSafely

func (s *Session) GetResultSafely() *pb.QueryResponse

func (*Session) GetSelfChecksum

func (s *Session) GetSelfChecksum() (Checksum, error)

func (*Session) GetSelfPartyCode

func (s *Session) GetSelfPartyCode() string

func (*Session) GetSessionVars

func (s *Session) GetSessionVars() *variable.SessionVars

GetSessionVars implements the context.Context interface.

func (*Session) IsIssuer

func (s *Session) IsIssuer() bool

func (*Session) OnError

func (s *Session) OnError(err error)

OnError is called when query job failed

func (*Session) OnSuccess

func (s *Session) OnSuccess()

OnSuccess is called when query job success

func (*Session) SaveEndpoint

func (s *Session) SaveEndpoint(partyCode, endpoint string)

func (*Session) SaveLocalChecksum

func (s *Session) SaveLocalChecksum(partyCode string, sum Checksum) error

func (*Session) SaveRemoteChecksum

func (s *Session) SaveRemoteChecksum(partyCode string, pbChecksum *pb.Checksum) error

func (*Session) SetResultSafely

func (s *Session) SetResultSafely(result *pb.QueryResponse)

func (*Session) SetValue

func (s *Session) SetValue(key fmt.Stringer, value interface{})

SetValue implements sessionctx.Context SetValue interface.

func (*Session) Value

func (s *Session) Value(key fmt.Stringer) interface{}

Value implements sessionctx.Context Value interface.

Jump to

Keyboard shortcuts

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