gather

package
v0.0.0-...-3f388d4 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2022 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Overview

-------------------------------------------------------------------------

*
* docker_runner.go
*    Runner for DB Instance In Docker or Pod
*
*
* Copyright (c) 2021, Alibaba Group Holding Limited
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* IDENTIFICATION
*           internal/gather/docker_runner.go
*-------------------------------------------------------------------------

-------------------------------------------------------------------------

*
* export_runner.go
*    Export Runner
*
*
* Copyright (c) 2021, Alibaba Group Holding Limited
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* IDENTIFICATION
*           internal/gather/export_runner.go
*-------------------------------------------------------------------------

-------------------------------------------------------------------------

*
* http.go
*    Http client
*
*
* Copyright (c) 2021, Alibaba Group Holding Limited
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* IDENTIFICATION
*           internal/gather/http.go
*-------------------------------------------------------------------------

-------------------------------------------------------------------------

*
* plugin.go
*    Plugin Interface
*
*
* Copyright (c) 2021, Alibaba Group Holding Limited
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* IDENTIFICATION
*           internal/gather/plugin.go
*-------------------------------------------------------------------------

-------------------------------------------------------------------------

*
* schema.go
*    Metrics schema
*
*
* Copyright (c) 2021, Alibaba Group Holding Limited
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* IDENTIFICATION
*           internal/gather/schema.go
*-------------------------------------------------------------------------

-------------------------------------------------------------------------

*
* software_polardb_runner.go
*    SoftwarePolardbRunner
*
*
* Copyright (c) 2021, Alibaba Group Holding Limited
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* IDENTIFICATION
*           internal/gather/software_polardb_runner.go
*-------------------------------------------------------------------------

Index

Constants

View Source
const (
	// IntType for schema
	IntType = 0
	// FloatType for schema
	FloatType = 1
	// StringType for schema
	StringType = 2
	// MapKeyType from schema
	MapKeyType = 3
	// ListType from schema
	ListType = 4
	// CPUTopType from schema
	CPUTopType = 5
	// IOTopType from schema
	IOTopType = 6
	// MemTopType from schema
	MemTopType = 7
	// DStatusType from schema
	DStatusType = 8
	// mapType for schema
	MapType = 9
	// map with Int as key and double as value
	IntDoubleMap = 10
)

Variables

View Source
var DatatypeFormalizeMap map[string]string
View Source
var PluginNameFormalizeMap map[string]string

Functions

func DefaultMessageSerializeBySchema

func DefaultMessageSerializeBySchema(ms *SchemaItems, content map[string]interface{}, buf *bytes.Buffer) error

DefaultMessageSerializeBySchema method

func HTTPConnectionNew

func HTTPConnectionNew() *http.Client

HTTPConnectionNew new http

func HTTPGet

func HTTPGet(client *http.Client, url string) ([]byte, error)

HTTPGet get method

func MessageHeaderSerializeBySchema

func MessageHeaderSerializeBySchema(schemaHeader *SchemaItems, ins *Instance, headerMap map[string]interface{}) error

MessageHeaderSerializeBySchema method

func MessageSerialize

func MessageSerialize(ms *SchemaItems, values map[string]interface{}, buf *bytes.Buffer) error

MessageSerialize method

func OnlyArrayMessageSerialize

func OnlyArrayMessageSerialize(v []string, buf *bytes.Buffer) error

OnlyArrayMessageSerialize method

func OnlyIntArrayMessageSerialize

func OnlyIntArrayMessageSerialize(ms *SchemaItems, values map[string][]int, buf *bytes.Buffer) error

OnlyIntArrayMessageSerialize method

func OnlyIntMessageSerializeBySchema

func OnlyIntMessageSerializeBySchema(ms *SchemaItems, content map[string]uint64, buf *bytes.Buffer) error

OnlyIntMessageSerializeBySchema method

Types

type BusinessSchema

type BusinessSchema struct {
	Version uint32
	Headers SchemaItems
	Metrics SchemaItems
}

BusinessSchema for business

func JSON2Schema

func JSON2Schema(j []byte, buf *bytes.Buffer) (*BusinessSchema, error)

JSON2Schema parser json schema

type BusinessSchemaDesc

type BusinessSchemaDesc struct {
	Headers []SchemaItemDesc `json:"headers"`
	Metrics []SchemaItemDesc `json:"metrics"`
}

