Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neoppod
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Levin Zimmermann
neoppod
Commits
17a95c4f
Commit
17a95c4f
authored
Aug 31, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
4e33b5f7
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
31 deletions
+46
-31
go/neo/client/client.go
go/neo/client/client.go
+7
-2
go/neo/proto-misc.go
go/neo/proto-misc.go
+1
-1
go/neo/server/cluster_test.go
go/neo/server/cluster_test.go
+26
-27
go/neo/zproto-str.go
go/neo/zproto-str.go
+12
-1
No files found.
go/neo/client/client.go
View file @
17a95c4f
...
...
@@ -82,8 +82,9 @@ func NewClient(clusterName, masterAddr string, net xnet.Networker) *Client {
Net
:
net
,
MasterAddr
:
masterAddr
,
//NodeTab: &neo.NodeTable{},
//PartTab: &neo.PartitionTable{},
NodeTab
:
&
neo
.
NodeTable
{},
PartTab
:
&
neo
.
PartitionTable
{},
ClusterState
:
-
1
,
// invalid
},
mlinkReady
:
make
(
chan
struct
{}),
...
...
@@ -270,9 +271,13 @@ func (c *Client) recvMaster(ctx context.Context, mlink *neo.NodeLink) error {
case
*
neo
.
NotifyNodeInformation
:
// XXX msg.IdTimestamp ?
for
_
,
nodeInfo
:=
range
msg
.
NodeList
{
log
.
Infof
(
ctx
,
"rx peer update: %v"
,
nodeInfo
)
c
.
node
.
NodeTab
.
Update
(
nodeInfo
,
/*XXX conn should not be here*/
nil
)
}
// FIXME logging under lock
log
.
Infof
(
ctx
,
"full nodetab:
\n
%s"
,
c
.
node
.
NodeTab
)
case
*
neo
.
NotifyClusterState
:
c
.
node
.
ClusterState
.
Set
(
msg
.
State
)
}
...
...
go/neo/proto-misc.go
View file @
17a95c4f
//go:generate stringer -output zproto-str.go -type ErrorCode,NodeType proto.go
//go:generate stringer -output zproto-str.go -type ErrorCode,NodeType
,NodeState
proto.go
package
neo
// supporting code for types defined in proto.go
...
...
go/neo/server/cluster_test.go
View file @
17a95c4f
...
...
@@ -199,31 +199,25 @@ func TestMasterStorage(t *testing.T) {
return
&
traceNeoSend
{
Src
:
xaddr
(
src
),
Dst
:
xaddr
(
dst
),
ConnID
:
connid
,
Msg
:
msg
}
}
// shortcut for nodetab change
node
:=
func
(
x
*
neo
.
NodeCommon
,
laddr
string
,
typ
neo
.
NodeType
,
num
int32
,
state
neo
.
NodeState
,
idtstamp
float64
)
*
traceNode
{
return
&
traceNode
{
NodeTab
:
unsafe
.
Pointer
(
x
.
NodeTab
),
NodeInfo
:
neo
.
NodeInfo
{
Type
:
typ
,
Addr
:
xnaddr
(
laddr
),
UUID
:
neo
.
UUID
(
typ
,
num
),
State
:
state
,
IdTimestamp
:
idtstamp
,
},
}
}
// shortcut for NodeInfo
nodei
:=
func
(
typ
neo
.
NodeType
,
addr
string
,
uuid
neo
.
NodeUUID
,
state
neo
.
NodeState
,
idtstamp
float64
)
neo
.
NodeInfo
{
nodei
:=
func
(
laddr
string
,
typ
neo
.
NodeType
,
num
int32
,
state
neo
.
NodeState
,
idtstamp
float64
)
neo
.
NodeInfo
{
return
neo
.
NodeInfo
{
Type
:
typ
,
Addr
:
xnaddr
(
addr
),
UUID
:
uuid
,
Addr
:
xnaddr
(
l
addr
),
UUID
:
neo
.
UUID
(
typ
,
num
)
,
State
:
state
,
IdTimestamp
:
idtstamp
,
}
}
// shortcut for nodetab change
node
:=
func
(
x
*
neo
.
NodeCommon
,
laddr
string
,
typ
neo
.
NodeType
,
num
int32
,
state
neo
.
NodeState
,
idtstamp
float64
)
*
traceNode
{
return
&
traceNode
{
NodeTab
:
unsafe
.
Pointer
(
x
.
NodeTab
),
NodeInfo
:
nodei
(
laddr
,
typ
,
num
,
state
,
idtstamp
),
}
}
Mhost
:=
xnet
.
NetTrace
(
net
.
Host
(
"m"
),
tracer
)
Shost
:=
xnet
.
NetTrace
(
net
.
Host
(
"s"
),
tracer
)
...
...
@@ -380,16 +374,6 @@ func TestMasterStorage(t *testing.T) {
YourUUID
:
neo
.
UUID
(
neo
.
CLIENT
,
1
),
}))
// C <- M NotifyNodeInformation C1,M1,S1
tc
.
Expect
(
conntx
(
"m:3"
,
"c:1"
,
2
,
&
neo
.
NotifyNodeInformation
{
IdTimestamp
:
0
,
// XXX ?
NodeList
:
[]
neo
.
NodeInfo
{
nodei
(
neo
.
MASTER
,
"m:1"
,
neo
.
UUID
(
neo
.
MASTER
,
1
),
neo
.
RUNNING
,
0.00
),
nodei
(
neo
.
STORAGE
,
"s:1"
,
neo
.
UUID
(
neo
.
STORAGE
,
1
),
neo
.
RUNNING
,
0.01
),
nodei
(
neo
.
STORAGE
,
""
,
neo
.
UUID
(
neo
.
CLIENT
,
1
),
neo
.
RUNNING
,
0.02
),
},
}))
// C asks M about PT
tc
.
Expect
(
conntx
(
"c:1"
,
"m:3"
,
3
,
&
neo
.
AskPartitionTable
{}))
tc
.
Expect
(
conntx
(
"m:3"
,
"c:1"
,
3
,
&
neo
.
AnswerPartitionTable
{
...
...
@@ -399,6 +383,21 @@ func TestMasterStorage(t *testing.T) {
},
}))
// C <- M NotifyNodeInformation C1,M1,S1
tc
.
Expect
(
conntx
(
"m:3"
,
"c:1"
,
0
,
&
neo
.
NotifyNodeInformation
{
IdTimestamp
:
0
,
// XXX ?
NodeList
:
[]
neo
.
NodeInfo
{
nodei
(
"m:1"
,
neo
.
MASTER
,
1
,
neo
.
RUNNING
,
0.00
),
nodei
(
"s:1"
,
neo
.
STORAGE
,
1
,
neo
.
RUNNING
,
0.01
),
nodei
(
""
,
neo
.
CLIENT
,
1
,
neo
.
RUNNING
,
0.02
),
},
}))
Cnode
:=
(
*
neo
.
NodeCommon
)(
unsafe
.
Pointer
(
C
))
// XXX hack
tc
.
Expect
(
node
(
Cnode
,
"m:1"
,
neo
.
MASTER
,
1
,
neo
.
RUNNING
,
0.00
))
tc
.
Expect
(
node
(
Cnode
,
"s:1"
,
neo
.
STORAGE
,
1
,
neo
.
RUNNING
,
0.01
))
tc
.
Expect
(
node
(
Cnode
,
""
,
neo
.
CLIENT
,
1
,
neo
.
RUNNING
,
0.02
))
// C asks M about last tid XXX better master sends it itself on new client connected
wg
=
&
xsync
.
WorkGroup
{}
...
...
go/neo/zproto-str.go
View file @
17a95c4f
// Code generated by "stringer -output zproto-str.go -type ErrorCode,NodeType proto.go"; DO NOT EDIT.
// Code generated by "stringer -output zproto-str.go -type ErrorCode,NodeType
,NodeState
proto.go"; DO NOT EDIT.
package
neo
...
...
@@ -25,3 +25,14 @@ func (i NodeType) String() string {
}
return
_NodeType_name
[
_NodeType_index
[
i
]
:
_NodeType_index
[
i
+
1
]]
}
const
_NodeState_name
=
"UNKNOWNDOWNRUNNINGPENDING"
var
_NodeState_index
=
[
...
]
uint8
{
0
,
7
,
11
,
18
,
25
}
func
(
i
NodeState
)
String
()
string
{
if
i
<
0
||
i
>=
NodeState
(
len
(
_NodeState_index
)
-
1
)
{
return
fmt
.
Sprintf
(
"NodeState(%d)"
,
i
)
}
return
_NodeState_name
[
_NodeState_index
[
i
]
:
_NodeState_index
[
i
+
1
]]
}
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