grpc

package
v0.0.0-...-e20d5c5 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2024 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DEFAULT_SYNC_INTERVAL = time.Minute
	EpcIDIPV6_LEN         = 20
	LruSlotSize           = 1 << 14
	LruCap                = 1 << 17
	GROUPID_MAX           = 1 << 16

	MASTER_TABLE_MOUDLE_NANE = "ingester"
)
View Source
const (
	GROUP_CACHE_IPV6_KEYLEN        = 160 / 8
	SERVER_GROUP_CACHE_IPV6_KEYLEN = 192 / 8
	GROUP_CACHE_SIZE               = 65536
)
View Source
const (
	DEFAULT_SYNC_TIMEOUT = 8 * time.Second
)

Variables

This section is empty.

Functions

func Lookup

func Lookup(host net.IP) (net.IP, error)

func QueryAllOrgIDs

func QueryAllOrgIDs() []uint16

func QueryVtapOrgAndTeamID

func QueryVtapOrgAndTeamID(vtapId uint16) (uint16, uint16)

func RegisterPlatformDataCommand

func RegisterPlatformDataCommand(ips []net.IP, port int) *cobra.Command

Types

type BaseInfo

type BaseInfo struct {
	RegionID uint32
	HitCount uint64
}

type CidrInfo

type CidrInfo struct {
	Cidr     *net.IPNet
	EpcID    int32
	RegionID uint32
	SubnetID uint32
	AZID     uint32
	IsWan    bool
	HitCount *uint64
}

type Counter

type Counter struct {
	GrpcRequestTime     int64 `statsd:"grpc-request-time"`
	UpdateServiceTime   int64 `statsd:"update-service-time"`
	UpdatePlatformTime  int64 `statsd:"update-platform-time"`
	UpdateCount         int64 `statsd:"update-count"`
	UpdateServicesCount int64 `statsd:"update-services-count"`

	IP4TotalCount       int64 `statsd:"ip4-total-count"`
	IP4HitCount         int64 `statsd:"ip4-hit-count"`
	IP6TotalCount       int64 `statsd:"ip6-total-count"`
	IP6HitCount         int64 `statsd:"ip6-hit-count"`
	IP4MissCount        int64 `statsd:"ip4-miss-count"`
	IP6MissCount        int64 `statsd:"ip6-miss-count"`
	MacMissCount        int64 `statsd:"mac-miss-count"`
	EpcMissCount        int64 `statsd:"epc-miss-count"`
	ContainerTotalCount int64 `statsd:"container-total-count"`
	ContainerHitCount   int64 `statsd:"container-hit-count"`
	ContainerMissCount  int64 `statsd:"container-miss-count"`
}

type EpcIDIPv6Key

type EpcIDIPv6Key struct {
	IPv6 [net.IPv6len]byte
	// contains filtered or unexported fields
}

type GroupLabeler

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

func NewGroupLabeler

func NewGroupLabeler(log *logger.PrefixLogger, idMaps []api.GroupIDMap, portFilterLruCap int, moduleName string) *GroupLabeler

func (*GroupLabeler) Query

func (l *GroupLabeler) Query(l3EpcID int16, ip uint32, podGroupID uint16) []uint16

func (*GroupLabeler) QueryIPv6

func (l *GroupLabeler) QueryIPv6(l3EpcID int16, ip net.IP, podGroupID uint16) []uint16

func (*GroupLabeler) QueryService

func (l *GroupLabeler) QueryService(l3EpcID int16, ip uint32, podGroupID uint16, protocol layers.IPProtocol, serverPort uint16) []uint16

func (*GroupLabeler) QueryServiceIPv6

func (l *GroupLabeler) QueryServiceIPv6(l3EpcID int16, ip net.IP, podGroupID uint16, protocol layers.IPProtocol, serverPort uint16) []uint16

type GrpcSession

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

func (*GrpcSession) Close

func (s *GrpcSession) Close()

func (*GrpcSession) CloseConnection

func (s *GrpcSession) CloseConnection()

func (*GrpcSession) GetClient

func (s *GrpcSession) GetClient() *grpc.ClientConn

func (*GrpcSession) Init

func (s *GrpcSession) Init(ips []net.IP, port uint16, syncInterval time.Duration, maxMsgSize int, runOnce func())

func (*GrpcSession) Request

func (s *GrpcSession) Request(syncFunction SyncFunction) error

func (*GrpcSession) SetSyncInterval

func (s *GrpcSession) SetSyncInterval(syncInterval time.Duration)

func (*GrpcSession) SetTimeout

func (s *GrpcSession) SetTimeout(timeout time.Duration)

func (*GrpcSession) Start

func (s *GrpcSession) Start()

type Info

type Info struct {
	EpcID        int32
	L2EpcID      int32
	Host         uint32
	HostStr      string
	HostID       uint32
	Mac          uint64
	RegionID     uint32
	DeviceType   uint32
	DeviceID     uint32
	SubnetID     uint32
	PodNodeID    uint32
	PodNSID      uint32
	PodGroupID   uint32
	PodGroupType uint8
	PodID        uint32
	PodClusterID uint32
	AZID         uint32
	IsVip        bool
	IsWan        bool
	VtapID       uint32
	IsIPv4       bool
	IP4          uint32
	IP6          net.IP
	HitCount     *uint64
}

type PlatformDataManager

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

func NewPlatformDataManager

func NewPlatformDataManager(ips []net.IP, port, maxSlaveTableSize, rpcMaxMsgSize int, nodeIP string, receiver *receiver.Receiver) *PlatformDataManager

func (*PlatformDataManager) GetMasterPlatformInfoTable

func (m *PlatformDataManager) GetMasterPlatformInfoTable() *PlatformInfoTable

func (*PlatformDataManager) NewPlatformInfoTable

func (m *PlatformDataManager) NewPlatformInfoTable(moudleName string) (*PlatformInfoTable, error)

type PlatformInfoTable

type PlatformInfoTable struct {
	*ServiceTable

	*GrpcSession

	utils.Closable
	// contains filtered or unexported fields
}

func NewPlatformInfoTable

func NewPlatformInfoTable(ips []net.IP, port, index, rpcMaxMsgSize int, moduleName, nodeIP string, receiver *receiver.Receiver, isMaster bool, manager *PlatformDataManager) *PlatformInfoTable

func (*PlatformInfoTable) AddOtherRegion

func (t *PlatformInfoTable) AddOtherRegion()

统计收到其他region的数据

func (*PlatformInfoTable) ClosePlatformInfoTable

func (t *PlatformInfoTable) ClosePlatformInfoTable()

func (*PlatformInfoTable) GetCounter

func (t *PlatformInfoTable) GetCounter() interface{}

func (*PlatformInfoTable) HandleSimpleCommand

func (t *PlatformInfoTable) HandleSimpleCommand(op uint16, arg string) string

func (*PlatformInfoTable) IPV4InfoAddLru

func (t *PlatformInfoTable) IPV4InfoAddLru(info *Info, key uint64)

func (*PlatformInfoTable) IPV4InfoStat

func (t *PlatformInfoTable) IPV4InfoStat(lruItem interface{})

func (*PlatformInfoTable) IPV6InfoAddLru

func (t *PlatformInfoTable) IPV6InfoAddLru(info *Info, key []byte)

func (*PlatformInfoTable) IPV6InfoStat

func (t *PlatformInfoTable) IPV6InfoStat(lruItem interface{})

func (*PlatformInfoTable) InfoMissStat

func (t *PlatformInfoTable) InfoMissStat(mac uint64)

func (*PlatformInfoTable) QueryAnalyzerID

func (t *PlatformInfoTable) QueryAnalyzerID() uint32

func (*PlatformInfoTable) QueryEpcIDBaseInfo

func (t *PlatformInfoTable) QueryEpcIDBaseInfo(epcID int32) *BaseInfo

func (*PlatformInfoTable) QueryEpcIDBaseInfosPair

func (t *PlatformInfoTable) QueryEpcIDBaseInfosPair(epcID0, epcID1 int32) (*BaseInfo, *BaseInfo)

func (*PlatformInfoTable) QueryGprocessInfo

func (t *PlatformInfoTable) QueryGprocessInfo(gprocessId uint32) (uint16, uint32)

return vtapID, podID

func (*PlatformInfoTable) QueryIPV4Infos

func (t *PlatformInfoTable) QueryIPV4Infos(epcID int32, ipv4 uint32) *Info

func (*PlatformInfoTable) QueryIPV4InfosPair

func (t *PlatformInfoTable) QueryIPV4InfosPair(epcID0 int32, ipv40 uint32, epcID1 int32, ipv41 uint32) (info0 *Info, info1 *Info)

