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 (
...
@@ -61,10 +61,11 @@ import (
//
//
// XXX update after introduction of _MasterLink
// XXX update after introduction of _MasterLink
type
_MasteredNode
struct
{
type
_MasteredNode
struct
{
myInfo
proto
.
NodeInfo
// type, laddr, nid, state, idtime
node
*
xneo
.
Node
ClusterName
string
// myInfo proto.NodeInfo // type, laddr, nid, state, idtime
Net
xnet
.
Networker
// network AP we are sending/receiving on
// ClusterName string
MasterAddr
string
// address of current master TODO -> masterRegistry
// Net xnet.Networker // network AP we are sending/receiving on
// MasterAddr string // address of current master TODO -> masterRegistry
// operational state is maintained by TalkMaster.
// operational state is maintained by TalkMaster.
// users retrieve it via WithOperational().
// users retrieve it via WithOperational().
...
@@ -74,7 +75,7 @@ type _MasteredNode struct {
...
@@ -74,7 +75,7 @@ type _MasteredNode struct {
// - state of partTab/nodeTab is operational
// - state of partTab/nodeTab is operational
opMu
sync
.
RWMutex
opMu
sync
.
RWMutex
mlink
*
neonet
.
NodeLink
// link to master
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
opReady
chan
struct
{}
// reinitialized each time state becomes non-operational
operational
bool
// cache for state.IsOperational()
operational
bool
// cache for state.IsOperational()
...
@@ -113,6 +114,8 @@ const (
...
@@ -113,6 +114,8 @@ const (
// XXX doc
// XXX doc
func
newMasteredNode
(
typ
proto
.
NodeType
,
clusterName
string
,
net
xnet
.
Networker
,
masterAddr
string
)
*
_MasteredNode
{
func
newMasteredNode
(
typ
proto
.
NodeType
,
clusterName
string
,
net
xnet
.
Networker
,
masterAddr
string
)
*
_MasteredNode
{
node
:=
&
_MasteredNode
{
node
:=
&
_MasteredNode
{
node
:
xneo
.
NewNode
(
typ
,
clusterName
,
net
,
masterAddr
),
/*
myInfo: proto.NodeInfo{
myInfo: proto.NodeInfo{
Type: typ,
Type: typ,
Addr: proto.Address{},
Addr: proto.Address{},
...
@@ -129,7 +132,7 @@ func newMasteredNode(typ proto.NodeType, clusterName string, net xnet.Networker,
...
@@ -129,7 +132,7 @@ func newMasteredNode(typ proto.NodeType, clusterName string, net xnet.Networker,
PartTab: &xneo.PartitionTable{},
PartTab: &xneo.PartitionTable{},
Code: -1, // invalid
Code: -1, // invalid
},
},
*/
opReady
:
make
(
chan
struct
{}),
opReady
:
make
(
chan
struct
{}),
}
}
...
...
go/neo/xneo/xneo.go
View file @
0af56694
...
@@ -49,34 +49,42 @@ func (cs *ClusterState) IsOperational() bool {
...
@@ -49,34 +49,42 @@ func (cs *ClusterState) IsOperational() bool {
// - current partition table (how data is split around storage nodes),
// - current partition table (how data is split around storage nodes),
// - current cluster state.
// - current cluster state.
type
Node
struct
{
type
Node
struct
{
MyInfo
proto
.
NodeInfo
MyInfo
proto
.
NodeInfo
// type, laddr, nid, state, idtime
ClusterName
string
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
StateMu
sync
.
RWMutex
// <- XXX unexport
MasterAddr
string
// address of current master XXX put under StateMu ?
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?
// // should be set by user so Node can notify when master tells this node to shutdown
NodeTab
*
NodeTable
// information about nodes in the cluster
// OnShutdown func()
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
()
}
}
// NewNode creates new node.
// 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
{
node
:=
&
Node
{
MyInfo
:
proto
.
NodeInfo
{
Type
:
typ
,
Addr
:
proto
.
Address
{},
NID
:
0
,
IdTime
:
proto
.
IdTimeNone
},
MyInfo
:
proto
.
NodeInfo
{
ClusterName
:
clusterName
,
Type
:
typ
,
Net
:
net
,
Addr
:
proto
.
Address
{},
MasterAddr
:
masterAddr
,
NID
:
0
,
IdTime
:
proto
.
IdTimeNone
,
},
ClusterName
:
clusterName
,
Net
:
net
,
MasterAddr
:
masterAddr
,
NodeTab
:
&
NodeTable
{},
state
:
ClusterState
{
PartTab
:
&
PartitionTable
{},
NodeTab
:
&
NodeTable
{},
ClusterState
:
-
1
,
// invalid
PartTab
:
&
PartitionTable
{},
Code
:
-
1
,
// invalid
},
}
}
node
.
NodeTab
.
localNode
=
node
node
.
state
.
NodeTab
.
localNode
=
node
return
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