nl

package
v1.3.19 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package notifications provides interfaces for AIStore notifications

  • Copyright (c) 2018-2021, NVIDIA CORPORATION. All rights reserved.

Package notifications provides interfaces for AIStore notifications

  • Copyright (c) 2018-2021, NVIDIA CORPORATION. All rights reserved.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OnFinished

func OnFinished(n cluster.Notif, err error)

func OnProgress

func OnProgress(n cluster.Notif)

Types

type Base

type Base struct {
	F func(n cluster.Notif, err error) // notification callback
	P func(n cluster.Notif)            // on progress notification callback

	Dsts []string // node IDs to notify

	When     cluster.Upon  // see the enum below
	Interval time.Duration // interval at which progress needs to be updated
	// contains filtered or unexported fields
}

func (*Base) LastNotifTime

func (base *Base) LastNotifTime() int64

func (*Base) NotifyInterval

func (base *Base) NotifyInterval() time.Duration

func (*Base) OnFinishedCB

func (base *Base) OnFinishedCB() func(cluster.Notif, error)

func (*Base) OnProgressCB

func (base *Base) OnProgressCB() func(cluster.Notif)

func (*Base) SetLastNotified

func (base *Base) SetLastNotified(now int64)

func (*Base) Subscribers

func (base *Base) Subscribers() []string

func (*Base) Upon

func (base *Base) Upon(u cluster.Upon) bool

type Callback

type Callback func(n Listener)

type Listener

type Listener interface {
	Callback(nl Listener, ts int64)
	UnmarshalStats(rawMsg []byte) (any, bool, bool, error)
	Lock()
	Unlock()
	RLock()
	RUnlock()
	Notifiers() meta.NodeMap
	Kind() string
	Bcks() []*cmn.Bck
	SetErr(error)
	Err() error
	UUID() string
	SetAborted()
	Aborted() bool
	Status() *Status
	SetStats(daeID string, stats any)
	NodeStats() *NodeStats
	QueryArgs() cmn.HreqArgs
	EndTime() int64
	SetAddedTime()
	AddedTime() int64
	Finished() bool
	String() string
	GetOwner() string
	SetOwner(string)
	LastUpdated(si *meta.Snode) int64
	ProgressInterval() time.Duration

	// detailed ref-counting
	ActiveNotifiers() meta.NodeMap
	FinCount() int
	ActiveCount() int
	HasFinished(node *meta.Snode) bool
	MarkFinished(node *meta.Snode)
	NodesTardy(periodicNotifTime time.Duration) (nodes meta.NodeMap, tardy bool)
}

type ListenerBase

type ListenerBase struct {
	Common struct {
		UUID        string
		Action      string // async operation kind (see cmn/api_const.go)
		Owned       string // "": not owned | equalIC: IC | otherwise, pid + IC
		SmapVersion int64  // smap version in which NL is added
		Bck         []*cmn.Bck
	}
	// construction
	Srcs       meta.NodeMap // all notifiers
	ActiveSrcs meta.NodeMap // running notifiers
	F          Callback     `json:"-"` // optional listening-side callback
	Stats      *NodeStats   // [daeID => Stats (e.g. cmn.SnapExt)]

	// runtime
	EndTimeX atomic.Int64 // timestamp when finished
	AbortedX atomic.Bool  // sets if the xaction is Aborted
	ErrValue cos.ErrValue // reported error and count
	// contains filtered or unexported fields
}

func NewNLB

func NewNLB(uuid, action string, smap *meta.Smap, srcs meta.NodeMap, progress time.Duration, bck ...*cmn.Bck) *ListenerBase

func (*ListenerBase) Aborted

func (nlb *ListenerBase) Aborted() bool

func (*ListenerBase) ActiveCount

func (nlb *ListenerBase) ActiveCount() int

func (*ListenerBase) ActiveNotifiers

func (nlb *ListenerBase) ActiveNotifiers() meta.NodeMap

func (*ListenerBase) AddedTime

func (nlb *ListenerBase) AddedTime() int64

func (*ListenerBase) Bcks