BusinessSchemaDesc schema json definition begin

type DockerRunner

type DockerRunner struct {
	Runner
	// contains filtered or unexported fields
}

DockerRunner for a instance

func (*DockerRunner) RunnerInit

func (dr *DockerRunner) RunnerInit(mInfoMap *sync.Map, pInfo *PluginInfo, pCtx *PluginCtx) error

RunnerInit init this runner

func (*DockerRunner) RunnerNotify

func (dr *DockerRunner) RunnerNotify()

RunnerNotify notify a runner

func (*DockerRunner) RunnerRun

func (dr *DockerRunner) RunnerRun(wg *sync.WaitGroup) error

RunnerRun run plugin for a docker instance

func (*DockerRunner) RunnerStatus

func (dr *DockerRunner) RunnerStatus() interface{}

RunnerStatus get status from a runner

func (*DockerRunner) RunnerStop

func (dr *DockerRunner) RunnerStop()

RunnerStop stop all runner instance

type ExportRunner

type ExportRunner struct {
	Runner
	// contains filtered or unexported fields
}

ExportRunner a runner only for export functions

func (*ExportRunner) RunnerInit

func (er *ExportRunner) RunnerInit(mInfoMap *sync.Map, pInfo *PluginInfo, pCtx *PluginCtx) error

RunnerInit init this runner

func (*ExportRunner) RunnerNotify

func (er *ExportRunner) RunnerNotify()

RunnerNotify notify a runner

func (*ExportRunner) RunnerRun

func (er *ExportRunner) RunnerRun(wg *sync.WaitGroup) error

RunnerRun export runner run

func (*ExportRunner) RunnerStatus

func (er *ExportRunner) RunnerStatus() interface{}

RunnerStatus get status

func (*ExportRunner) RunnerStop

func (er *ExportRunner) RunnerStop()

RunnerStop stop runner

type ExternConf

type ExternConf struct {
	Schema   string                 `json:"schema"`
	Type     string                 `json:"type"`
	Business string                 `json:"business"`
	Context  map[string]interface{} `json:"context"`
}

ExternConf struct

type Instance

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

Instance base struct

type ModuleInfo

type ModuleInfo struct {
	ID        string
	Mode      string
	Extern    string
	PluginABI PluginInterface
	Eat       map[string]interface{} // module-name.FuncName as key
	Iat       map[string]interface{} // module-name.FuncName as key
	Contexts  sync.Map               // module-name as key
	// contains filtered or unexported fields
}

ModuleInfo a module struct

func (*ModuleInfo) ModuleExit

func (module *ModuleInfo) ModuleExit()

ModuleExit exit module

func (*ModuleInfo) ModuleInit

func (module *ModuleInfo) ModuleInit(pInfo *PluginInfo) error

ModuleInit init a module

type PluginCtx

type PluginCtx struct {

	//Plugins          map[string]*PluginInfo
	Plugins          sync.Map // pluginName as key,pluginInfo as value
	ReverseDependMap map[string][]*PluginInfo
	PluginQueue      chan *PluginInfo
	// contains filtered or unexported fields
}

PluginCtx : plugin context ReverseDependMap : depOn 被依赖 : dep 依赖, 如 A 依赖 B & C,则记录两条:B:A, C:A

func (*PluginCtx) PluginExit

func (pCtx *PluginCtx) PluginExit()

PluginExit exit

func (*PluginCtx) PluginInit

func (pCtx *PluginCtx) PluginInit()

PluginInit init

func (*PluginCtx) PluginStop

func (pCtx *PluginCtx) PluginStop()

PluginStop stop

func (*PluginCtx) Run

func (pCtx *PluginCtx) Run(dir string, wait *sync.WaitGroup)

Run run plugin

type PluginInfo

