ganjine

package
v0.0.0-...-4a740ba Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	ClusterStateStop int = iota
	ClusterStateRunning
	ClusterStateStopping
	ClusterStateStarting // plan to start
)

Server State

View Source
const (
	// DataStructureStatePreAlpha refers to all activities performed during the software project before formal testing.
	DataStructureStatePreAlpha uint8 = iota
	// DataStructureStateAlpha is the first phase to begin software testing
	DataStructureStateAlpha
	// DataStructureStateBeta generally begins when the software is feature complete but likely to contain a number of known or unknown bugs.
	DataStructureStateBeta
	// DataStructureStatePerpetualBeta where new features are continually added to the software without establishing a final "stable" release.
	// This technique may allow a developer to delay offering full support and responsibility for remaining issues.
	DataStructureStatePerpetualBeta
	// DataStructureStateOpenBeta is for a larger group, or anyone interested.
	DataStructureStateOpenBeta
	// DataStructureStateClosedBeta is released to a restricted group of individuals for a user test by invitation.
	DataStructureStateClosedBeta
	// DataStructureStateReleaseCandidate also known as "going silver", is a beta version with potential to be a stable product,
	// which is ready to release unless significant bugs emerge
	DataStructureStateReleaseCandidate
	// DataStructureStateStableRelease Also called production release,
	// the stable release is the last release candidate (RC) which has passed all verifications / tests.
	DataStructureStateStableRelease
	// DataStructureStateEndOfLife indicate no longer supported and continue its existence until to ExpiryDate!
	DataStructureStateEndOfLife
)

DataStructure State https://en.wikipedia.org/wiki/Software_release_life_cycle

View Source
const (
	NodeStateSplitting uint8 = iota
	NodeStateReAllocate
	NodeStateAcceptWrite
)

Node State

View Source
const (
	// Master use to consistency of read and write and detect active master transaction manager
	ReplicationStateMaster uint8 = iota
	ReplicationStateReadWrite
	ReplicationStateRead
	ReplicationStateStop
)

Replication State

Variables

View Source
var (
	ErrHashIndexRecordNil         = errors.New("HashIndexRecordNil", "Given hash record can't be nil")
	ErrHashIndexRecordNotValid    = errors.New("HashIndexRecordNotValid", "Given recordID exist in storage devices but has diffrent StructureID")
	ErrHashIndexRecordNotExist    = errors.New("HashIndexRecordNotExist", "Given recordID not exist in any storage devices")
	ErrHashIndexRecordManipulated = errors.New("HashIndexRecordManipulated", "HashIndex record has problem when engine try to read it from storage devices")

	ErrNodeNotGanjineNode = errors.New("NodeNotGanjineNode", "Given request can't proccess due to send to an non Ganjine node")
)

Declare Errors Details

Functions

This section is empty.

Types

type Cluster

type Cluster struct {
	State              int      // States locate in const of this file.
	Capacity           [16]byte // In bytes, Max 2^128 Byte, Is it enough!!??
	Manifest           Manifest
	Replications       replications
	Node               *Node    // This active node, nil if node just be service node!
	PrimaryIndexRanges []uint64 // First left 64bit of record ID!
	TransactionManager TransactionManager
	OldCluster         *Cluster // Just exist in Re-Allocate proccess like add node or replication zone!
	Server             *achaemenid.Server
}

Cluster store all cluster data, that each node in cluster and SDK in authorized app must have full sync of it to work probably!!

func (*Cluster) FindNodeIDByRecordID

func (c *Cluster) FindNodeIDByRecordID(recordID [32]byte) (nodeID uint32)

FindNodeIDByRecordID use to find responsible node ID for given record node part! Nodes in each replication store in sort so nodeID is array location of desire node in any replication!

func (*Cluster) GetLocalNodeDetail

func (c *Cluster) GetLocalNodeDetail() (res *Node, err error)

GetLocalNodeDetail return local ganjine node detail or related error.

func (*Cluster) GetNodeByRecordID

func (c *Cluster) GetNodeByRecordID(recordID [32]byte) (node *Node)

GetNodeByRecordID returns the node have desire record in best replication.

func (*Cluster) GetNodeByReplicationID

func (c *Cluster) GetNodeByReplicationID(repID uint8, nodeLoc uint32) (node *Node)

GetNodeByReplicationID returns the node in desire replication.

func (*Cluster) GetZoneBy

func (c *Cluster) GetZoneBy(recordID [32]byte) (rep *Node)

GetZoneBy returns the node have desire index in best replication.

func (*Cluster) Init

func (c *Cluster) Init(s *achaemenid.Server) (err error)

Init initialize an exiting cluster to get or make a cluster!

func (*Cluster) Shutdown

func (c *Cluster) Shutdown(s *achaemenid.Server) (err error)

Shutdown the cluster!

type Manifest

type Manifest struct {
	DataCentersClass uint8 // 0:FirstClass 256:Low-Quality default:0

	TotalZones       uint8  // ReplicationNumber, deafult:3
	TotalNodesInZone uint32 // not count replicated nodes, just one of them count.

	TransactionTimeOut uint16 // in ms, default:500ms, Max 65.535s timeout
	NodeFailureTimeOut uint16 // in minute, default:60m, other corresponding node same range will replace failed node! not use in network failure, it is handy proccess!

	CachePercent uint8 // GC cached records when reach this size limit!
}

Manifest store Ganjine manifest data

type Node

type Node struct {
	achaemenid.Node
	ID uint32 // this ID locate node in replication

	State uint8
	// contains filtered or unexported fields
}

Node is an individual machine running Ganjine Same replicated node on other replication must have same StartRange, EndRange and HashIndexRecordID!

func (*Node) SyllabDecoder

func (n *Node) SyllabDecoder(buf []byte) (err error)

SyllabDecoder decode from buf to req

func (*Node) SyllabEncoder

func (n *Node) SyllabEncoder() (buf []byte)

SyllabEncoder encode req to buf

type TransactionManager

type TransactionManager struct {
}

TransactionManager or transactional authority store

func (*TransactionManager) FinishTransaction

func (tm *TransactionManager) FinishTransaction(indexHash [32]byte, record []byte) (err error)

FinishTransaction approve transaction!

func (*TransactionManager) GetIndexRecords

func (tm *TransactionManager) GetIndexRecords(indexHash [32]byte) (recordsID [][32]byte)

GetIndexRecords return related records ID to given index.

func (*TransactionManager) RegisterTransaction

func (tm *TransactionManager) RegisterTransaction(indexHash [32]byte, recordID [32]byte) (Record []byte, err error)

RegisterTransaction register new transaction on queue and get last record when transaction ready for this one!

Jump to

Keyboard shortcuts

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