controllers

package
v0.0.0-...-8540621 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2024 License: Apache-2.0 Imports: 50 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrTracepointRegistrationFailed failed to register tracepoint.
	ErrTracepointRegistrationFailed = errors.New("failed to register tracepoints")
	// ErrTracepointDeletionFailed failed to delete tracepoint.
	ErrTracepointDeletionFailed = errors.New("failed to delete tracepoints")
	// ErrTracepointPending tracepoint is still pending.
	ErrTracepointPending = errors.New("tracepoints are still pending")
	// ErrConfigUpdateFailed failed to send the config update request to an agent.
	ErrConfigUpdateFailed = errors.New("failed to update config")
)

Functions

func AgentRelationToVizierRelation

func AgentRelationToVizierRelation(relation *schemapb.Relation) *vizierpb.Relation

AgentRelationToVizierRelation converts the agent relation format to the Vizier relation format.

func BuildExecuteScriptResponse

func BuildExecuteScriptResponse(r *carnotpb.TransferResultChunkRequest,

	tableIDMap map[string]string,
	compilationTimeNs int64) (*vizierpb.ExecuteScriptResponse, error)

BuildExecuteScriptResponse Converts the agent-format result into the vizier client format result.

func ErrToVizierResponse

func ErrToVizierResponse(id uuid.UUID, err error) *vizierpb.ExecuteScriptResponse

ErrToVizierResponse converts an error to an externally-facing Vizier response message

func ErrToVizierStatus

func ErrToVizierStatus(err error) *vizierpb.Status

ErrToVizierStatus converts an error to an externally-facing Vizier status.

func GetQueryPlanAsDotString

func GetQueryPlanAsDotString(distributedPlan *distributedpb.DistributedPlan, planMap map[uuid.UUID]*planpb.Plan,
	planExecStats *[]*queryresultspb.AgentExecutionStats) (string, error)

GetQueryPlanAsDotString converts the plan into a dotstring that can be rendered by GraphViz.

func LaunchQuery

func LaunchQuery(queryID uuid.UUID, natsConn *nats.Conn, planMap map[uuid.UUID]*planpb.Plan, analyze bool) error

LaunchQuery launches a query by sending query fragments to relevant agents.

func OutputSchemaFromPlan

func OutputSchemaFromPlan(planMap map[uuid.UUID]*planpb.Plan) map[string]*schemapb.Relation

OutputSchemaFromPlan takes in a plan map and returns the relations for all of the final output tables in the plan map.

func QueryPlanRelationResponse

func QueryPlanRelationResponse(queryID uuid.UUID, planTableID string) *vizierpb.ExecuteScriptResponse

QueryPlanRelationResponse returns the relation of the query plan as an ExecuteScriptResponse.

func QueryPlanResponse

func QueryPlanResponse(queryID uuid.UUID, plan *distributedpb.DistributedPlan, planMap map[uuid.UUID]*planpb.Plan,
	agentStats *[]*queryresultspb.AgentExecutionStats,
	planTableID string,
	maxQueryPlanStringSizeBytes int) ([]*vizierpb.ExecuteScriptResponse, error)

QueryPlanResponse returns the query plan as an ExecuteScriptResponse.

func QueryResultStatsToVizierStats

func QueryResultStatsToVizierStats(e *queryresultspb.QueryExecutionStats, compilationTimeNs int64) *vizierpb.QueryExecutionStats

QueryResultStatsToVizierStats gets the execution stats from the query results.

func RelationFromTable

func RelationFromTable(table *schemapb.Table) (*vizierpb.QueryMetadata, error)

RelationFromTable gets the relation from the table.

func RowBatchToVizierRowBatch

func RowBatchToVizierRowBatch(rb *schemapb.RowBatchData, tableID string) (*vizierpb.RowBatchData, error)

RowBatchToVizierRowBatch converts an internal row batch to a vizier row batch.

func StatusToError

func StatusToError(s *statuspb.Status) error

StatusToError converts a statuspb.Status to a grpc error.

func StatusToVizierResponse

func StatusToVizierResponse(id uuid.UUID, s *statuspb.Status) *vizierpb.ExecuteScriptResponse