func (nlb *ListenerBase) Bcks() []*cmn.Bck

func (*ListenerBase) Callback

func (nlb *ListenerBase) Callback(nl Listener, ts int64)

is called after all Notifiers will have notified OR on failure (err != nil)

func (*ListenerBase) EndTime

func (nlb *ListenerBase) EndTime() int64

func (*ListenerBase) Err

func (nlb *ListenerBase) Err() error

func (*ListenerBase) FinCount

func (nlb *ListenerBase) FinCount() int

func (*ListenerBase) Finished

func (nlb *ListenerBase) Finished() bool

func (*ListenerBase) GetOwner

func (nlb *ListenerBase) GetOwner() string

func (*ListenerBase) HasFinished

func (nlb *ListenerBase) HasFinished(node *meta.Snode) bool

func (*ListenerBase) Kind

func (nlb *ListenerBase) Kind() string

func (*ListenerBase) LastUpdated

func (nlb *ListenerBase) LastUpdated(si *meta.Snode) int64

func (*ListenerBase) Lock

func (nlb *ListenerBase) Lock()

func (*ListenerBase) MarkFinished

func (nlb *ListenerBase) MarkFinished(node *meta.Snode)

func (*ListenerBase) NodeStats

func (nlb *ListenerBase) NodeStats() *NodeStats

func (*ListenerBase) NodesTardy

func (nlb *ListenerBase) NodesTardy(periodicNotifTime time.Duration) (nodes meta.NodeMap, tardy bool)

under rlock

func (*ListenerBase) Notifiers

func (nlb *ListenerBase) Notifiers() meta.NodeMap

func (*ListenerBase) ProgressInterval

func (nlb *ListenerBase) ProgressInterval() time.Duration

func (*ListenerBase) RLock

func (nlb *ListenerBase) RLock()

func (*ListenerBase) RUnlock

func (nlb *ListenerBase) RUnlock()

func (*ListenerBase) SetAborted

func (nlb *ListenerBase) SetAborted()

func (*ListenerBase) SetAddedTime

func (nlb *ListenerBase) SetAddedTime()

func (*ListenerBase) SetErr

func (nlb *ListenerBase) SetErr(err error)

func (*ListenerBase) SetOwner

func (nlb *ListenerBase) SetOwner(o string)

func (*ListenerBase) SetStats

func (nlb *ListenerBase) SetStats(daeID string, stats any)

func (*ListenerBase) Status

func (nlb *ListenerBase) Status() *Status

func (*ListenerBase) String

func (nlb *ListenerBase) String() string

func (*ListenerBase) UUID

func (nlb *ListenerBase) UUID() string

func (*ListenerBase) Unlock

func (nlb *ListenerBase) Unlock()

type NodeStats

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

func NewNodeStats

func NewNodeStats(sizes ...int) *NodeStats

func (*NodeStats) Len

func (ns *NodeStats) Len() (l int)

func (*NodeStats) Load

func (ns *NodeStats) Load(key string) (val any, ok bool)

func (*NodeStats) MarshalJSON

func (ns *NodeStats) MarshalJSON() (data []byte, err error)

func (*NodeStats) Range

func (ns *NodeStats) Range(f func(string, any) bool)

func (*NodeStats) Store

func (ns *NodeStats) Store(key string, stats any)

func (*NodeStats) UnmarshalJSON

func (ns *NodeStats) UnmarshalJSON(data []byte) (err error)

type Status

type Status struct {
	Kind     string `json:"kind"`     // xaction kind
	UUID     string `json:"uuid"`     // xaction UUID
	ErrMsg   string `json:"err"`      // error
	EndTimeX int64  `json:"end_time"` // time xaction ended
	AbortedX bool   `json:"aborted"`  // true if aborted
}

func (*Status) Aborted

func (ns *Status) Aborted() bool

func (*Status) Finished

func (ns *Status) Finished() bool

func (*Status) String

func (ns *Status) String() (s string)

type StatusVec

type StatusVec []Status

func (StatusVec) String

func (nsv StatusVec) String() (s string)

Jump to

Keyboard shortcuts

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