registry

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: May 7, 2018 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Registry

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

Registry is a dqlite node-level data structure that tracks:

- The directory where dqlite data for this node lives.

  • All SQLite connections opened on the node, either in leader replication mode or follower replication mode.
  • All inflight WAL write transactions, either for leader or follower connections.

- All tracers used to emit trace messages.

- Last log index applied by the FSM.

A single Registry instance is shared by a single replication.FSM instance, a single replication.Methods instance and a single dqlite.Driver instance.

Methods that access or mutate the registry are not thread-safe and must be performed after acquiring the lock. See Lock() and Unlock().

func New

func New(dir string) *Registry

New creates a new registry.

The 'dir' parameter sets the directory where the node associated with this registry will save the SQLite database files.

func (*Registry) ConnFollower

func (r *Registry) ConnFollower(filename string) *sqlite3.SQLiteConn

ConnFollower returns the follower connection used to replicate the database identified by the given filename.

If there's no follower connection registered for the database with the given filename, this method panics.

func (*Registry) ConnFollowerAdd

func (r *Registry) ConnFollowerAdd(filename string, conn *sqlite3.SQLiteConn)

ConnFollowerAdd adds a new follower connection to the registry.

If a follower connection for the database with the given filename is already registered, this method panics.

func (*Registry) ConnFollowerDel

func (r *Registry) ConnFollowerDel(filename string)

ConnFollowerDel removes the follower registered against the database with the given filename.

func (*Registry) ConnFollowerExists

func (r *Registry) ConnFollowerExists(filename string) bool

ConnFollowerExists checks whether the registry has a follower connection registered against the database with the given filename.

func (*Registry) ConnFollowerFilenames

func (r *Registry) ConnFollowerFilenames() []string

ConnFollowerFilenames returns the filenames for all databases which currently have registered follower connections.

func (*Registry) ConnLeaderAdd

func (r *Registry) ConnLeaderAdd(filename string, conn *sqlite3.SQLiteConn)

ConnLeaderAdd adds a new leader connection to the registry.

func (*Registry) ConnLeaderDel

func (r *Registry) ConnLeaderDel(conn *sqlite3.SQLiteConn)

ConnLeaderDel removes the given leader connection from the registry.

func (*Registry) ConnLeaderFilename

func (r *Registry) ConnLeaderFilename(conn *sqlite3.SQLiteConn) string

ConnLeaderFilename returns the filename of the database associated with the given leader connection.

If conn is not a registered leader connection, this method will panic.

func (*Registry) ConnLeaders

func (r *Registry) ConnLeaders(filename string) []*sqlite3.SQLiteConn

ConnLeaders returns all open leader connections for the database with the given filename.

func (*Registry) ConnSerial

func (r *Registry) ConnSerial(conn *sqlite3.SQLiteConn) uint64

ConnSerial returns a serial number uniquely identifying the given registered connection.

func (*Registry) Dir

func (r *Registry) Dir() string

Dir is the directory where replicated SQLite files are stored.

func (*Registry) Dump

func (r *Registry) Dump() string

Dump the content of the registry, useful for debugging.

func (*Registry) Frames

func (r *Registry) Frames() uint64

Frames returns the number of frames that have been written to the WAL so far.

func (*Registry) FramesIncrease

func (r *Registry) FramesIncrease(n uint64)

FramesIncrease increases by the given amount the number of frames written to the WAL so far.

func (*Registry) FramesReset

func (r *Registry) FramesReset()

FramesReset resets the WAL frames counter to zero.

func (*Registry) HookSyncAdd

func (r *Registry) HookSyncAdd(data []byte)

HookSyncAdd adds a new log command data to the underlying hookSync, which is expected to match the Log.Data bytes received next FSM.Apply() call.

func (*Registry) HookSyncMatches

func (r *Registry) HookSyncMatches(data []byte) bool

HookSyncMatches checks whether the Log.Data bytes that an FSM.Apply() call is about to process match the ones that were last added to the hookSync via HookSyncAdd().

func (*Registry) HookSyncPresent

func (r *Registry) HookSyncPresent() bool

HookSyncPresent checks whether a hook sync was set by methods hook.

func (*Registry) HookSyncReset

func (r *Registry) HookSyncReset()

HookSyncReset clears the hookSync instance created with HookSyncSet.

func (*Registry) HookSyncSet

func (r *Registry) HookSyncSet()

HookSyncSet creates a new hookSync instance associated with this Registry.

