Commit f1f7eb02 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 110de273
...@@ -52,9 +52,10 @@ type tEnv struct { ...@@ -52,9 +52,10 @@ type tEnv struct {
// Create it with tEnv.NewCluster. // Create it with tEnv.NewCluster.
// Create nodes with .NewMaster, .NewStorage and .NewClient. // 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 { type tCluster struct {
*tEnv // original testing env this cluster was created at *tEnv // original testing env this cluster was created at
...@@ -62,8 +63,8 @@ type tCluster struct { ...@@ -62,8 +63,8 @@ type tCluster struct {
network *virtnet.SubNetwork // nodes interoperate via network network *virtnet.SubNetwork // nodes interoperate via network
traceOn bool // whether tracing is currently on or off traceOn bool // whether tracing is currently on or off
gotracer *TraceCollector // for tracing go nodes XXX -> GoTracer gotracer *GoTracer // for tracing go nodes
//tpy *PyTracer // for tracing py nodes //tpy *PyTracer // for tracing py nodes TODO
erouter *EventRouter // to which stream an event should go erouter *EventRouter // to which stream an event should go
tabMu sync.Mutex tabMu sync.Mutex
......
...@@ -29,12 +29,8 @@ import ( ...@@ -29,12 +29,8 @@ import (
"lab.nexedi.com/kirr/neo/go/neo/xneo" "lab.nexedi.com/kirr/neo/go/neo/xneo"
) )
// GoTraceCollector collects events from NEO/go trace points and sends them to event dispatcher. // GoTracer collects events from NEO/go trace points and sends them to event dispatcher.
// type GoTracer struct {
// 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 {
pg *tracing.ProbeGroup pg *tracing.ProbeGroup
rx interface { RxEvent(interface{}) } rx interface { RxEvent(interface{}) }
...@@ -43,8 +39,8 @@ type TraceCollector struct { ...@@ -43,8 +39,8 @@ type TraceCollector struct {
clusterState2Owner map[*proto.ClusterState]string clusterState2Owner map[*proto.ClusterState]string
} }
func NewTraceCollector(rx interface { RxEvent(interface{}) }) *TraceCollector { func NewTraceCollector(rx interface { RxEvent(interface{}) }) *GoTracer {
return &TraceCollector{ return &GoTracer{
pg: &tracing.ProbeGroup{}, pg: &tracing.ProbeGroup{},
rx: rx, rx: rx,
...@@ -59,7 +55,7 @@ func NewTraceCollector(rx interface { RxEvent(interface{}) }) *TraceCollector { ...@@ -59,7 +55,7 @@ func NewTraceCollector(rx interface { RxEvent(interface{}) }) *TraceCollector {
//trace:import "lab.nexedi.com/kirr/neo/go/neo/xneo" //trace:import "lab.nexedi.com/kirr/neo/go/neo/xneo"
// Attach attaches the tracer to appropriate trace points. // Attach attaches the tracer to appropriate trace points.
func (t *TraceCollector) Attach() { func (t *GoTracer) Attach() {
tracing.Lock() tracing.Lock()
//neo_traceMsgRecv_Attach(t.pg, t.traceNeoMsgRecv) //neo_traceMsgRecv_Attach(t.pg, t.traceNeoMsgRecv)
neonet_traceMsgSendPre_Attach(t.pg, t.traceNeoMsgSendPre) neonet_traceMsgSendPre_Attach(t.pg, t.traceNeoMsgSendPre)
...@@ -69,7 +65,7 @@ func (t *TraceCollector) Attach() { ...@@ -69,7 +65,7 @@ func (t *TraceCollector) Attach() {
tracing.Unlock() tracing.Unlock()
} }
func (t *TraceCollector) Detach() { func (t *GoTracer) Detach() {
t.pg.Done() t.pg.Done()
} }
...@@ -77,7 +73,7 @@ func (t *TraceCollector) Detach() { ...@@ -77,7 +73,7 @@ func (t *TraceCollector) Detach() {
// //
// This way it can translate e.g. *NodeTable -> owner node name when creating // This way it can translate e.g. *NodeTable -> owner node name when creating
// corresponding event. // corresponding event.
func (t *TraceCollector) RegisterNode(node *xneo.Node, name string) { func (t *GoTracer) RegisterNode(node *xneo.Node, name string) {
tracing.Lock() tracing.Lock()
defer tracing.Unlock() defer tracing.Unlock()
...@@ -88,14 +84,14 @@ func (t *TraceCollector) RegisterNode(node *xneo.Node, name string) { ...@@ -88,14 +84,14 @@ func (t *TraceCollector) RegisterNode(node *xneo.Node, name string) {
t.clusterState2Owner[&node.State.Code] = name t.clusterState2Owner[&node.State.Code] = name
} }
func (t *TraceCollector) TraceNetDial(ev *xnet.TraceDial) { func (t *GoTracer) TraceNetDial(ev *xnet.TraceDial) {
t.rx.RxEvent(&eventNetDial{ t.rx.RxEvent(&eventNetDial{
Dialer: ev.Dialer, Dialer: ev.Dialer,
Addr: ev.Addr, Addr: ev.Addr,
}) })
} }
func (t *TraceCollector) TraceNetConnect(ev *xnet.TraceConnect) { func (t *GoTracer) TraceNetConnect(ev *xnet.TraceConnect) {
t.rx.RxEvent(&eventNetConnect{ t.rx.RxEvent(&eventNetConnect{
Src: ev.Src.String(), Src: ev.Src.String(),
Dst: ev.Dst.String(), Dst: ev.Dst.String(),
...@@ -103,27 +99,27 @@ func (t *TraceCollector) TraceNetConnect(ev *xnet.TraceConnect) { ...@@ -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()}) 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}) 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] where := t.clusterState2Owner[cs]
t.rx.RxEvent(&eventClusterState{where, *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] where := t.nodeTab2Owner[nt]
t.rx.RxEvent(&eventNodeTab{where, n.NodeInfo}) 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] where := t.node2Name[m.node]
t.rx.RxEvent(&eventMStartReady{where, ready}) 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