Commit 533d3a3e authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 7877e55c
// gmigrate - show number of times G migrates to another M (OS thread). // gmigrate - show number of times G migrates to another M (OS thread).
// usage: `go tool trace -d <trace.out> |gmigrate` // usage: `go tool trace -d <trace.out> |gmigrate`
package main
// +build ignore // +build ignore
package main
import ( import (
"bufio" "bufio"
"errors" "errors"
......
...@@ -88,6 +88,7 @@ func NewClient(clusterName, masterAddr string, net xnet.Networker) *Client { ...@@ -88,6 +88,7 @@ func NewClient(clusterName, masterAddr string, net xnet.Networker) *Client {
// spawn background process which performs master talk // spawn background process which performs master talk
ctx, cancel := context.WithCancel(context.Background()) ctx, cancel := context.WithCancel(context.Background())
cli.talkMasterCancel = cancel cli.talkMasterCancel = cancel
cli.node.OnShutdown = cancel // XXX ok?
go cli.talkMaster(ctx) go cli.talkMaster(ctx)
return cli return cli
......
...@@ -1146,6 +1146,9 @@ func (c *Conn) Recv() (Msg, error) { ...@@ -1146,6 +1146,9 @@ func (c *Conn) Recv() (Msg, error) {
// TODO use free-list for decoded messages + when possible decode in-place // TODO use free-list for decoded messages + when possible decode in-place
msg := reflect.New(msgType).Interface().(Msg) msg := reflect.New(msgType).Interface().(Msg)
// msg := reflect.NewAt(msgType, bufAlloc(msgType.Size())
_, err = msg.neoMsgDecode(pkt.Payload()) _, err = msg.neoMsgDecode(pkt.Payload())
if err != nil { if err != nil {
return nil, &ConnError{Conn: c, Op: "decode", Err: err} // XXX "decode:" is already in ErrDecodeOverflow return nil, &ConnError{Conn: c, Op: "decode", Err: err} // XXX "decode:" is already in ErrDecodeOverflow
......
...@@ -31,7 +31,6 @@ import ( ...@@ -31,7 +31,6 @@ import (
"context" "context"
"fmt" "fmt"
"net" "net"
"os"
"sync" "sync"
"lab.nexedi.com/kirr/go123/xerr" "lab.nexedi.com/kirr/go123/xerr"
...@@ -69,6 +68,9 @@ type NodeApp struct { ...@@ -69,6 +68,9 @@ type NodeApp struct {
NodeTab *NodeTable // information about nodes in the cluster NodeTab *NodeTable // information about nodes in the cluster
PartTab *PartitionTable // information about data distribution in the cluster PartTab *PartitionTable // information about data distribution in the cluster
ClusterState ClusterState // master idea about cluster state ClusterState ClusterState // master idea about cluster state
// should be set by user so NodeApp can notify when master tells this node to shutdown
OnShutdown func()
} }
// NewNodeApp creates new node application // NewNodeApp creates new node application
...@@ -346,7 +348,9 @@ func (app *NodeApp) UpdateNodeTab(ctx context.Context, msg *NotifyNodeInformatio ...@@ -346,7 +348,9 @@ func (app *NodeApp) UpdateNodeTab(ctx context.Context, msg *NotifyNodeInformatio
if nodeInfo.State == DOWN { if nodeInfo.State == DOWN {
log.Info(ctx, "master told us to shutdown") log.Info(ctx, "master told us to shutdown")
log.Flush() log.Flush()
os.Exit(1) app.OnShutdown()
// os.Exit(1)
return
} }
} }
} }
......
...@@ -94,6 +94,7 @@ func (stor *Storage) Run(ctx context.Context) error { ...@@ -94,6 +94,7 @@ func (stor *Storage) Run(ctx context.Context) error {
// start serving incoming connections // start serving incoming connections
wg := sync.WaitGroup{} wg := sync.WaitGroup{}
serveCtx, serveCancel := context.WithCancel(ctx) serveCtx, serveCancel := context.WithCancel(ctx)
stor.node.OnShutdown = serveCancel
wg.Add(1) wg.Add(1)
go func(ctx context.Context) (err error) { go func(ctx context.Context) (err error) {
defer wg.Done() defer wg.Done()
......
...@@ -75,7 +75,7 @@ Sgo() { ...@@ -75,7 +75,7 @@ Sgo() {
# -alsologtostderr # -alsologtostderr
exec -a Sgo \ exec -a Sgo \
neo -log_dir=$log storage -cluster=$cluster -bind=$Sbind -masters=$Mbind "$@" & neo -cpuprofile cpu.out -log_dir=$log storage -cluster=$cluster -bind=$Sbind -masters=$Mbind "$@" &
} }
......
// zsha1 - compute sha1 of whole latest objects stream in a ZODB database // zsha1 - compute sha1 of whole latest objects stream in a ZODB database
package main
// +build ignore // +build ignore
package main
import ( import (
"context" "context"
"crypto/sha1" "crypto/sha1"
......
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