func (*Registry) HookSyncWait

func (r *Registry) HookSyncWait()

HookSyncWait blocks until the underlying hookSync is done.

It assumes that the lock is held, releasing it before blocking and requiring it thereafter.

func (*Registry) Index

func (r *Registry) Index() uint64

Index returns the last Raft log index that was successfully applied the FSM.

func (*Registry) IndexUpdate

func (r *Registry) IndexUpdate(index uint64)

IndexUpdate updates the index of the last log applied by the FSM we're associated with.

func (*Registry) Lock

func (r *Registry) Lock()

Lock the registry.

func (*Registry) Testing

func (r *Registry) Testing(t *testing.T, node int)

Testing sets up this registry for unit-testing.

The tracers will forward all entries to the testing logger, using the given node prefix.

func (*Registry) TracerConn

func (r *Registry) TracerConn(conn *sqlite3.SQLiteConn, hook string) *trace.Tracer

TracerConn returns the tracer that should be used by the replication.Methods instance associated with this registry when running the given hook for the given connection, which is assumed to be a registered leader connection.

func (*Registry) TracerFSM

func (r *Registry) TracerFSM() *trace.Tracer

TracerFSM returns the tracer that should be used by the replication.FSM instance associated with this registry.

func (*Registry) TxnByConn

func (r *Registry) TxnByConn(conn *sqlite3.SQLiteConn) *transaction.Txn

TxnByConn returns the transaction associated with the given connection, if any.

func (*Registry) TxnByFilename

func (r *Registry) TxnByFilename(filename string) *transaction.Txn

TxnByFilename returns the transaction associated with the given database filename, if any.

If there is more than one transaction for the same filename, this method panics.

func (*Registry) TxnByID

func (r *Registry) TxnByID(id uint64) *transaction.Txn

TxnByID returns the transaction with the given ID, if it exists.

func (*Registry) TxnCommittedAdd

func (r *Registry) TxnCommittedAdd(txn *transaction.Txn)

TxnCommittedAdd saves the ID of the given transaction in the committed buffer, in case a client needs to check if it can be recovered.

func (*Registry) TxnCommittedFind

func (r *Registry) TxnCommittedFind(id uint64) bool

TxnCommittedFind scans the comitted buffer and returns true if the given ID is present.

func (*Registry) TxnDel

func (r *Registry) TxnDel(id uint64)

TxnDel deletes the transaction with the given ID.

func (*Registry) TxnDryRun

func (r *Registry) TxnDryRun()

TxnDryRun makes transactions only transition between states, without actually invoking the relevant SQLite APIs. This is used by tests and by surrogate followers.

func (*Registry) TxnFollowerAdd

func (r *Registry) TxnFollowerAdd(conn *sqlite3.SQLiteConn, id uint64) *transaction.Txn

TxnFollowerAdd adds a new follower transaction to the registry.

The given connection is assumed to be in follower replication mode. The new transaction will be associated with the given transaction ID, which should match the one of the leader transaction that initiated the write.

func (*Registry) TxnFollowerResurrected

func (r *Registry) TxnFollowerResurrected(txn *transaction.Txn)

TxnFollowerResurrected registers a follower transaction created by resurrecting a zombie leader transaction.

func (*Registry) TxnFollowerSurrogate

func (r *Registry) TxnFollowerSurrogate(txn *transaction.Txn) *transaction.Txn

TxnFollowerSurrogate creates a surrogate follower transaction.

Surrogate follower transactions are used to replace leader transactions when a node loses leadership and are supposed to be undone by the next leader.

func (*Registry) TxnLastID

func (r *Registry) TxnLastID(conn *sqlite3.SQLiteConn) uint64

TxnLastID returns the ID of the last transaction executed on the given leader connection.

func (*Registry) TxnLeaderAdd

func (r *Registry) TxnLeaderAdd(conn *sqlite3.SQLiteConn, id uint64) *transaction.Txn

TxnLeaderAdd adds a new transaction to the registry.

The given connection is assumed to be in leader replication mode.

func (*Registry) TxnLeaderByFilename

func (r *Registry) TxnLeaderByFilename(filename string) *transaction.Txn

TxnLeaderByFilename returns the leader transaction associated with the given database filename, if any.

If there is more than one leader transaction for the same filename, this method panics.

func (*Registry) Unlock

func (r *Registry) Unlock()

Unlock the registry.

Jump to

Keyboard shortcuts

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