Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Kirill Smelkov
neo
Commits
4c91dc61
Commit
4c91dc61
authored
Jul 17, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
57a86cd5
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
45 additions
and
12 deletions
+45
-12
go/neo/connection.go
go/neo/connection.go
+25
-2
go/neo/server/cluster_test.go
go/neo/server/cluster_test.go
+12
-6
go/neo/server/ztrace_test.go
go/neo/server/ztrace_test.go
+3
-3
go/xcommon/xtesting/xtesting.go
go/xcommon/xtesting/xtesting.go
+5
-1
No files found.
go/neo/connection.go
View file @
4c91dc61
...
...
@@ -203,7 +203,7 @@ func (nl *NodeLink) NewConn() (*Conn, error) {
return
c
,
nil
}
// shutdown closes
peerLink and marks NodeLink as no longer operational
// shutdown closes
raw link to peer and marks NodeLink as no longer operational.
// it also shutdowns all opened connections over this node link.
func
(
nl
*
NodeLink
)
shutdown
()
{
nl
.
downOnce
.
Do
(
func
()
{
...
...
@@ -699,9 +699,32 @@ func Dial(ctx context.Context, net xnet.Networker, addr string) (nl *NodeLink, e
// block further Accepts.
// ---- for convenience: Conn -> NodeLink & local/remote link addresses ----
// LocalAddr returns local address of the underlying link to peer.
func
(
nl
*
NodeLink
)
LocalAddr
()
net
.
Addr
{
return
nl
.
peerLink
.
LocalAddr
()
}
// RemoteAddr returns remote address of the underlying link to peer.
func
(
nl
*
NodeLink
)
RemoteAddr
()
net
.
Addr
{
return
nl
.
peerLink
.
RemoteAddr
()
}
// Link returns underlying NodeLink of this connection.
func
(
c
*
Conn
)
Link
()
*
NodeLink
{
return
c
.
nodeLink
}
// ConnID returns connection identifier used for the connection.
func
(
c
*
Conn
)
ConnID
()
uint32
{
return
c
.
connId
}
// ---- for convenience: String / Error ----
func
(
nl
*
NodeLink
)
String
()
string
{
s
:=
fmt
.
Sprintf
(
"%s - %s"
,
nl
.
peerLink
.
LocalAddr
(),
nl
.
peerLink
.
RemoteAddr
())
s
:=
fmt
.
Sprintf
(
"%s - %s"
,
nl
.
LocalAddr
(),
nl
.
RemoteAddr
())
return
s
// XXX add "(closed)" if nl is closed ?
// XXX other flags e.g. (down) ?
}
...
...
go/neo/server/cluster_test.go
View file @
4c91dc61
...
...
@@ -27,6 +27,7 @@ import (
//"bytes"
"context"
//"io"
"net"
//"reflect"
"testing"
...
...
@@ -78,7 +79,9 @@ type traceNeoSend struct {
ConnID
uint32
Msg
neo
.
Msg
}
func
(
t
*
MyTracer
)
traceNeoConnSend
(
c
*
neo
.
Conn
,
msg
neo
.
Msg
)
{
t
.
Trace1
(
&
traceNeoSend
{
c
,
msg
})
}
func
(
t
*
MyTracer
)
traceNeoConnSendPre
(
c
*
neo
.
Conn
,
msg
neo
.
Msg
)
{
t
.
Trace1
(
&
traceNeoSend
{
c
.
Link
()
.
LocalAddr
(),
c
.
Link
()
.
RemoteAddr
(),
c
.
ConnID
(),
msg
})
}
...
...
@@ -169,6 +172,11 @@ func TestMasterStorage(t *testing.T) {
return
&
xnet
.
TraceListen
{
Laddr
:
xaddr
(
laddr
)}
}
// XXX
conntx
:=
func
(
src
,
dst
string
,
connid
uint32
,
msg
neo
.
Msg
)
*
traceNeoSend
{
return
&
traceNeoSend
{
Src
:
xaddr
(
src
),
Dst
:
xaddr
(
dst
),
ConnID
:
connid
,
Msg
:
msg
}
}
Mhost
:=
xnet
.
NetTrace
(
net
.
Host
(
"m"
),
tracer
)
Shost
:=
xnet
.
NetTrace
(
net
.
Host
(
"s"
),
tracer
)
...
...
@@ -209,11 +217,9 @@ func TestMasterStorage(t *testing.T) {
//)
_
=
nettx
tc
.
Expect
(
conntx
(
"s:1"
,
"m:1"
,
1
,
RequestIdentification
{
...
})
// ... M adjust nodetab...
conntx
(
"m:1"
,
"s:1"
,
1
,
AcceptIdentification
{
...
})
)
tc
.
Expect
(
conntx
(
"s:1"
,
"m:1"
,
1
,
&
neo
.
RequestIdentification
{}))
// XXX
// XXX ... M adjust nodetab...
tc
.
Expect
(
conntx
(
"m:1"
,
"s:1"
,
1
,
&
neo
.
AcceptIdentification
{}))
// XXX
...
...
go/neo/server/ztrace_test.go
View file @
4c91dc61
...
...
@@ -13,7 +13,7 @@ import (
// traceimport: "lab.nexedi.com/kirr/neo/go/neo"
// rerun "gotrace gen" if you see link failure ↓↓↓
//go:linkname neo_trace_exporthash lab.nexedi.com/kirr/neo/go/neo._trace_exporthash_
bc56cd7a9caf82c14d9586243f763e65afb91ea0
//go:linkname neo_trace_exporthash lab.nexedi.com/kirr/neo/go/neo._trace_exporthash_
d2fa0ebb37c3e2bf54309859a1eeb0e831edd435
func
neo_trace_exporthash
()
func
init
()
{
neo_trace_exporthash
()
}
...
...
@@ -21,5 +21,5 @@ func init() { neo_trace_exporthash() }
//go:linkname neo_traceConnRecv_Attach lab.nexedi.com/kirr/neo/go/neo.traceConnRecv_Attach
func
neo_traceConnRecv_Attach
(
*
tracing
.
ProbeGroup
,
func
(
c
*
neo
.
Conn
,
msg
neo
.
Msg
))
*
tracing
.
Probe
//go:linkname neo_traceConnSend
_Attach lab.nexedi.com/kirr/neo/go/neo.traceConnSend
_Attach
func
neo_traceConnSend_Attach
(
*
tracing
.
ProbeGroup
,
func
(
c
*
neo
.
Conn
,
msg
neo
.
Msg
))
*
tracing
.
Probe
//go:linkname neo_traceConnSend
Pre_Attach lab.nexedi.com/kirr/neo/go/neo.traceConnSendPre
_Attach
func
neo_traceConnSend
Pre
_Attach
(
*
tracing
.
ProbeGroup
,
func
(
c
*
neo
.
Conn
,
msg
neo
.
Msg
))
*
tracing
.
Probe
go/xcommon/xtesting/xtesting.go
View file @
4c91dc61
...
...
@@ -25,6 +25,8 @@ import (
"reflect"
"strings"
"testing"
"github.com/kylelemons/godebug/pretty"
)
// XXX move -> tracing
...
...
@@ -114,7 +116,9 @@ func (tc *TraceChecker) expect1(eventExpect interface{}) {
revent
:=
reventp
.
Elem
()
if
!
reflect
.
DeepEqual
(
revent
.
Interface
(),
reventExpect
.
Interface
())
{
tc
.
t
.
Fatalf
(
"expect: %s:
\n
have: %v
\n
want: %v"
,
reventExpect
.
Type
(),
revent
,
reventExpect
)
tc
.
t
.
Fatalf
(
"expect: %s:
\n
want: %v
\n
have: %v
\n
diff: %s"
,
reventExpect
.
Type
(),
reventExpect
,
revent
,
pretty
.
Compare
(
reventExpect
.
Interface
(),
revent
.
Interface
()))
}
close
(
msg
.
Ack
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment