counters

package
v0.0.0-...-f6902ab Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2023 License: Apache-2.0 Imports: 8 Imported by: 8

Documentation

Index

Constants

View Source
const (
	CncFile                 = "cnc.dat"
	CurrentCncVersion int32 = 512 // util.SemanticVersionCompose(0, 2, 0)
)
View Source
const CounterLength = util.CacheLineLength * 2
View Source
const FreeForReuseDeadlineOffset = TypeIdOffset + util.SizeOfInt32

FreeForReuseDeadlineOffset is the offset in the record at which the deadline (in milliseconds) for when counter may be reused.

View Source
const FullLabelLength = util.CacheLineLength * 6
View Source
const LabelOffset = util.CacheLineLength * 2
View Source
const MaxKeyLength = (util.CacheLineLength * 2) - (util.SizeOfInt32 * 2) - util.SizeOfInt64
View Source
const MaxLabelLength = FullLabelLength - util.SizeOfInt32
View Source
const MetadataLength = LabelOffset + FullLabelLength
View Source
const NullCounterId = int32(-1)
View Source
const RecordAllocated int32 = 1
View Source
const RecordReclaimed int32 = -1
View Source
const RecordUnused int32 = 0
View Source
const RegistrationIdOffset = util.SizeOfInt64
View Source
const TypeIdOffset = util.SizeOfInt32

Variables

This section is empty.

Functions

This section is empty.

Types

type AtomicCounter

type AtomicCounter struct {
	Reader    *Reader
	CounterId int32
	// contains filtered or unexported fields
}

func NewAtomicCounter

func NewAtomicCounter(reader *Reader, counterId int32) (*AtomicCounter, error)

func (*AtomicCounter) Get

func (ac *AtomicCounter) Get() int64

func (*AtomicCounter) GetWeak

func (ac *AtomicCounter) GetWeak() int64

func (*AtomicCounter) Label

func (ac *AtomicCounter) Label() string

func (*AtomicCounter) Set

func (ac *AtomicCounter) Set(value int64)

func (*AtomicCounter) SetWeak

func (ac *AtomicCounter) SetWeak(value int64)

func (*AtomicCounter) State

func (ac *AtomicCounter) State() int32

type Counter

type Counter struct {
	Id     int32
	TypeId int32
	Value  int64
	Label  string
}

type MetaDataFlyweight

type MetaDataFlyweight struct {
	flyweight.FWBase

	CncVersion flyweight.Int32Field

	ClientLivenessTo     flyweight.Int64Field
	DriverStartTimestamp flyweight.Int64Field
	DriverPid            flyweight.Int64Field

	ToDriverBuf  flyweight.RawDataField
	ToClientsBuf flyweight.RawDataField
	MetaDataBuf  flyweight.RawDataField
	ValuesBuf    flyweight.RawDataField
	ErrorBuf     flyweight.RawDataField
	// contains filtered or unexported fields
}

*

  • Description of the command and control file used between driver and clients.
  • <p>
  • File Layout
  • <pre>
  • +-----------------------------+
  • | Meta Data |
  • +-----------------------------+
  • | to-driver Buffer |
  • +-----------------------------+
  • | to-clients Buffer |
  • +-----------------------------+
  • | Counters Metadata Buffer |
  • +-----------------------------+
  • | Counters Values Buffer |
  • +-----------------------------+
  • | Error Log |
  • +-----------------------------+
  • </pre>
  • <p>
  • Meta Data Layout (CnC Version 0.2.0 => 512)
  • <pre>
  • 0 1 2 3
  • 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  • +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  • | Aeron CnC Version |
  • +---------------------------------------------------------------+
  • | to-driver buffer length |
  • +---------------------------------------------------------------+
  • | to-clients buffer length |
  • +---------------------------------------------------------------+
  • | Counters Metadata buffer length |
  • +---------------------------------------------------------------+
  • | Counters Values buffer length |
  • +---------------------------------------------------------------+
  • | Error Log buffer length |
  • +---------------------------------------------------------------+
  • | Client Liveness Timeout |
  • | |
  • +---------------------------------------------------------------+
  • | Driver Start Timestamp |
  • | |
  • +---------------------------------------------------------------+
  • | Driver PID |
  • | |
  • +---------------------------------------------------------------+
  • </pre> *
  • See also <a href="https://github.com/real-logic/aeron/blob/master/aeron-client/src/main/cpp/CncFileDescriptor.h">CncFileDescriptor.h</a>.