StatusToVizierResponse converts an error to an externally-facing Vizier response message

func StatusToVizierStatus

func StatusToVizierStatus(s *statuspb.Status) *vizierpb.Status

StatusToVizierStatus converts an internal status to an externally-facing Vizier status.

func TableRelationResponses

func TableRelationResponses(queryID uuid.UUID, tableIDMap map[string]string,
	planMap map[uuid.UUID]*planpb.Plan) ([]*vizierpb.ExecuteScriptResponse, error)

TableRelationResponses returns the query metadata table schemas as ExecuteScriptResponses.

func UInt128ToVizierUInt128

func UInt128ToVizierUInt128(i *typespb.UInt128) *vizierpb.UInt128

UInt128ToVizierUInt128 converts our internal representation of UInt128 to Vizier's representation of UInt128.

func VizierQueryRequestToPlannerMutationRequest

func VizierQueryRequestToPlannerMutationRequest(vpb *vizierpb.ExecuteScriptRequest) (*plannerpb.CompileMutationsRequest, error)

VizierQueryRequestToPlannerMutationRequest maps request to mutation.

func VizierQueryRequestToPlannerQueryRequest

func VizierQueryRequestToPlannerQueryRequest(vpb *vizierpb.ExecuteScriptRequest) (*plannerpb.QueryRequest, error)

VizierQueryRequestToPlannerQueryRequest converts a externally-facing query request to an internal representation.

func VizierStatusToError

func VizierStatusToError(s *vizierpb.Status) error

VizierStatusToError converts a vizierpb.Status to a grpc error.

Types

type AgentsTracker

type AgentsTracker interface {
	GetAgentInfo() tracker.AgentsInfo
}

AgentsTracker is the interface for the background agent information tracker.

type DataPrivacy

type DataPrivacy interface {
	// RedactionOptions returns the proto message containing options for redaction based on the cached data privacy level.
	RedactionOptions(ctx context.Context) (*distributedpb.RedactionOptions, error)
}

DataPrivacy is an interface that manages data privacy in the query executor.

func CreateDataPrivacyManager

func CreateDataPrivacyManager(ns string) (DataPrivacy, error)

CreateDataPrivacyManager creates a privacy manager for the namespace.

type MutationExecFactory

MutationExecFactory is a function that creates a new MutationExecutorImpl.

type MutationExecutor

type MutationExecutor interface {
	Execute(ctx context.Context, request *vizierpb.ExecuteScriptRequest, options *planpb.PlanOptions) (*statuspb.Status, error)
	MutationInfo(ctx context.Context) (*vizierpb.MutationInfo, error)
}

MutationExecutor is the interface for running script mutations.

func NewMutationExecutor

NewMutationExecutor creates a new mutation executor.

type MutationExecutorImpl

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

MutationExecutorImpl is responsible for running script mutations.

func (*MutationExecutorImpl) Execute

Execute runs the mutation. On unknown errors it will return an error, otherwise we return a status message that has more context about the error message.

func (*MutationExecutorImpl) MutationInfo

MutationInfo returns the summarized mutation information.

type Planner

Planner describes the interface for any planner.

type QueryExecutor

type QueryExecutor interface {
	Run(context.Context, *vizierpb.ExecuteScriptRequest, QueryResultConsumer) error
	Wait() error
	QueryID() uuid.UUID
}

QueryExecutor executes a query and allows the caller to consume results via a QueryResultConsumer.

func NewQueryExecutor

func NewQueryExecutor(
	resultAddress string,
	resultSSLTargetName string,
	agentsTracker AgentsTracker,
	dataPrivacy DataPrivacy,
	natsConn *nats.Conn,
	mdtp metadatapb.MetadataTracepointServiceClient,
	mdconf metadatapb.MetadataConfigServiceClient,
	resultForwarder QueryResultForwarder,
	planner Planner,
	mutExecFactory MutationExecFactory,
) QueryExecutor

NewQueryExecutor creates a new QueryExecutorImpl.

func NewQueryExecutorFromServer

func NewQueryExecutorFromServer(s *Server, mutExecFactory MutationExecFactory) QueryExecutor

NewQueryExecutorFromServer creates a new QueryExecutor using the properties of a query broker server.

