Commit b2f0b1c6 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 62117b70
......@@ -43,7 +43,7 @@ import (
// Client talks to NEO cluster and exposes access to it via ZODB interfaces.
type Client struct {
node neo.NodeCommon
node neo.NodeApp
talkMasterCancel func()
......@@ -62,7 +62,7 @@ type Client struct {
// - .ClusterState = RUNNING <- XXX needed?
//
// however master link is accessed separately (see ^^^ and masterLink)
operational bool // XXX <- somehow move to NodeCommon?
operational bool // XXX <- somehow move to NodeApp?
opReady chan struct{} // reinitialized each time state becomes non-operational
}
......@@ -77,7 +77,7 @@ func (c *Client) StorageName() string {
// It will connect to master @masterAddr and identify with sepcified cluster name.
func NewClient(clusterName, masterAddr string, net xnet.Networker) *Client {
cli := &Client{
node: neo.NodeCommon{
node: neo.NodeApp{
MyInfo: neo.NodeInfo{Type: neo.CLIENT, Addr: neo.Address{}},
ClusterName: clusterName,
Net: net,
......@@ -368,15 +368,14 @@ func (c *Client) LastOid(ctx context.Context) (zodb.Oid, error) {
}
func (c *Client) Load(ctx context.Context, xid zodb.Xid) (data []byte, serial zodb.Tid, err error) {
// XXX err context (but keep zodb errors intact ?)
defer xerr.Contextf(&err, "client: load %v", xid)
defer xerr.Contextf(&err, "client: load %v", xid) // XXX keep zodb errors intact?
err = c.withOperational(ctx)
if err != nil {
return nil, 0, err
}
// Here we have cluster state operational and rlocked. Retrieve
// here we have cluster state operational and rlocked. Retrieve
// storages we might need to access and release the lock.
storv := make([]*neo.Node, 0)
for _, cell := range c.node.PartTab.Get(xid.Oid) {
......
......@@ -49,10 +49,10 @@ const (
)
// NodeCommon is common data in all NEO nodes: Master, Storage & Client XXX text
// XXX naming -> Node ?
// NodeApp is base for implementing NEO node applications.
//
// XXX -> internal?
type NodeCommon struct {
type NodeApp struct {
MyInfo NodeInfo
ClusterName string
......@@ -70,7 +70,7 @@ type NodeCommon struct {
// It handshakes, requests identification and checks peer type. If successful returned are:
// - primary link connection which carried identification
// - accept identification reply
func (n *NodeCommon) Dial(ctx context.Context, peerType NodeType, addr string) (_ *Conn, _ *AcceptIdentification, err error) {
func (n *NodeApp) Dial(ctx context.Context, peerType NodeType, addr string) (_ *Conn, _ *AcceptIdentification, err error) {
link, err := DialLink(ctx, n.Net, addr)
if err != nil {
return nil, nil, err
......@@ -117,9 +117,10 @@ func (n *NodeCommon) Dial(ctx context.Context, peerType NodeType, addr string) (
// Listen starts listening at node's listening address.
//
// If the address is empty one new free is automatically selected.
// The node information about where it listens at is appropriately updated.
func (n *NodeCommon) Listen() (Listener, error) {
func (n *NodeApp) Listen() (Listener, error) {
// start listening
ll, err := ListenLink(n.Net, n.MyInfo.Addr.String())
if err != nil {
......
......@@ -69,6 +69,7 @@ type NodeTable struct {
//trace:event traceNodeChanged(nt *NodeTable, n *Node)
// Node represents a peer node in the cluster.
//
// XXX name as Peer?
type Node struct {
nodeTab *NodeTable // this node is part of
......@@ -336,7 +337,7 @@ type dialed struct {
ready chan struct{}
}
// Dial returns link to peer node.
// Dial establishes link to peer node.
//
// If the link was not yet established Dial dials the peer appropriately,
// handshakes, requests identification and checks that identification reply is
......@@ -470,7 +471,7 @@ func (p *Peer) PutConn(c *Conn) {
// dial does low-level work to dial peer
// XXX p.* reading without lock - ok?
func (p *Node) dial(ctx context.Context) (*NodeLink, error) {
var me *NodeCommon // XXX temp stub
var me *NodeApp // XXX bad -> crashes
conn0, accept, err := me.Dial(ctx, p.Type, p.Addr.String())
if err != nil {
return nil, err
......
......@@ -211,7 +211,7 @@ func TestMasterStorage(t *testing.T) {
}
// shortcut for nodetab change
node := func(x *neo.NodeCommon, laddr string, typ neo.NodeType, num int32, state neo.NodeState, idtstamp float64) *traceNode {
node := func(x *neo.NodeApp, 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),
......@@ -394,7 +394,7 @@ func TestMasterStorage(t *testing.T) {
},
}))
Cnode := (*neo.NodeCommon)(unsafe.Pointer(C)) // XXX hack
Cnode := (*neo.NodeApp)(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))
......
......@@ -44,7 +44,7 @@ import (
// Master is a node overseeing and managing how whole NEO cluster works
type Master struct {
node neo.NodeCommon
node neo.NodeApp
// master manages node and partition tables and broadcast their updates
// to all nodes in cluster
......@@ -90,7 +90,7 @@ func NewMaster(clusterName, serveAddr string, net xnet.Networker) *Master {
}
m := &Master{
node: neo.NodeCommon{
node: neo.NodeApp{
MyInfo: neo.NodeInfo{Type: neo.MASTER, Addr: addr},
ClusterName: clusterName,
Net: net,
......
......@@ -39,7 +39,7 @@ import (
// Storage is NEO node that keeps data and provides read/write access to it
type Storage struct {
node neo.NodeCommon
node neo.NodeApp
// context for providing operational service
// it is renewed every time master tells us StartOpertion, so users
......@@ -68,7 +68,7 @@ func NewStorage(cluster, masterAddr, serveAddr string, net xnet.Networker, zstor
}
stor := &Storage{
node: neo.NodeCommon{
node: neo.NodeApp{
MyInfo: neo.NodeInfo{Type: neo.STORAGE, Addr: addr},
ClusterName: cluster,
Net: net,
......
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