func InitAndWrapMetaData

func InitAndWrapMetaData(buf *atomic.Buffer, offset int, toDriverBufLen int32, toClientBufLen int32,
	metadataBufLen int32, valuesBufLen int32, errorLogLen int32) *MetaDataFlyweight

InitAndWrapMetaData is a test method to inject the desired values into the buffer, then wrap it as a MetaDataFlyweight.

func MapFile

func MapFile(filename string) (*MetaDataFlyweight, *memmap.File, error)

func (*MetaDataFlyweight) Wrap

func (m *MetaDataFlyweight) Wrap(buf *atomic.Buffer, offset int) flyweight.Flyweight

type ReadableCounter

type ReadableCounter struct {
	Reader         *Reader
	RegistrationId int64
	CounterId      int32
	// contains filtered or unexported fields
}

func NewReadableCounter

func NewReadableCounter(reader *Reader, counterId int32) (*ReadableCounter, error)

func NewReadableRegisteredCounter

func NewReadableRegisteredCounter(reader *Reader, registrationId int64, counterId int32) (*ReadableCounter, error)

func (*ReadableCounter) Close

func (rc *ReadableCounter) Close()

func (*ReadableCounter) Get

func (rc *ReadableCounter) Get() int64

func (*ReadableCounter) GetWeak

func (rc *ReadableCounter) GetWeak() int64

func (*ReadableCounter) IsClosed

func (rc *ReadableCounter) IsClosed() bool

func (*ReadableCounter) Label

func (rc *ReadableCounter) Label() string

func (*ReadableCounter) State

func (rc *ReadableCounter) State() int32

type Reader

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

func NewReader

func NewReader(values, metaData *atomic.Buffer) *Reader

func (*Reader) FindCounter

func (reader *Reader) FindCounter(typeId int32, keyFilter func(keyBuffer *atomic.Buffer) bool) int32

func (*Reader) GetCounterOwnerId

func (reader *Reader) GetCounterOwnerId(counterId int32) int64

func (*Reader) GetCounterRegistrationId

func (reader *Reader) GetCounterRegistrationId(counterId int32) int64

func (*Reader) GetCounterTypeId

func (reader *Reader) GetCounterTypeId(counterId int32) int32

GetCounterTypeId returns the type id for a counter.

func (*Reader) GetCounterValue

func (reader *Reader) GetCounterValue(counterId int32) int64

GetCounterValue returns the value of the given counter id (as a volatile read).

func (*Reader) GetKeyPartInt32

func (reader *Reader) GetKeyPartInt32(counterId int32, offset int32) (int32, error)

GetKeyPartInt32 returns an int32 portion of the key at the specified offset

func (*Reader) GetKeyPartInt64

func (reader *Reader) GetKeyPartInt64(counterId int32, offset int32) (int64, error)

GetKeyPartInt64 returns an int64 portion of the key at the specified offset

func (*Reader) GetKeyPartString

func (reader *Reader) GetKeyPartString(counterId int32, offset int32) (string, error)

GetKeyPartString returns a string portion of the key, assuming the string is prefixed by its length (as an 32-bit int) at the specified offset.

func (*Reader) IsCounterAllocated

func (reader *Reader) IsCounterAllocated(counterId int32) bool

func (*Reader) Scan

func (reader *Reader) Scan(cb func(Counter))

func (*Reader) ScanForType

func (reader *Reader) ScanForType(typeId int32, callback func(counterId int32, keyBuffer *atomic.Buffer) bool)

Jump to

Keyboard shortcuts

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