sharding

package
v0.0.0-...-a7a8f6c Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2022 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cfg

type Cfg struct {
	Addr                string
	ShardingAddr        string
	DataPath            string
	Labels              []prophet.Pair
	ProphetName         string
	FragHBInterval      time.Duration
	StoreHBInterval     time.Duration
	MaxPeerDownDuration time.Duration
	RMLease             time.Duration
	CoreOptions         []core.Option
	InitFragments       int
	Concurrency         int
	OverloadPercentage  uint64
	OverloadPeriod      uint64
	TransSendCB         func(meta.ResourceManager, meta.Notify) error
	TransWorkerCount    int
	PRWorkerCount       int
	// contains filtered or unexported fields
}

Cfg raftstore configuration

func (*Cfg) Adjust

func (c *Cfg) Adjust()

Adjust adjust

type ContainerAdapter

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

ContainerAdapter adapter for prophet's container and store

func (*ContainerAdapter) Clone

func (c *ContainerAdapter) Clone() prophet.Container

Clone adapter prophet

func (*ContainerAdapter) ID

func (c *ContainerAdapter) ID() uint64

ID adapter prophet

func (*ContainerAdapter) Lables

func (c *ContainerAdapter) Lables() []prophet.Pair

Lables adapter prophet

func (*ContainerAdapter) Marshal

func (c *ContainerAdapter) Marshal() ([]byte, error)

Marshal adapter prophet

func (*ContainerAdapter) State

func (c *ContainerAdapter) State() prophet.State

State adapter prophet

func (*ContainerAdapter) Unmarshal

func (c *ContainerAdapter) Unmarshal(data []byte) error

Unmarshal adapter prophet

type FragmentsState

type FragmentsState struct {
	FragmentCount, FragmentLeaderCount uint64
}

FragmentsState fragments state

type PeerReplicate

type PeerReplicate struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

PeerReplicate is the fragment peer replicatation. Every Fragment has N replicatation in N stores.

type ProphetAdapter

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

ProphetAdapter adapter prophet

func (*ProphetAdapter) ChangeLeader

func (pa *ProphetAdapter) ChangeLeader(resourceID uint64, newLeader *prophet.Peer)

ChangeLeader prophet adapter

func (*ProphetAdapter) ChangePeer

func (pa *ProphetAdapter) ChangePeer(resourceID uint64, peer *prophet.Peer, changeType prophet.ChangePeerType)

ChangePeer prophet adapter

func (*ProphetAdapter) ContainerHBInterval

func (pa *ProphetAdapter) ContainerHBInterval() time.Duration

ContainerHBInterval fetch container HB interface

func (*ProphetAdapter) FetchContainerHB

func (pa *ProphetAdapter) FetchContainerHB() *prophet.ContainerHeartbeatReq

FetchContainerHB fetch container HB

func (*ProphetAdapter) FetchLeaderResources

func (pa *ProphetAdapter) FetchLeaderResources() []uint64

FetchLeaderResources fetch all local leader resources

func (*ProphetAdapter) FetchResourceHB

func (pa *ProphetAdapter) FetchResourceHB(id uint64) *prophet.ResourceHeartbeatReq

FetchResourceHB fetch resource HB

func (*ProphetAdapter) HBHandler

func (pa *ProphetAdapter) HBHandler() prophet.HeartbeatHandler

HBHandler HB hander

func (*ProphetAdapter) NewContainer

func (pa *ProphetAdapter) NewContainer() prophet.Container

NewContainer return a new container

func (*ProphetAdapter) NewResource

func (pa *ProphetAdapter) NewResource() prophet.Resource

NewResource return a new resource

func (*ProphetAdapter) ResourceHBInterval

func (pa *ProphetAdapter) ResourceHBInterval() time.Duration

ResourceHBInterval fetch resource HB interface

type ResourceAdapter

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

ResourceAdapter adapter for prophet's resource and db

func (*ResourceAdapter) Changed

func (r *ResourceAdapter) Changed(other prophet.Resource) bool

Changed adapter prophet

func (*ResourceAdapter) Clone

func (r *ResourceAdapter) Clone() prophet.Resource

Clone adapter prophet

func (*ResourceAdapter) ID

func (r *ResourceAdapter) ID() uint64

ID adapter prophet

func (*ResourceAdapter) Marshal

func (r *ResourceAdapter) Marshal() ([]byte, error)

Marshal adapter prophet

func (*ResourceAdapter) Peers

func (r *ResourceAdapter) Peers() []*prophet.Peer

Peers adapter prophet

func (*ResourceAdapter) SetPeers

func (r *ResourceAdapter) SetPeers(peers []*prophet.Peer)

SetPeers adapter prophet

func (*ResourceAdapter) Stale

func (r *ResourceAdapter) Stale(other prophet.Resource) bool

Stale adapter prophet

func (*ResourceAdapter) Unmarshal

func (r *ResourceAdapter) Unmarshal(data []byte) error

Unmarshal adapter prophet

type Seata

type Seata struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Seata seata compatibled server

func NewSeata

func NewSeata(cfg Cfg) (*Seata, error)

NewSeata creates a seata compatibled server

func (*Seata) Start

func (f *Seata) Start() error

Start start

func (*Seata) Stop

func (f *Seata) Stop()

Stop stop seata

type Store

type Store interface {
	// Meta returns the current store's metadata
	Meta() meta.StoreMeta
	// Cfg returns the configuration
	Cfg() Cfg
	// Start start all fragments managed by the store
	Start()

	// FragmentsState returns the state of the fragments
	FragmentsState() FragmentsState
	// GetStoreAddr returns the store address
	GetStoreAddr(storeID uint64) (string, error)

	// LeaderPeer returns the fragment's leader peer
	LeaderPeer(fid uint64) (prophet.Peer, error)
	// CreateFragment create a new fragment and save it to the local data
	CreateFragment() meta.Fragment
	// MustPutFragment update the store's fragment metadata
	MustPutFragment(frag meta.Fragment)
	// GetFragment returns a fragment replicatation from the store,
	// when `leader` is true, only return the leader replicatation
	GetFragment(fid uint64, leader bool) *PeerReplicate

	// ForeachReplicate do something on every `replicatations`, break if the funcation return false
	ForeachReplicate(func(*PeerReplicate) bool)
	// AddReplicate add a replicatation
	AddReplicate(*PeerReplicate)
	// AddPeer add a peer to the exist fragment
	AddPeer(fid uint64, peer prophet.Peer)
	// RemovePeer remove the peer from the exist fragment
	RemovePeer(uint64, prophet.Peer)

	// Transport returns the seata message transport
	Transport() transport.Transport
	// ShardingTransport returns the sharding message transport
	ShardingTransport() Transport

	// HandleShardingMsg handle the sharding message, maybe returns a response.
	HandleShardingMsg(data interface{}) interface{}

	// AddRM add a resource manager
	AddRM(rms meta.ResourceManagerSet)
	// RenewRMLease renew the resource manager's lease
	RenewRMLease(pid, sid string)
}

Store is a container of fragments, which maintains a set of fragments

func NewStore

func NewStore(cfg Cfg) Store

NewStore returns store with cfg

type Transport

type Transport interface {
	Start()
	Stop()

	Send(uint64, interface{})
}

Transport sharding transport

Jump to

Keyboard shortcuts

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