type PluginInfo struct {
	Type              string   `json:"type"`
	Mode              string   `json:"mode"`
	Runner            string   `json:"runner"`
	Exports           []string `json:"exports"`
	Imports           []string `json:"imports"`
	Path              string   `json:"path"`
	Name              string   `json:"name"`
	Extern            string   `json:"extern"`
	WorkDir           string   `json:"workdir"`
	WorkDirPrefix     string   `json:"prefix"`
	DoubleCheckDir    string   `json:"doulecheckdir"`
	Target            string   `json:"target"`       // 用于判断实例类型,对齐本地元数据的dbtype
	DbType            string   `json:"dbtype"`       // 用于上报数据的dbtype,不一定等于target
	BusinessType      string   `json:"businessType"` // 用于上报数据的类型
	BizType           string   `json:"biz_type"`     //区分实例是属于公共云还是阿里集团
	Enable            bool     `json:"enable"`
	Interval          int      `json:"interval"`
	Backend           []string `json:"backend"`
	Processor         string   `json:"processor"`      // NOTE(wormhole.gl): processor
	ProcessorBackends []string `json:"multi_backends"` // NOTE(wormhole.gl): processor backends
	Dependencies      []string `json:"dependencies"`
}

PluginInfo for plugin

type PluginInterface

type PluginInterface struct {
	Init func(interface{}) (interface{}, error)
	Run  func(interface{}, interface{}) error
	Exit func(interface{}) error
}

PluginInterface plugin common

type Runner

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

Runner base struct

type RunnerService

type RunnerService interface {
	RunnerInit(mInfoMap *sync.Map, pInfo *PluginInfo, ctx *PluginCtx) error
	RunnerRun(wait *sync.WaitGroup) error
	RunnerStop()
	RunnerStatus() interface{}
	RunnerNotify()
}

RunnerService base interface

func NewDockerRunner

func NewDockerRunner() RunnerService

NewDockerRunner new a docker runner object

func NewExportRunner

func NewExportRunner() RunnerService

NewExportRunner new a docker runner object, one plugin conf will run only one runner and one instance in this runner

func NewSingletonRunner

func NewSingletonRunner() RunnerService

NewSingletonRunner method

func NewSoftwarePolardbRunner

func NewSoftwarePolardbRunner() RunnerService

NewSoftwarePolardbRunner new a SoftwarePolardbRunner object

type Schema

type Schema struct {
	BizSchemaMap map[string]BusinessSchema
}

Schema entry

type SchemaItem

type SchemaItem struct {
	Index     int
	ValueType int
	Name      string
}

SchemaItem for the schema

type SchemaItemDesc

type SchemaItemDesc struct {
	Index int    `json:"index"`
	Type  string `json:"type"`
	Name  string `json:"name"`
}

SchemaItemDesc schema json definition begin

type SchemaItems

type SchemaItems struct {
	SchemaItems []SchemaItem
}

SchemaItems set of schema

type SingletonRunner

type SingletonRunner struct {
	Runner
}

SingletonRunner struct

func (*SingletonRunner) RunnerInit

func (sr *SingletonRunner) RunnerInit(mInfoMap *sync.Map, pInfo *PluginInfo, pCtx *PluginCtx) error

RunnerInit init

func (*SingletonRunner) RunnerNotify

func (sr *SingletonRunner) RunnerNotify()

RunnerNotify notify

func (*SingletonRunner) RunnerRun

func (sr *SingletonRunner) RunnerRun(wg *sync.WaitGroup) error

RunnerRun run

func (*SingletonRunner) RunnerStatus

func (sr *SingletonRunner) RunnerStatus() interface{}

RunnerStatus status

func (*SingletonRunner) RunnerStop

func (sr *SingletonRunner) RunnerStop()

RunnerStop stop

type SoftwarePolardbRunner

type SoftwarePolardbRunner struct {
	Runner
	// contains filtered or unexported fields
}

SoftwarePolardbRunner struct

func (*SoftwarePolardbRunner) RunnerInit

func (rr *SoftwarePolardbRunner) RunnerInit(mInfos *sync.Map, pInfo *PluginInfo, ctx *PluginCtx) error

RunnerInit init this runner

func (*SoftwarePolardbRunner) RunnerNotify

func (rr *SoftwarePolardbRunner) RunnerNotify()

RunnerNotify notify

func (*SoftwarePolardbRunner) RunnerRun

func (rr *SoftwarePolardbRunner) RunnerRun(wg *sync.WaitGroup) error

RunnerRun run

func (*SoftwarePolardbRunner) RunnerStatus

func (rr *SoftwarePolardbRunner) RunnerStatus() interface{}

RunnerStatus status

func (*SoftwarePolardbRunner) RunnerStop

func (rr *SoftwarePolardbRunner) RunnerStop()

RunnerStop stop

Jump to

Keyboard shortcuts

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