예제 #1
0
// start starts the node by registering the storage instance for the
// RPC service "Node" and initializing stores for each specified
// engine. Launches periodic store gossiping in a goroutine.
func (n *Node) start(rpcServer *rpc.Server, engines []engine.Engine,
	attrs proto.Attributes, stopper *util.Stopper) error {
	n.initDescriptor(rpcServer.Addr(), attrs)
	if err := rpcServer.RegisterName("Node", (*nodeServer)(n)); err != nil {
		log.Fatalf("unable to register node service with RPC server: %s", err)
	}

	// Start status monitor.
	n.status.StartMonitorFeed(n.ctx.EventFeed)
	stopper.AddCloser(n.ctx.EventFeed)

	// Initialize stores, including bootstrapping new ones.
	if err := n.initStores(engines, stopper); err != nil {
		return err
	}

	// Pass NodeID to status monitor - this value is initialized in initStores,
	// but the StatusMonitor must be active before initStores.
	n.status.SetNodeID(n.Descriptor.NodeID)

	// Initialize publisher for Node Events.
	n.feed = status.NewNodeEventFeed(n.Descriptor.NodeID, n.ctx.EventFeed)

	n.startedAt = n.ctx.Clock.Now().WallTime
	n.startStoresScanner(stopper)
	n.startPublishStatuses(stopper)
	n.startGossip(stopper)
	log.Infoc(n.context(), "Started node with %v engine(s) and attributes %v", engines, attrs.Attrs)
	return nil
}
예제 #2
0
파일: node.go 프로젝트: Gardenya/cockroach
// start starts the node by registering the storage instance for the
// RPC service "Node" and initializing stores for each specified
// engine. Launches periodic store gossiping in a goroutine.
func (n *Node) start(rpcServer *rpc.Server, engines []engine.Engine,
	attrs proto.Attributes, stopper *stop.Stopper) error {
	n.initDescriptor(rpcServer.Addr(), attrs)
	if err := rpcServer.RegisterName("Node", (*nodeServer)(n)); err != nil {
		log.Fatalf("unable to register node service with RPC server: %s", err)
	}

	// Start status monitor.
	n.status.StartMonitorFeed(n.ctx.EventFeed)
	stopper.AddCloser(n.ctx.EventFeed)

	// Initialize stores, including bootstrapping new ones.
	if err := n.initStores(engines, stopper); err != nil {
		return err
	}

	n.startedAt = n.ctx.Clock.Now().WallTime

	// Initialize publisher for Node Events. This requires the NodeID, which is
	// initialized by initStores(); because of this, some Store initialization
	// events will precede the StartNodeEvent on the feed.
	n.feed = status.NewNodeEventFeed(n.Descriptor.NodeID, n.ctx.EventFeed)
	n.feed.StartNode(n.Descriptor, n.startedAt)

	n.startPublishStatuses(stopper)
	n.startGossip(stopper)
	log.Infoc(n.context(), "Started node with %v engine(s) and attributes %v", engines, attrs.Attrs)
	return nil
}
예제 #3
0
파일: node.go 프로젝트: Zemnmez/cockroach
// NewNode returns a new instance of Node, interpreting command line
// flags to initialize the appropriate Store or set of
// Stores. Registers the storage instance for the RPC service "Node".
func NewNode(rpcServer *rpc.Server, kvDB kv.DB, gossip *gossip.Gossip) *Node {
	n := &Node{
		gossip:   gossip,
		kvDB:     kvDB,
		storeMap: make(map[int32]*storage.Store),
		closer:   make(chan struct{}, 1),
	}
	n.initAttributes(rpcServer.Addr())
	rpcServer.RegisterName("Node", n)
	return n
}
예제 #4
0
파일: node.go 프로젝트: Joinhack/cockroach
// start starts the node by initializing network/physical topology
// attributes gleaned from the environment and initializing stores
// for each specified engine. Launches periodic store gossipping
// in a goroutine.
func (n *Node) start(rpcServer *rpc.Server, engines []storage.Engine,
	attrs storage.Attributes) error {
	n.initDescriptor(rpcServer.Addr(), attrs)
	rpcServer.RegisterName("Node", n)

	if err := n.initStoreMap(engines); err != nil {
		return err
	}
	go n.startGossip()

	return nil
}
예제 #5
0
파일: node.go 프로젝트: GavinHwa/cockroach
// start starts the node by initializing network/physical topology
// attributes gleaned from the environment and initializing stores
// for each specified engine. Launches periodic store gossipping
// in a goroutine.
func (n *Node) start(rpcServer *rpc.Server, clock *hlc.HLClock,
	engines []engine.Engine, attrs engine.Attributes) error {
	n.initDescriptor(rpcServer.Addr(), attrs)
	rpcServer.RegisterName("Node", n)

	if err := n.initStores(clock, engines); err != nil {
		return err
	}
	go n.startGossip()

	return nil
}
예제 #6
0
파일: server.go 프로젝트: Zemnmez/cockroach
// newServer creates and returns a server struct.
func newServer(rpcServer *rpc.Server, interval time.Duration) *server {
	s := &server{
		interval:      interval,
		is:            newInfoStore(rpcServer.Addr()),
		incoming:      newAddrSet(MaxPeers),
		clientAddrMap: make(map[string]net.Addr),
	}
	rpcServer.RegisterName("Gossip", s)
	rpcServer.AddCloseCallback(s.onClose)
	s.ready = sync.NewCond(&s.mu)
	return s
}
예제 #7
0
파일: node.go 프로젝트: kuguobing/cockroach
// start starts the node by initializing network/physical topology
// attributes gleaned from the environment and initializing stores
// for each specified engine. Launches periodic store gossipping
// in a goroutine.
func (n *Node) start(rpcServer *rpc.Server, clock *hlc.Clock,
	engines []engine.Engine, attrs proto.Attributes) error {
	n.initDescriptor(rpcServer.Addr(), attrs)
	rpcServer.RegisterName("Node", n)

	// Initialize stores, including bootstrapping new ones.
	if err := n.initStores(clock, engines); err != nil {
		return err
	}
	go n.startGossip()

	return nil
}
예제 #8
0
// start starts the node by initializing network/physical topology
// attributes gleaned from the environment and initializing stores
// for each specified engine. Launches periodic store gossiping
// in a goroutine.
func (n *Node) start(rpcServer *rpc.Server, clock *hlc.Clock,
	engines []engine.Engine, attrs proto.Attributes) error {
	n.initDescriptor(rpcServer.Addr(), attrs)
	if err := rpcServer.RegisterName("Node", n); err != nil {
		log.Fatalf("unable to register node service with RPC server: %s", err)
	}

	// Initialize stores, including bootstrapping new ones.
	if err := n.initStores(clock, engines); err != nil {
		return err
	}
	go n.startGossip()
	log.Infof("Started node with %v engine(s) and attributes %v", engines, attrs)
	return nil
}
예제 #9
0
// start initializes the infostore with the rpc server address and
// then begins processing connecting clients in an infinite select
// loop via goroutine. Periodically, clients connected and awaiting
// the next round of gossip are awoken via the conditional variable.
func (s *server) start(rpcServer *rpc.Server) {
	s.is.NodeAddr = rpcServer.Addr()
	rpcServer.RegisterName("Gossip", s)
	rpcServer.AddCloseCallback(s.onClose)

	go func() {
		// Periodically wakeup blocked client gossip requests.
		gossipTimeout := time.Tick(s.jitteredGossipInterval())
		for {
			select {
			case <-gossipTimeout:
				// Wakeup all blocked gossip requests.
				s.ready.Broadcast()
			}
		}
	}()
}
예제 #10
0
// start initializes the infostore with the rpc server address and
// then begins processing connecting clients in an infinite select
// loop via goroutine. Periodically, clients connected and awaiting
// the next round of gossip are awoken via the conditional variable.
func (s *server) start(rpcServer *rpc.Server) {
	s.is.NodeAddr = rpcServer.Addr()
	if err := rpcServer.RegisterName("Gossip", s); err != nil {
		log.Fatalf("unable to register gossip service with RPC server: %s", err)
	}
	rpcServer.AddCloseCallback(s.onClose)

	go func() {
		// Periodically wakeup blocked client gossip requests.
		gossipTimeout := time.Tick(s.jitteredGossipInterval())
		for {
			select {
			case <-gossipTimeout:
				// Wakeup all blocked gossip requests.
				s.ready.Broadcast()
			}
		}
	}()
}
예제 #11
0
// start initializes the infostore with the rpc server address and
// then begins processing connecting clients in an infinite select
// loop via goroutine. Periodically, clients connected and awaiting
// the next round of gossip are awoken via the conditional variable.
func (s *server) start(rpcServer *rpc.Server, stopper *stop.Stopper) {
	s.is.NodeAddr = rpcServer.Addr()
	if err := rpcServer.RegisterName("Gossip", s); err != nil {
		log.Fatalf("unable to register gossip service with RPC server: %s", err)
	}
	rpcServer.AddCloseCallback(s.onClose)

	stopper.RunWorker(func() {
		// Periodically wakeup blocked client gossip requests.
		for {
			select {
			case <-time.After(s.jitteredGossipInterval()):
				// Wakeup all blocked gossip requests.
				s.ready.Broadcast()
			case <-stopper.ShouldStop():
				s.stop()
				return
			}
		}
	})
}
예제 #12
0
파일: db.go 프로젝트: Hellblazer/cockroach
// RegisterRPC registers the RPC endpoints.
func (s *DBServer) RegisterRPC(rpcServer *rpc.Server) error {
	return rpcServer.RegisterName("Server", (*rpcDBServer)(s))
}