Commit f1f7eb02 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 110de273
......@@ -52,19 +52,20 @@ type tEnv struct {
// Create it with tEnv.NewCluster.
// Create nodes with .NewMaster, .NewStorage and .NewClient.
//
// NOTE network addresses are predictable due to using pipenet/lonet for inter-node networking.
// The cluster is tested based on synchronous event tracing -
// see package lab.nexedi.com/kirr/go123/tracing/tracetest for context.
//
// XXX text about events tracing
// NOTE network addresses are predictable due to using pipenet/lonet for inter-node networking.
type tCluster struct {
*tEnv // original testing env this cluster was created at
name string // name of the cluster
network *virtnet.SubNetwork // nodes interoperate via network
traceOn bool // whether tracing is currently on or off
gotracer *TraceCollector // for tracing go nodes XXX -> GoTracer
//tpy *PyTracer // for tracing py nodes
erouter *EventRouter // to which stream an event should go
traceOn bool // whether tracing is currently on or off
gotracer *GoTracer // for tracing go nodes
//tpy *PyTracer // for tracing py nodes TODO
erouter *EventRouter // to which stream an event should go
tabMu sync.Mutex
nodeTab map[string/*node*/]*tNode
......
......@@ -29,12 +29,8 @@ import (
"lab.nexedi.com/kirr/neo/go/neo/xneo"
)
// GoTraceCollector collects events from NEO/go trace points and sends them to event dispatcher.
//
// TraceCollector connects to NEO-specific trace points via probes and sends events to dispatcher.
//
// XXX naming -> GoTracer (and PyTracer for NEO/py)
type TraceCollector struct {
// GoTracer collects events from NEO/go trace points and sends them to event dispatcher.
type GoTracer struct {
pg *tracing.ProbeGroup
rx interface { RxEvent(interface{}) }
......@@ -43,8 +39,8 @@ type TraceCollector struct {
clusterState2Owner map[*proto.ClusterState]string
}
func NewTraceCollector(rx interface { RxEvent(interface{}) }) *TraceCollector {
return &TraceCollector{
func NewTraceCollector(rx interface { RxEvent(interface{}) }) *GoTracer {
return &GoTracer{
pg: &tracing.ProbeGroup{},
rx: rx,
......@@ -59,7 +55,7 @@ func NewTraceCollector(rx interface { RxEvent(interface{}) }) *TraceCollector {
//trace:import "lab.nexedi.com/kirr/neo/go/neo/xneo"
// Attach attaches the tracer to appropriate trace points.
func (t *TraceCollector) Attach() {
func (t *GoTracer) Attach() {
tracing.Lock()
//neo_traceMsgRecv_Attach(t.pg, t.traceNeoMsgRecv)
neonet_traceMsgSendPre_Attach(t.pg, t.traceNeoMsgSendPre)
......@@ -69,7 +65,7 @@ func (t *TraceCollector) Attach() {
tracing.Unlock()
}
func (t *TraceCollector) Detach() {
func (t *GoTracer) Detach() {
t.pg.Done()
}
......@@ -77,7 +73,7 @@ func (t *TraceCollector) Detach() {
//
// This way it can translate e.g. *NodeTable -> owner node name when creating
// corresponding event.
func (t *TraceCollector) RegisterNode(node *xneo.Node, name string) {
func (t *GoTracer) RegisterNode(node *xneo.Node, name string) {
tracing.Lock()
defer tracing.Unlock()
......@@ -88,14 +84,14 @@ func (t *TraceCollector) RegisterNode(node *xneo.Node, name string) {
t.clusterState2Owner[&node.State.Code] = name
}
func (t *TraceCollector) TraceNetDial(ev *xnet.TraceDial) {
func (t *GoTracer) TraceNetDial(ev *xnet.TraceDial) {
t.rx.RxEvent(&eventNetDial{
Dialer: ev.Dialer,
Addr: ev.Addr,
})
}
func (t *TraceCollector) TraceNetConnect(ev *xnet.TraceConnect) {
func (t *GoTracer) TraceNetConnect(ev *xnet.TraceConnect) {
t.rx.RxEvent(&eventNetConnect{
Src: ev.Src.String(),
Dst: ev.Dst.String(),
......@@ -103,27 +99,27 @@ func (t *TraceCollector) TraceNetConnect(ev *xnet.TraceConnect) {
})
}
func (t *TraceCollector) TraceNetListen(ev *xnet.TraceListen) {
func (t *GoTracer) TraceNetListen(ev *xnet.TraceListen) {
t.rx.RxEvent(&eventNetListen{Laddr: ev.Laddr.String()})
}
func (t *TraceCollector) TraceNetTx(ev *xnet.TraceTx) {} // we use traceNeoMsgSend instead
func (t *GoTracer) TraceNetTx(ev *xnet.TraceTx) {} // we use traceNeoMsgSend instead
func (t *TraceCollector) traceNeoMsgSendPre(l *neonet.NodeLink, connID uint32, msg proto.Msg) {
func (t *GoTracer) traceNeoMsgSendPre(l *neonet.NodeLink, connID uint32, msg proto.Msg) {
t.rx.RxEvent(&eventNeoSend{l.LocalAddr().String(), l.RemoteAddr().String(), connID, msg})
}
func (t *TraceCollector) traceClusterState(cs *proto.ClusterState) {
func (t *GoTracer) traceClusterState(cs *proto.ClusterState) {
where := t.clusterState2Owner[cs]
t.rx.RxEvent(&eventClusterState{where, *cs})
}
func (t *TraceCollector) traceNode(nt *xneo.NodeTable, n *xneo.PeerNode) {
func (t *GoTracer) traceNode(nt *xneo.NodeTable, n *xneo.PeerNode) {
where := t.nodeTab2Owner[nt]
t.rx.RxEvent(&eventNodeTab{where, n.NodeInfo})
}
func (t *TraceCollector) traceMasterStartReady(m *Master, ready bool) {
func (t *GoTracer) traceMasterStartReady(m *Master, ready bool) {
where := t.node2Name[m.node]
t.rx.RxEvent(&eventMStartReady{where, ready})
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment