Commit d04fb093 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent c5775014
...@@ -200,8 +200,18 @@ func (stor *Storage) talkMaster(ctx context.Context) (err error) { ...@@ -200,8 +200,18 @@ func (stor *Storage) talkMaster(ctx context.Context) (err error) {
// it returns error describing why such cycle had to finish. // it returns error describing why such cycle had to finish.
// XXX distinguish between temporary problems and non-temporary ones? // XXX distinguish between temporary problems and non-temporary ones?
func (stor *Storage) talkMaster1(ctx context.Context) (err error) { func (stor *Storage) talkMaster1(ctx context.Context) (err error) {
// FIXME dup in Client.talkMaster1 // FIXME dup in MasteredNode.talkMaster1
mlink, accept, err := stor.node.Dial(ctx, proto.MASTER, stor.node.MasterAddr) node := stor.node
reqID := &proto.RequestIdentification{
NodeType: node.MyInfo.Type,
NID: node.MyInfo.NID,
Address: node.MyInfo.Addr,
ClusterName: node.ClusterName,
IdTime: node.MyInfo.IdTime, // XXX ok?
DevPath: nil, // XXX stub
NewNID: nil, // XXX stub
}
mlink, accept, err := xneo.Dial(ctx, proto.MASTER, node.Net, node.MasterAddr, reqID)
if err != nil { if err != nil {
return err return err
} }
......
...@@ -102,7 +102,15 @@ func (l *listener) Close() error { return l.l.Close() } ...@@ -102,7 +102,15 @@ func (l *listener) Close() error { return l.l.Close() }
func (l *listener) Addr() net.Addr { return l.l.Addr() } func (l *listener) Addr() net.Addr { return l.l.Addr() }
// XXX Dial + request identification + verify peer type // Dial connects to another node in the cluster.
//
// It handshakes, requests identification and checks peer type. If successful returned are:
//
// - established link
// - accept identification reply
//
// Dial does not update .NodeTab or its node entries in any way.
// For establishing links to peers present in .NodeTab use Node.Dial.
func Dial(ctx context.Context, typ proto.NodeType, net xnet.Networker, addr string, reqID *proto.RequestIdentification) (_ *neonet.NodeLink, _ *proto.AcceptIdentification, err error) { func Dial(ctx context.Context, typ proto.NodeType, net xnet.Networker, addr string, reqID *proto.RequestIdentification) (_ *neonet.NodeLink, _ *proto.AcceptIdentification, err error) {
defer task.Runningf(&ctx, "dial %s (%s)", addr, typ)(&err) defer task.Runningf(&ctx, "dial %s (%s)", addr, typ)(&err)
......
...@@ -327,7 +327,16 @@ func (p *PeerNode) dial(ctx context.Context) (_ *neonet.NodeLink, err error) { ...@@ -327,7 +327,16 @@ func (p *PeerNode) dial(ctx context.Context) (_ *neonet.NodeLink, err error) {
defer task.Runningf(&ctx, "connect %s", p.NID)(&err) // XXX "connect" good word here? defer task.Runningf(&ctx, "connect %s", p.NID)(&err) // XXX "connect" good word here?
node := p.nodeTab.localNode node := p.nodeTab.localNode
link, accept, err := node.Dial(ctx, p.Type, p.Addr.String()) reqID := &proto.RequestIdentification{
NodeType: node.MyInfo.Type,
NID: node.MyInfo.NID,
Address: node.MyInfo.Addr,
ClusterName: node.ClusterName,
IdTime: node.MyInfo.IdTime, // XXX ok?
DevPath: nil, // XXX stub
NewNID: nil, // XXX stub
}
link, accept, err := Dial(ctx, p.Type, node.Net, p.Addr.String(), reqID)
if err != nil { if err != nil {
return nil, err return nil, err
} }
......
...@@ -24,17 +24,17 @@ package xneo ...@@ -24,17 +24,17 @@ package xneo
import ( import (
"context" "context"
"fmt" // "fmt"
"sync" "sync"
"lab.nexedi.com/kirr/go123/xerr" // "lab.nexedi.com/kirr/go123/xerr"
"lab.nexedi.com/kirr/go123/xnet" "lab.nexedi.com/kirr/go123/xnet"
"lab.nexedi.com/kirr/neo/go/internal/log" "lab.nexedi.com/kirr/neo/go/internal/log"
"lab.nexedi.com/kirr/neo/go/internal/task" // "lab.nexedi.com/kirr/neo/go/internal/task"
"lab.nexedi.com/kirr/neo/go/internal/xio" // "lab.nexedi.com/kirr/neo/go/internal/xio"
"lab.nexedi.com/kirr/neo/go/neo/neonet" // "lab.nexedi.com/kirr/neo/go/neo/neonet"
"lab.nexedi.com/kirr/neo/go/neo/proto" "lab.nexedi.com/kirr/neo/go/neo/proto"
) )
...@@ -90,6 +90,7 @@ func NewNode(net xnet.Networker, typ proto.NodeType, clusterName, masterAddr str ...@@ -90,6 +90,7 @@ func NewNode(net xnet.Networker, typ proto.NodeType, clusterName, masterAddr str
return node return node
} }
// XXX kill -> xneo.Dial
// Dial connects to another node in the cluster. // Dial connects to another node in the cluster.
// //
// It handshakes, requests identification and checks peer type. If successful returned are: // It handshakes, requests identification and checks peer type. If successful returned are:
...@@ -104,7 +105,8 @@ func NewNode(net xnet.Networker, typ proto.NodeType, clusterName, masterAddr str ...@@ -104,7 +105,8 @@ func NewNode(net xnet.Networker, typ proto.NodeType, clusterName, masterAddr str
// <- dialing to other nodes always go through node.Dial // <- dialing to other nodes always go through node.Dial
// //
// XXX <- use dialNode instead // XXX <- use dialNode instead
func (node *Node) Dial(ctx context.Context, peerType proto.NodeType, addr string) (_ *neonet.NodeLink, _ *proto.AcceptIdentification, err error) { /*
func (node *Node) __Dial(ctx context.Context, peerType proto.NodeType, addr string) (_ *neonet.NodeLink, _ *proto.AcceptIdentification, err error) {
defer task.Runningf(&ctx, "dial %v (%v)", addr, peerType)(&err) defer task.Runningf(&ctx, "dial %v (%v)", addr, peerType)(&err)
link, err := neonet.DialLink(ctx, node.Net, addr) link, err := neonet.DialLink(ctx, node.Net, addr)
...@@ -164,6 +166,7 @@ func (node *Node) Dial(ctx context.Context, peerType proto.NodeType, addr string ...@@ -164,6 +166,7 @@ func (node *Node) Dial(ctx context.Context, peerType proto.NodeType, addr string
log.Info(ctx, "identification accepted") log.Info(ctx, "identification accepted")
return link, accept, nil return link, accept, nil
} }
*/
// ---------------------------------------- // ----------------------------------------
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment