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
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
neoppod
Commits
c6dda6c2
Commit
c6dda6c2
authored
Jun 07, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
6312399d
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
23 additions
and
49 deletions
+23
-49
go/neo/connection.go
go/neo/connection.go
+0
-24
go/neo/master.go
go/neo/master.go
+10
-5
go/neo/net.go
go/neo/net.go
+1
-0
go/neo/nodetab.go
go/neo/nodetab.go
+3
-3
go/neo/parttab.go
go/neo/parttab.go
+2
-2
go/neo/proto-str.go
go/neo/proto-str.go
+1
-1
go/neo/server.go
go/neo/server.go
+5
-14
go/neo/storage.go
go/neo/storage.go
+1
-0
No files found.
go/neo/connection.go
View file @
c6dda6c2
...
...
@@ -728,27 +728,3 @@ func (c *Conn) err(op string, e error) error {
}
return
&
ConnError
{
Conn
:
c
,
Op
:
op
,
Err
:
e
}
}
// ----------------------------------------
// XXX ^^^ original description about notify/ask/answer
// All packets are classified to be of one of the following kind:
// - notify: a packet is sent without expecting any reply
// - ask: a packet is sent and reply is expected
// - answer: a packet replying to previous ask
//
// At any time there can be several Asks packets issued by both nodes.
// For an Ask packet a single Answer reply is expected XXX vs protocol where there is one request and list of replies ?
//
// XXX -> multiple subconnection explicitly closed with ability to chat
// multiple packets without spawning goroutines? And only single answer
// expected implemented that after only ask-send / answer-receive the
// (sub-)connection is explicitly closed ?
//
// XXX it is maybe better to try to avoid multiplexing by hand and let the OS do it?
//
// A reply to particular Ask packet, once received, will be delivered to
// corresponding goroutine which originally issued Ask XXX this can be put into interface
go/neo/master.go
View file @
c6dda6c2
...
...
@@ -31,6 +31,8 @@ import (
"sync"
"../zodb"
"lab.nexedi.com/kirr/go123/xerr"
)
// Master is a node overseeing and managing how whole NEO cluster works
...
...
@@ -175,7 +177,7 @@ func (m *Master) run(ctx context.Context) {
// - !nil: recovery was cancelled
func
(
m
*
Master
)
recovery
(
ctx
context
.
Context
)
(
err
error
)
{
fmt
.
Println
(
"master: recovery"
)
defer
errcontextf
(
&
err
,
"master: recovery"
)
defer
xerr
.
Context
(
&
err
,
"master: recovery"
)
m
.
setClusterState
(
ClusterRecovering
)
rctx
,
rcancel
:=
context
.
WithCancel
(
ctx
)
...
...
@@ -299,7 +301,7 @@ func storCtlRecovery(ctx context.Context, link *NodeLink, res chan storRecovery)
link.Close()
*/
}()
defer
errc
ontextf
(
&
err
,
"%s: stor recovery"
,
link
)
defer
xerr
.
C
ontextf
(
&
err
,
"%s: stor recovery"
,
link
)
conn
,
err
:=
link
.
NewConn
()
// FIXME bad
if
err
!=
nil
{
...
...
@@ -362,7 +364,7 @@ var errClusterDegraded = errors.New("cluster became non-operatonal")
// prerequisite for start: .partTab is operational wrt .nodeTab
func
(
m
*
Master
)
verify
(
ctx
context
.
Context
)
(
err
error
)
{
fmt
.
Println
(
"master: verify"
)
defer
errcontextf
(
&
err
,
"master: verify"
)
defer
xerr
.
Context
(
&
err
,
"master: verify"
)
m
.
setClusterState
(
ClusterVerifying
)
vctx
,
vcancel
:=
context
.
WithCancel
(
ctx
)
...
...
@@ -481,7 +483,7 @@ func storCtlVerify(ctx context.Context, link *NodeLink, res chan storVerify) {
res
<-
storVerify
{
link
:
link
,
err
:
err
}
}
}()
defer
errc
ontextf
(
&
err
,
"%s: verify"
,
link
)
defer
xerr
.
C
ontextf
(
&
err
,
"%s: verify"
,
link
)
// FIXME stub
conn
,
_
:=
link
.
NewConn
()
...
...
@@ -525,7 +527,7 @@ func storCtlVerify(ctx context.Context, link *NodeLink, res chan storVerify) {
// prerequisite for start: .partTab is operational wrt .nodeTab and verification passed
func
(
m
*
Master
)
service
(
ctx
context
.
Context
)
(
err
error
)
{
fmt
.
Println
(
"master: service"
)
defer
errcontextf
(
&
err
,
"master: service"
)
defer
xerr
.
Context
(
&
err
,
"master: service"
)
m
.
setClusterState
(
ClusterRunning
)
...
...
@@ -804,6 +806,8 @@ func (m *Master) ServeClient(ctx context.Context, link *NodeLink) {
// ---- internal requests for storage driver ----
// XXX goes away
/*
// storageRecovery asks storage driver to extract cluster recovery information from storage
type storageRecovery struct {
resp chan PartitionTable // XXX +err ?
...
...
@@ -823,6 +827,7 @@ type storageStartOperation struct {
type storageStopOperation struct {
resp chan error
}
*/
// DriveStorage serves incoming connection on which peer identified itself as storage
//
...
...
go/neo/net.go
View file @
c6dda6c2
...
...
@@ -96,6 +96,7 @@ func (n *netTLS) Listen(laddr string) (net.Listener, error) {
return
tls
.
NewListener
(
l
,
n
.
config
),
nil
}
// ----------------------------------------
// String formats Address to canonical host:port form
func
(
addr
Address
)
String
()
string
{
...
...
go/neo/nodetab.go
View file @
c6dda6c2
...
...
@@ -206,11 +206,11 @@ func (nt *NodeTable) Subscribe() (ch chan NodeInfo, unsubscribe func()) {
return
ch
,
unsubscribe
}
// SubscribeBuffer
r
ed subscribes to NodeTable updates without blocking updater
// SubscribeBuffered subscribes to NodeTable updates without blocking updater
// it returns a channel via which updates are delivered and unsubscribe function
// the updates will be sent to destination in non-blocking way - if destination
// channel is not ready they will be buffer
r
ed.
// it is the caller reponsibility to make sure such buffering does not grow up
// channel is not ready they will be buffered.
// it is the caller re
s
ponsibility to make sure such buffering does not grow up
// to infinity - via e.g. detecting stuck connections and unsubscribing on shutdown
//
// XXX locking: client for subscribe/unsubscribe XXX ok?
...
...
go/neo/parttab.go
View file @
c6dda6c2
...
...
@@ -96,7 +96,7 @@ package neo
// S2 S2
// S3 → S2
//
// Np thus is always multiple of Ns and with furter reorderings (if needed)
// Np thus is always multiple of Ns and with furt
h
er reorderings (if needed)
// could be reduced directly to Ns.
//
// Usually Master maintains partition table, plans partition updates and tells
...
...
@@ -149,7 +149,7 @@ func (pt *PartitionTable) OperationalWith(nt *NodeTable) bool {
cellLoop
:
for
_
,
cell
:=
range
ptEntry
{
switch
cell
.
CellState
{
case
UP_TO_DATE
,
FEEDING
:
// XXX cell.isReadble in py
case
UP_TO_DATE
,
FEEDING
:
// XXX cell.isRead
a
ble in py
// cell says it is readable. let's check whether corresponding node is up
// FIXME checking whether it is up is not really enough -
// - what is needed to check is that data on that node is up
...
...
go/neo/proto-str.go
View file @
c6dda6c2
...
...
@@ -18,7 +18,7 @@ func (e *Error) Error() string {
}
const
nodeTypeChar
=
"MSCA4567"
const
nodeTypeChar
=
"MSCA4567"
// keep in sync with NodeType constants
func
(
nodeUUID
NodeUUID
)
String
()
string
{
// return ex 'S1', 'M2', ...
...
...
go/neo/server.go
View file @
c6dda6c2
...
...
@@ -23,6 +23,8 @@ import (
"fmt"
"net"
"reflect"
"lab.nexedi.com/kirr/go123/xerr"
)
// Server is an interface that represents networked server
...
...
@@ -76,6 +78,7 @@ func Serve(ctx context.Context, l net.Listener, srv Server) error {
}
// ListenAndServe listens on network address and then calls Serve to handle incoming connections
// XXX unused -> goes away ?
func
ListenAndServe
(
ctx
context
.
Context
,
net
Network
,
laddr
string
,
srv
Server
)
error
{
l
,
err
:=
net
.
Listen
(
laddr
)
if
err
!=
nil
{
...
...
@@ -88,23 +91,11 @@ func ListenAndServe(ctx context.Context, net Network, laddr string, srv Server)
// ----------------------------------------
// errcontextf adds formatted prefix context to *errp
// must be called under defer
func
errcontextf
(
errp
*
error
,
format
string
,
argv
...
interface
{})
{
if
*
errp
==
nil
{
return
}
format
+=
": %s"
argv
=
append
(
argv
,
*
errp
)
*
errp
=
fmt
.
Errorf
(
format
,
argv
...
)
}
// IdentifyPeer identifies peer on the link
// it expects peer to send RequestIdentification packet and replies with AcceptIdentification if identification passes.
// returns information about identified node or error.
func
IdentifyPeer
(
link
*
NodeLink
,
myNodeType
NodeType
)
(
nodeInfo
RequestIdentification
/*TODO -> NodeInfo*/
,
err
error
)
{
defer
errc
ontextf
(
&
err
,
"%s: identify"
,
link
)
defer
xerr
.
C
ontextf
(
&
err
,
"%s: identify"
,
link
)
// the first conn must come with RequestIdentification packet
conn
,
err
:=
link
.
Accept
()
...
...
@@ -147,7 +138,7 @@ func IdentifyPeer(link *NodeLink, myNodeType NodeType) (nodeInfo RequestIdentifi
// IdentifyWith identifies local node with remote peer
// it also verifies peer's node type to what caller expects
func
IdentifyWith
(
expectPeerType
NodeType
,
link
*
NodeLink
,
myInfo
NodeInfo
,
clusterName
string
)
(
accept
*
AcceptIdentification
,
err
error
)
{
defer
errc
ontextf
(
&
err
,
"%s: request identification"
,
link
)
defer
xerr
.
C
ontextf
(
&
err
,
"%s: request identification"
,
link
)
conn
,
err
:=
link
.
NewConn
()
if
err
!=
nil
{
...
...
go/neo/storage.go
View file @
c6dda6c2
...
...
@@ -196,6 +196,7 @@ func (stor *Storage) ServeLink(ctx context.Context, link *NodeLink) {
link
.
Close
()
// XXX err
}()
// XXX recheck identification logic here
nodeInfo
,
err
:=
IdentifyPeer
(
link
,
STORAGE
)
if
err
!=
nil
{
fmt
.
Printf
(
"stor: %v
\n
"
,
err
)
...
...
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