func (*PlatformInfoTable) QueryIPV6Infos

func (t *PlatformInfoTable) QueryIPV6Infos(epcID int32, ipv6 net.IP) *Info

func (*PlatformInfoTable) QueryIPV6InfosPair

func (t *PlatformInfoTable) QueryIPV6InfosPair(epcID0 int32, ipv60 net.IP, epcID1 int32, ipv61 net.IP) (info0 *Info, info1 *Info)

func (*PlatformInfoTable) QueryMacInfo

func (t *PlatformInfoTable) QueryMacInfo(mac uint64) *Info

func (*PlatformInfoTable) QueryMacInfosPair

func (t *PlatformInfoTable) QueryMacInfosPair(mac0, mac1 uint64) (*Info, *Info)

func (*PlatformInfoTable) QueryPodContainerInfo

func (t *PlatformInfoTable) QueryPodContainerInfo(vtapID uint16, containerID string) *PodInfo

func (*PlatformInfoTable) QueryPodIdInfo

func (t *PlatformInfoTable) QueryPodIdInfo(podId uint32) *Info

func (*PlatformInfoTable) QueryPodInfo

func (t *PlatformInfoTable) QueryPodInfo(vtapId uint16, podName string) *PodInfo

func (*PlatformInfoTable) QueryProcessInfo

func (t *PlatformInfoTable) QueryProcessInfo(vtapId uint16, processId uint32) uint32

return gProcessID

func (*PlatformInfoTable) QueryRegionID

func (t *PlatformInfoTable) QueryRegionID() uint32

func (*PlatformInfoTable) QueryVtapEpc0

func (t *PlatformInfoTable) QueryVtapEpc0(vtapId uint16) int32

func (*PlatformInfoTable) QueryVtapEpc1

func (t *PlatformInfoTable) QueryVtapEpc1(vtapId uint16, isIPv4 bool, ip41 uint32, ip61 net.IP) int32

epc1的计算 1. 本地路由优先, 先假设等于epc0: 验证epc0+ip1是否在cidr list中 2. 对等连接路由其次, 假设等于epc0的peer-connection的epc: 2.1 查询PeerConnection list, 确认epc0的对等连接的epc为: epc0_0, epc0_1... 2.2 假设等于epc_0_0: 验证epc0_0+ip1是否在cidr list中 2.3 假设等于epc_0_1: 验证epc0_0+ip1是否在cidr list中 2.4 ... 3. 如果还找不到, 直接使用ip1去查wan ip

func (*PlatformInfoTable) QueryVtapInfo

func (t *PlatformInfoTable) QueryVtapInfo(vtapId uint16) *VtapInfo

func (*PlatformInfoTable) QueryVtapOrgAndTeamID

func (t *PlatformInfoTable) QueryVtapOrgAndTeamID(vtapId uint16) (uint16, uint16)

func (*PlatformInfoTable) ReloadMaster

func (t *PlatformInfoTable) ReloadMaster() error

func (*PlatformInfoTable) ReloadSlave

func (t *PlatformInfoTable) ReloadSlave() error

func (*PlatformInfoTable) String

func (t *PlatformInfoTable) String() string

func (*PlatformInfoTable) Version

func (t *PlatformInfoTable) Version() uint64

type PodInfo

type PodInfo struct {
	PodId        uint32
	PodName      string
	Ip           string
	EpcId        int32
	PodClusterId uint32
	ContainerIds []string
	PodNodeIp    string
	PodNsId      uint32
	PodGroupId   uint32
	PodGroupType uint8
}

type ServiceTable

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

func NewServiceTable

func NewServiceTable(grpcServices []*trident.ServiceInfo) *ServiceTable

func (*ServiceTable) QueryService

func (s *ServiceTable) QueryService(podID, podNodeID, podClusterID, podGroupID uint32, epcID int32, isIPv6 bool, ipv4 uint32, ipv6 net.IP, protocol layers.IPProtocol, serverPort uint16) uint32

func (*ServiceTable) String

func (s *ServiceTable) String() string

type SyncFunction

type SyncFunction func(context.Context, net.IP) error

type VtapInfo

type VtapInfo struct {
	VtapId       uint16
	EpcId        int32
	Ip           string
	PodClusterId uint32
	OrgId        uint16
	TeamId       uint16
}

Jump to

Keyboard shortcuts

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