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
0af56694
Commit
0af56694
authored
Feb 03, 2021
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
f3510fde
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
26 deletions
+37
-26
go/neo/mastered.go
go/neo/mastered.go
+9
-6
go/neo/xneo/xneo.go
go/neo/xneo/xneo.go
+28
-20
No files found.
go/neo/mastered.go
View file @
0af56694
...
...
@@ -61,10 +61,11 @@ import (
//
// XXX update after introduction of _MasterLink
type
_MasteredNode
struct
{
myInfo
proto
.
NodeInfo
// type, laddr, nid, state, idtime
ClusterName
string
Net
xnet
.
Networker
// network AP we are sending/receiving on
MasterAddr
string
// address of current master TODO -> masterRegistry
node
*
xneo
.
Node
// myInfo proto.NodeInfo // type, laddr, nid, state, idtime
// ClusterName string
// Net xnet.Networker // network AP we are sending/receiving on
// MasterAddr string // address of current master TODO -> masterRegistry
// operational state is maintained by TalkMaster.
// users retrieve it via WithOperational().
...
...
@@ -74,7 +75,7 @@ type _MasteredNode struct {
// - state of partTab/nodeTab is operational
opMu
sync
.
RWMutex
mlink
*
neonet
.
NodeLink
// link to master
state
xneo
.
ClusterState
// nodeTab/partTab/clusterState
//
state xneo.ClusterState // nodeTab/partTab/clusterState
opReady
chan
struct
{}
// reinitialized each time state becomes non-operational
operational
bool
// cache for state.IsOperational()
...
...
@@ -113,6 +114,8 @@ const (
// XXX doc
func
newMasteredNode
(
typ
proto
.
NodeType
,
clusterName
string
,
net
xnet
.
Networker
,
masterAddr
string
)
*
_MasteredNode
{
node
:=
&
_MasteredNode
{
node
:
xneo
.
NewNode
(
typ
,
clusterName
,
net
,
masterAddr
),
/*
myInfo: proto.NodeInfo{
Type: typ,
Addr: proto.Address{},
...
...
@@ -129,7 +132,7 @@ func newMasteredNode(typ proto.NodeType, clusterName string, net xnet.Networker,
PartTab: &xneo.PartitionTable{},
Code: -1, // invalid
},
*/
opReady
:
make
(
chan
struct
{}),
}
...
...
go/neo/xneo/xneo.go
View file @
0af56694
...
...
@@ -49,34 +49,42 @@ func (cs *ClusterState) IsOperational() bool {
// - current partition table (how data is split around storage nodes),
// - current cluster state.
type
Node
struct
{
MyInfo
proto
.
NodeInfo
ClusterName
string
MyInfo
proto
.
NodeInfo
// type, laddr, nid, state, idtime
ClusterName
string
Net
xnet
.
Networker
// network AP we are sending/receiving on
MasterAddr
string
// address of current master TODO -> masterRegistry
Net
xnet
.
Networker
// network AP we are sending/receiving on
MasterAddr
string
// address of current master XXX put under StateMu ?
StateMu
sync
.
RWMutex
// <- XXX unexport
state
ClusterState
// nodeTab/partTab/stateCode
// NodeTab *NodeTable // information about nodes in the cluster
// PartTab *PartitionTable // information about data distribution in the cluster
// ClusterState proto.ClusterState // master idea about cluster state
StateMu
sync
.
RWMutex
// <- XXX just embed?
NodeTab
*
NodeTable
// information about nodes in the cluster
PartTab
*
PartitionTable
// information about data distribution in the cluster
ClusterState
proto
.
ClusterState
// master idea about cluster state
// should be set by user so Node can notify when master tells this node to shutdown
OnShutdown
func
()
// // should be set by user so Node can notify when master tells this node to shutdown
// OnShutdown func()
}
// NewNode creates new node.
func
NewNode
(
net
xnet
.
Networker
,
typ
proto
.
NodeType
,
clusterName
,
masterAddr
string
)
*
Node
{
func
NewNode
(
typ
proto
.
NodeType
,
clusterName
string
,
net
xnet
.
Networker
,
masterAddr
string
)
*
Node
{
node
:=
&
Node
{
MyInfo
:
proto
.
NodeInfo
{
Type
:
typ
,
Addr
:
proto
.
Address
{},
NID
:
0
,
IdTime
:
proto
.
IdTimeNone
},
ClusterName
:
clusterName
,
Net
:
net
,
MasterAddr
:
masterAddr
,
MyInfo
:
proto
.
NodeInfo
{
Type
:
typ
,
Addr
:
proto
.
Address
{},
NID
:
0
,
IdTime
:
proto
.
IdTimeNone
,
},
ClusterName
:
clusterName
,
Net
:
net
,
MasterAddr
:
masterAddr
,
NodeTab
:
&
NodeTable
{},
PartTab
:
&
PartitionTable
{},
ClusterState
:
-
1
,
// invalid
state
:
ClusterState
{
NodeTab
:
&
NodeTable
{},
PartTab
:
&
PartitionTable
{},
Code
:
-
1
,
// invalid
},
}
node
.
NodeTab
.
localNode
=
node
node
.
state
.
NodeTab
.
localNode
=
node
return
node
}
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