signal

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2016 License: Apache-2.0 Imports: 12 Imported by: 26

Documentation

Index

Constants

View Source
const (
	// read-only ops use posthooks
	PostRead    = "post-read"
	PostOpenDir = "post-opendir"
	// write ops use prehooks
	PreWrite = "pre-write"
	PreMkdir = "pre-mkdir"
	PreRmdir = "pre-rmdir"
	PreFsync = "pre-fsync"
)

Variables

This section is empty.

Functions

func GetSignalClass

func GetSignalClass(name string) *reflect.Type

name is a REST JSON class name

func RegisterKnownSignals

func RegisterKnownSignals()

func RegisterSignalClass

func RegisterSignalClass(name string, value interface{})

Register an event class so that it can be serialized/deserialized

name is a REST JSON class name

Types

type Action

type Action interface {
	// these fields are same as in Signal
	ID() string
	EntityID() string
	ArrivedTime() time.Time
	JSONMap() map[string]interface{}
	String() string

	// comparator, excluding uuid
	Equals(o Action) bool

	// triggered time (only orchestrator should call this)
	TriggeredTime() time.Time

	// set triggered time (only orchestrator should call this)
	SetTriggeredTime(time.Time)

	// in fault actions, can be nil (but not always)
	Event() Event
}

Action signal interface (orchestrator->inspector)

func NewEventAcceptanceAction

func NewEventAcceptanceAction(event Event) (Action, error)

func NewFilesystemFaultAction

func NewFilesystemFaultAction(event Event) (Action, error)

func NewNopAction

func NewNopAction(entityID string, event Event) (Action, error)

entityID: can be empty string ("")

event: can be nil

func NewPacketFaultAction

func NewPacketFaultAction(event Event) (Action, error)

func NewProcSetSchedAction

func NewProcSetSchedAction(event Event, attrs map[string]linuxsched.SchedAttr) (Action, error)

func NewShellAction

func NewShellAction(command string, comments map[string]interface{}) (Action, error)

Execute a shell command (blocking). The action is not expected to be tied with any event.

command: shell command string

comments: arbitrary info for user-written exploration policy (not passed to the command itself). e.g., - entity_id(string): entity if that will be killed or shut down

  • expected(bool): true for expected shutdown, false for unexpected kill

type ArrivalSignal

type ArrivalSignal interface {
	LoadJSONMap(map[string]interface{}) error
	SetArrivedTime(time.Time)
}

type BasicAction

type BasicAction struct {
	BasicSignal
	// capitalized for encoding/gob
	Triggered  time.Time
	CauseEvent Event
}

func (*BasicAction) Equals

func (this *BasicAction) Equals(o Action) bool

implements Action

func (*BasicAction) Event

func (this *BasicAction) Event() Event

implements Action

if only event_uuid is known, return a dummy empty event (NopEvent). this case happens when called from inspector

func (*BasicAction) SetTriggeredTime

func (this *BasicAction) SetTriggeredTime(triggeredTime time.Time)

implements Action

func (*BasicAction) TriggeredTime

func (this *BasicAction) TriggeredTime() time.Time

implements Action

type BasicEvent

type BasicEvent struct {
	BasicSignal
}

func (*BasicEvent) DefaultAction

func (this *BasicEvent) DefaultAction() (Action, error)

implements Event

func (*BasicEvent) DefaultFaultAction

func (this *BasicEvent) DefaultFaultAction() (Action, error)

implements Event

func (*BasicEvent) Deferred

func (this *BasicEvent) Deferred() bool

implements Event

func (*BasicEvent) Equals

func (this *BasicEvent) Equals(o Event) bool

implements Event

func (*BasicEvent) ReplayHint

func (this *BasicEvent) ReplayHint() string

implements Event

func (*BasicEvent) SetDeferred

func (this *BasicEvent) SetDeferred(deferred bool)

func (*BasicEvent) SetReplayHint

func (this *BasicEvent) SetReplayHint(hint string)

type BasicPBAction

type BasicPBAction struct {
	BasicAction
}

for ProtocolBuffers actions

implements Action, PBAction

func (*BasicPBAction) PBResponseMessage

func (this *BasicPBAction) PBResponseMessage() *pb.InspectorMsgRsp

implements PBAction

type BasicSignal

type BasicSignal struct {
	M       map[string]interface{}
	Arrived time.Time
}

Map-based Signal interface implementation

Don't use pointer receiver for this type: https://github.com/golang/go/wiki/CodeReviewComments#receiver-type

func (*BasicSignal) ArrivedTime

func (this *BasicSignal) ArrivedTime() time.Time

implements Signal

func (*BasicSignal) Class

func (this *BasicSignal) Class() string

func (*BasicSignal) EntityID

func (this *BasicSignal) EntityID() string

implements Signal

func (*BasicSignal) EqualsSignal

func (this *BasicSignal) EqualsSignal(o Signal) bool

implements Signal

func (*BasicSignal) Get

func (this *BasicSignal) Get(k string) interface{}

for non-basic fields

func (*BasicSignal) ID

func (this *BasicSignal) ID() string

implements Signal

func (*BasicSignal) InitSignal

func (this *BasicSignal) InitSignal()

func (*BasicSignal) JSONMap

func (this *BasicSignal) JSONMap() map[string]interface{}

implements Signal

func (*BasicSignal) LoadJSONMap

func (this *BasicSignal) LoadJSONMap(m map[string]interface{}) error

func (*BasicSignal) Option

func (this *BasicSignal) Option() map[string]interface{}

func (*BasicSignal) Set

func (this *BasicSignal) Set(k string, v interface{})

for non-basic fields

func (*BasicSignal) SetArrivedTime

func (this *BasicSignal) SetArrivedTime(t time.Time)

func (*BasicSignal) SetClass

func (this *BasicSignal) SetClass(s string)

func (*BasicSignal) SetEntityID

func (this *BasicSignal) SetEntityID(s string)

func (*BasicSignal) SetID

func (this *BasicSignal) SetID(s string)

func (*BasicSignal) SetOption

func (this *BasicSignal) SetOption(m map[string]interface{})

func (*BasicSignal) SetType

func (this *BasicSignal) SetType(s string) error

must be event or signal

func (*BasicSignal) String

func (this *BasicSignal) String() string

implements Signal

func (*BasicSignal) Type

func (this *BasicSignal) Type() string

must be event or signal

type CFunctionEvent

type CFunctionEvent struct {
	FunctionName      string
	FunctionEventType FunctionEventType
	// contains filtered or unexported fields
}

implements Event

not implemented yet

func (*CFunctionEvent) DefaultAction

func (this *CFunctionEvent) DefaultAction() (Action, error)

implements Event NOTE: this method should also put pb{Req,Rsp} to action.Event().

func (*CFunctionEvent) PBRequestMessage

func (this *CFunctionEvent) PBRequestMessage() *pb.InspectorMsgReq

implements PBEvent

type Event

type Event interface {
	// these fields are same as in Signal
	ID() string
	EntityID() string
	ArrivedTime() time.Time
	JSONMap() map[string]interface{}
	String() string

	// comparator, excluding uuid
	Equals(o Event) bool

	// if deferred, the inspector is waiting for an action from the orchestrator.
	//
	// json name: "deferred"
	Deferred() bool

	// explore policy can use this hash string as a hint for semi-deterministic replaying.
	// The hint should not contain time-dependent or random things for better determinism.
	// Note that we will not support fully deterministic replaying.
	//
	// The hint can contain any character.
	//
	// json name: "replay_hint"
	ReplayHint() string

	// default positive action. can be NopAction, but cannot be nil.
	// (NopAction is used for history storage)
	DefaultAction() (Action, error)

	// default negative action. can be nil.
	DefaultFaultAction() (Action, error)
}

Event signal interface (inspector->orchestrator)

func NewFilesystemEvent

func NewFilesystemEvent(entityID string, op FilesystemOp, path string, m map[string]interface{}) (Event, error)

func NewJavaFunctionEventFromPB

func NewJavaFunctionEventFromPB(msg pb.InspectorMsgReq, arrivedTime time.Time) (Event, error)

func NewNopEvent

func NewNopEvent(entityID string, m map[string]interface{}) (Event, error)

func NewPacketEvent

func NewPacketEvent(entityID, srcEntityID, dstEntityID string, m map[string]interface{}) (Event, error)

func NewProcSetEvent

func NewProcSetEvent(entityID string, procs []string, m map[string]interface{}) (Event, error)

type EventAcceptanceAction

type EventAcceptanceAction struct {
	BasicPBAction
}

implements Action, PBAction

type Event_JavaSpecific_Param

type Event_JavaSpecific_Param struct {
	Name  string
	Value string
}

for Java

type Event_JavaSpecific_StackTraceElement

type Event_JavaSpecific_StackTraceElement struct {
	LineNumber int
	ClassName  string
	MethodName string
	FileName   string
}

for Java

type FilesystemEvent

type FilesystemEvent struct {
	BasicEvent
}

implements Event

func (*FilesystemEvent) DefaultFaultAction

func (this *FilesystemEvent) DefaultFaultAction() (Action, error)

implements Event

type FilesystemFaultAction

type FilesystemFaultAction struct {
	BasicAction
}

implements Action

type FilesystemOp

type FilesystemOp string

type FunctionEventType

type FunctionEventType int
const (
	NilFunctionEventType FunctionEventType = iota
	FunctionCall
	FunctionReturn
)

type JavaFunctionEvent

type JavaFunctionEvent struct {
	FunctionName       string
	FunctionEventType  FunctionEventType
	ThreadName         string
	StackTraceElements []Event_JavaSpecific_StackTraceElement
	Params             []Event_JavaSpecific_Param
	// contains filtered or unexported fields
}

implements Event

func (*JavaFunctionEvent) DefaultAction

func (this *JavaFunctionEvent) DefaultAction() (Action, error)

implements Event NOTE: this method should also put pb{Req,Rsp} to action.Event().

func (*JavaFunctionEvent) PBRequestMessage

func (this *JavaFunctionEvent) PBRequestMessage() *pb.InspectorMsgReq

implements PBEvent

type LogEvent

type LogEvent struct {
	BasicEvent
}

implements Event

type NopAction

type NopAction struct {
	BasicAction
}

implements Action, OrchestratorSideAction

func (*NopAction) ExecuteOnOrchestrator

func (this *NopAction) ExecuteOnOrchestrator() error

implements OrchestratorSideAction

func (*NopAction) OrchestratorSideOnly

func (this *NopAction) OrchestratorSideOnly() bool

implements OrchestratorSideAction

type NopEvent

type NopEvent struct {
	BasicEvent
}

implements Event

type OrchestratorSideAction

type OrchestratorSideAction interface {
	// if true, the action will not be propagated to inspectors.
	//
	// this field exists mainly for NopAction(for syslog events) and some fault actions
	OrchestratorSideOnly() bool

	// execute shell command or something else
	ExecuteOnOrchestrator() error
}

type PBAction

type PBAction interface {
	// can be nil, if Action.Event() does not implement PBEvent interface.
	PBResponseMessage() *pb.InspectorMsgRsp
}

Action for inspectors that *may* use ProtocolBuffers

type PBEvent

type PBEvent interface {
	PBRequestMessage() *pb.InspectorMsgReq
}

Event for inspectors that *may* use ProtocolBuffers

type PacketEvent

type PacketEvent struct {
	BasicEvent
}

implements Event

func (*PacketEvent) DefaultFaultAction

func (this *PacketEvent) DefaultFaultAction() (Action, error)

implements Event

type PacketFaultAction

type PacketFaultAction struct {
	BasicAction
}

implements Action

type ProcSetEvent

type ProcSetEvent struct {
	BasicEvent
}

Note: DefaultAction() is NopAction, not ProcSetSchedAction implements Event

type ProcSetSchedAction

type ProcSetSchedAction struct {
	BasicAction
}

implements Action

type ShellAction

type ShellAction struct {
	BasicAction
}

implements Action, OrchestratorSideAction

func (*ShellAction) ExecuteOnOrchestrator

func (this *ShellAction) ExecuteOnOrchestrator() error

implements OrchestratorSideAction

func (*ShellAction) OrchestratorSideOnly

func (this *ShellAction) OrchestratorSideOnly() bool

implements OrchestratorSideAction

type Signal

type Signal interface {
	// RFC 4122 UUID
	//
	// json name: "uuid"
	ID() string

	// Entity ID string (e.g. "zksrv1")
	//
	// json name: "entity"
	EntityID() string

	// arrived time
	//
	// for event, only orchestrator should call this.
	// for action, only inspector should call this.
	ArrivedTime() time.Time

	// JSON map. PBEvent also implements this method, mainly for MongoDB storage.
	JSONMap() map[string]interface{}

	// debug string
	String() string
}

you don't have to take care of this interface, see Event and Action

func NewSignalFromJSONString

func NewSignalFromJSONString(jsonString string, arrivedTime time.Time) (Signal, error)

Jump to

Keyboard shortcuts

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