type QueryExecutorFactory

type QueryExecutorFactory func(*Server, MutationExecFactory) QueryExecutor

QueryExecutorFactory creates a new QueryExecutor.

type QueryExecutorImpl

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

QueryExecutorImpl implements the QueryExecutor interface.

func (*QueryExecutorImpl) QueryID

func (q *QueryExecutorImpl) QueryID() uuid.UUID

QueryID returns the uuid of the executing query.

func (*QueryExecutorImpl) Run

Run launches a query with the given QueryResultConsumer consuming results, and does not wait for the query to error or finish.

func (*QueryExecutorImpl) Wait

func (q *QueryExecutorImpl) Wait() error

Wait waits for the query to finish or error.

type QueryFlags

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

QueryFlags represents a set of Pixie configuration flags.

func ParseQueryFlags

func ParseQueryFlags(queryStr string) (*QueryFlags, error)

ParseQueryFlags takes a query string containing some config options and generates a QueryFlags object that can be used to retrieve those options.

func (*QueryFlags) GetBool

func (f *QueryFlags) GetBool(key string) bool

GetBool gets the value of the given flag as a bool.

func (*QueryFlags) GetFloat64

func (f *QueryFlags) GetFloat64(key string) float64

GetFloat64 gets the value of the given flag as a float.

func (*QueryFlags) GetInt64

func (f *QueryFlags) GetInt64(key string) int64

GetInt64 gets the value of the given flag as an int64.

func (*QueryFlags) GetPlanOptions

func (f *QueryFlags) GetPlanOptions() *planpb.PlanOptions

GetPlanOptions creates the plan option proto from the specified query flags.

func (*QueryFlags) GetString

func (f *QueryFlags) GetString(key string) string

GetString gets the value of the given flag as a string.

type QueryPlanOpts

type QueryPlanOpts struct {
	TableID string
	Plan    *distributedpb.DistributedPlan
	PlanMap map[uuid.UUID]*planpb.Plan
}

QueryPlanOpts contains options for generating and returning the query plan when the query has explain=true.

type QueryResultConsumer

type QueryResultConsumer interface {
	Consume(*vizierpb.ExecuteScriptResponse) error
}

QueryResultConsumer defines an interface to allow consumption of Query results from a QueryResultExecutor.

type QueryResultForwarder

type QueryResultForwarder interface {
	RegisterQuery(queryID uuid.UUID, tableIDMap map[string]string,
		compilationTimeNs int64,
		queryPlanOpts *QueryPlanOpts, queryName string) error

	// Streams results from the agent stream to the client stream.
	// Blocks until the stream (& the agent stream) has completed, been cancelled, or experienced an error.
	// Returns error for any error received.
	StreamResults(ctx context.Context, queryID uuid.UUID,
		resultCh chan<- *vizierpb.ExecuteScriptResponse) error

	// Returns the producer context for the query, so that the watchdog can cancel all producers with one context.
	GetProducerCtx(queryID uuid.UUID) (context.Context, error)
	// Pass a message received from the agent stream to the client-side stream.
	ForwardQueryResult(ctx context.Context, msg *carnotpb.TransferResultChunkRequest) error
	// If the producer of data (i.e. Kelvin) errors then this function can be used to shutdown the stream.
	// The producer should not call this function if there's a retry is possible.
	ProducerCancelStream(queryID uuid.UUID, err error)
}

QueryResultForwarder is responsible for receiving query results from the agent streams and forwarding that data to the client stream.

func NewQueryResultForwarder

func NewQueryResultForwarder() QueryResultForwarder

NewQueryResultForwarder creates a new QueryResultForwarder.

func NewQueryResultForwarderWithOptions

func NewQueryResultForwarderWithOptions(opts ...QueryResultForwarderOption) QueryResultForwarder

NewQueryResultForwarderWithOptions returns a query result forwarder with custom options.

type QueryResultForwarderImpl

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

QueryResultForwarderImpl implements the QueryResultForwarder interface.

func (*QueryResultForwarderImpl) ForwardQueryResult

ForwardQueryResult forwards the agent result to the client result channel.

func (*QueryResultForwarderImpl) GetProducerCtx

func (f *QueryResultForwarderImpl) GetProducerCtx(queryID uuid.UUID) (context.Context, error)

GetProducerCtx returns the producer context for the query, so producers can check for that context being cancelled.

func (*QueryResultForwarderImpl) ProducerCancelStream

func (f *QueryResultForwarderImpl) ProducerCancelStream(queryID uuid.UUID, err error)

ProducerCancelStream signals to StreamResults that the client stream should be cancelled. It is triggered by the handler for the agent streams.

func (*QueryResultForwarderImpl) RegisterQuery

func (f *QueryResultForwarderImpl) RegisterQuery(queryID uuid.UUID, tableIDMap map[string]string,
	compilationTimeNs int64,
	queryPlanOpts *QueryPlanOpts,
	queryName string) error

RegisterQuery registers a query ID in the result forwarder.

func (*QueryResultForwarderImpl) StreamResults

func (f *QueryResultForwarderImpl) StreamResults(ctx context.Context, queryID uuid.UUID,
	resultCh chan<- *vizierpb.ExecuteScriptResponse) error

StreamResults streams results from the agent streams to the client stream.

type QueryResultForwarderOption

type QueryResultForwarderOption func(*QueryResultForwarderImpl)

QueryResultForwarderOption allows specifying options for new QueryResultForwarders.

func WithConsumerTimeout

func WithConsumerTimeout(timeout time.Duration) QueryResultForwarderOption

WithConsumerTimeout sets a timeout on how long the result forwarder will wait without a consumer pulling data from it.

func WithProducerTimeout

func WithProducerTimeout(timeout time.Duration) QueryResultForwarderOption

WithProducerTimeout sets a timeout on how long the result forwarder will wait without seeing any data from producers.

func WithResultSinkTimeout

func WithResultSinkTimeout(timeout time.Duration) QueryResultForwarderOption

WithResultSinkTimeout sets the result sink initialization timeout.

type Server

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

Server defines an gRPC server type.

func NewServer

func NewServer(env querybrokerenv.QueryBrokerEnv, agentsTracker AgentsTracker, dataPrivacy DataPrivacy,
	mds metadatapb.MetadataTracepointServiceClient, mdconf metadatapb.MetadataConfigServiceClient,
	natsConn *nats.Conn, queryExecFactory QueryExecutorFactory) (*Server, error)

NewServer creates GRPC handlers.

func NewServerWithForwarderAndPlanner

func NewServerWithForwarderAndPlanner(env querybrokerenv.QueryBrokerEnv,
	agentsTracker AgentsTracker,
	dataPrivacy DataPrivacy,
	resultForwarder QueryResultForwarder,
	mds metadatapb.MetadataTracepointServiceClient,
	mdconf metadatapb.MetadataConfigServiceClient,
	natsConn *nats.Conn,
	planner Planner,
	queryExecFactory QueryExecutorFactory) (*Server, error)

NewServerWithForwarderAndPlanner is NewServer with a QueryResultForwarder and a planner generating func.

func (*Server) CheckHealth

func (s *Server) CheckHealth(ctx context.Context) error

CheckHealth runs the health check and returns an error if it didn't pass.

func (*Server) Close

func (s *Server) Close()

Close frees the planner memory in the server.

func (*Server) ExecuteScript

ExecuteScript executes the script and sends results through the gRPC stream.

func (*Server) GenerateOTelScript

GenerateOTelScript generates an OTel script for the given DataFrame script.

func (*Server) HealthCheck

HealthCheck continually responds with the current health of Vizier.

func (*Server) TransferResultChunk

TransferResultChunk implements the API that allows the query broker receive streamed results from Carnot instances.

type TracepointInfo

type TracepointInfo struct {
	Name   string
	ID     uuid.UUID
	Status *statuspb.Status
}

TracepointInfo stores information of a particular tracepoint.

type TracepointMap

type TracepointMap map[string]*TracepointInfo

TracepointMap stores a map from the name to tracepoint info.

Directories

Path Synopsis
Package mock_controllers is a generated GoMock package.
Package mock_controllers is a generated GoMock package.

Jump to

Keyboard shortcuts

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