state

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	EmptyMetadata = Metadata{
		Indices: map[string]IndexMetadata{},
	}
)
View Source
var (
	NoOnDiskState = OnDiskState{
		Metadata: EmptyMetadata,
	}
)

Functions

This section is empty.

Types

type Address

type Address struct {
}

type AliasMetadata

type AliasMetadata struct {
	Alias string
}

type BoundAddress

type BoundAddress struct {
}

type ClusterBlocks

type ClusterBlocks struct {
}

type ClusterChangedEvent

type ClusterChangedEvent struct {
	State     ClusterState
	PrevState ClusterState
}

func (*ClusterChangedEvent) IndicesDeleted

func (e *ClusterChangedEvent) IndicesDeleted() []Index

type ClusterService

type ClusterService interface {
	State() *ClusterState
	SubmitStateUpdateTask(task ClusterStateUpdateTask)
}

type ClusterState

type ClusterState struct {
	Version   int64
	StateUUID string
	Name      string
	Nodes     *Nodes
	Metadata  Metadata
	//Blocks    ClusterBlocks
	RoutingTable RoutingTable
}

ClusterState

func ClusterStateFromBytes

func ClusterStateFromBytes(b []byte, localNode Node) *ClusterState

func (*ClusterState) ToBytes

func (c *ClusterState) ToBytes() []byte

type ClusterStateUpdateTask

type ClusterStateUpdateTask func(s ClusterState) ClusterState

type CoordinationState

type CoordinationState struct {
	LocalNode      *Node
	PersistedState PersistedState

	Term int64 // 원래는 PersistedState에서 관리, 임시로 CoordinationState 여기서 관리하도록

	JoinVotes    *VoteCollection
	PublishVotes *VoteCollection
	ElectionWon  bool
}

func (*CoordinationState) IsElectionQuorum

func (c *CoordinationState) IsElectionQuorum(nodes []string) bool

type Index

type Index struct {
	Name string
	Uuid string
}

type IndexAbstractionAlias

type IndexAbstractionAlias struct {
	AliasName  string
	WriteIndex IndexMetadata
}

type IndexMetadata

type IndexMetadata struct {
	Index          Index
	NumberOfShards int
	//NumberOfReplicas int
	//Version            int64
	//State              IndexMetadataState
	Aliases map[string]AliasMetadata
	Mapping map[string]MappingMetadata
}

type IndexMetadataState

type IndexMetadataState int

Metadata

const (
	OPEN IndexMetadataState = iota
	CLOSE
)

type IndexRoutingTable

type IndexRoutingTable struct {
	Index  Index
	Shards map[int]IndexShardRoutingTable
}

type IndexShardRoutingTable

type IndexShardRoutingTable struct {
	ShardId ShardId
	Primary ShardRouting
}

type Join

type Join struct {
	SourceNode Node
	TargetNode Node
	Term       int64
}

func NewJoin

func NewJoin(sourceNode Node, targetNode Node, term int64) *Join

type MappingMetadata

type MappingMetadata struct {
	Type   string
	Source []byte
}

type: "_doc" source: "properties: {}"

type Metadata

type Metadata struct {
	//ClusterUUID string
	//Version     int64
	//Coordination CoordinationMetadata
	Indices map[string]IndexMetadata
	//Templates    map[string]IndexTemplateMetadata
	IndicesLookup map[string]IndexAbstractionAlias
}

func (*Metadata) FindAliases

func (m *Metadata) FindAliases(aliases []string, concreteIndices []string) map[string][]AliasMetadata

type Node

type Node struct {
	Name string
	Id   string
	//ephemeralId string
	//HostName    string
	HostAddress string
}

func CreateLocalNode

func CreateLocalNode(id string, address string, name string) *Node

func NodeFromBytes

func NodeFromBytes(b []byte) *Node

func (*Node) ToBytes

func (n *Node) ToBytes() []byte

type Nodes

type Nodes struct {
	Nodes        map[string]Node
	DataNodes    map[string]Node
	MasterNodes  map[string]Node
	MasterNodeId string
	LocalNodeId  string
}

func (*Nodes) MasterNode

func (n *Nodes) MasterNode() Node

type OnDiskState

type OnDiskState struct {
	Id                  string
	DataPath            string
	CurrentTerm         int64
	LastAcceptedVersion int64
	Metadata            Metadata
}

type PersistedState

type PersistedState interface {
	GetLastAcceptedState() *ClusterState
	SetLastAcceptedState(state *ClusterState)
}

type RoutingNode

type RoutingNode struct {
	NodeId string

	Shards        map[ShardId]ShardRouting
	ShardsByIndex map[string]map[ShardRouting]struct{}
	// contains filtered or unexported fields
}

func (*RoutingNode) Add

func (n *RoutingNode) Add(shard ShardRouting)

func (*RoutingNode) NumShards

func (n *RoutingNode) NumShards() int

func (*RoutingNode) NumShardsOfIndex

func (n *RoutingNode) NumShardsOfIndex(index string) int

type RoutingNodes

type RoutingNodes struct {
	NodesToShards    map[string]*RoutingNode
	UnassignedShards []*ShardRouting
}

func NewRoutingNodes

func NewRoutingNodes(clusterState ClusterState) *RoutingNodes

type RoutingTable

type RoutingTable struct {
	IndicesRouting map[string]IndexRoutingTable
}

type ShardId

type ShardId struct {
	Index   Index
	ShardId int
}

type ShardRouting

type ShardRouting struct {
	ShardId       ShardId
	CurrentNodeId string
	//RelocatingNodeId string
	Primary bool
}

type VoteCollection

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

VoteCollection

func NewVoteCollection

func NewVoteCollection() *VoteCollection

func (*VoteCollection) AddJoinVote

func (v *VoteCollection) AddJoinVote(join Join) bool

func (*VoteCollection) AddVote

func (v *VoteCollection) AddVote(sourceNode *Node) bool

func (*VoteCollection) IsQuorum

func (v *VoteCollection) IsQuorum(nodes []string) bool

type VotingConfiguration

type VotingConfiguration struct {
	// nodeIds  map[string]bool
	NodeIds []string
}

func NewVotingConfiguration

func NewVotingConfiguration() *VotingConfiguration

Directories

Path Synopsis
tcp

Jump to

Keyboard shortcuts

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