Beispiel #1
0
// New creates an instance of a gossip node.
func New(rpcContext *rpc.Context, resolvers []resolver.Resolver, stopper *stop.Stopper) *Gossip {
	g := &Gossip{
		Connected:         make(chan struct{}),
		server:            newServer(stopper),
		outgoing:          makeNodeSet(minPeers),
		bootstrapping:     map[string]struct{}{},
		clients:           []*client{},
		disconnected:      make(chan *client, 10),
		stalled:           make(chan struct{}, 1),
		stallInterval:     defaultStallInterval,
		bootstrapInterval: defaultBootstrapInterval,
		cullInterval:      defaultCullInterval,
		nodeDescs:         map[roachpb.NodeID]*roachpb.NodeDescriptor{},
	}
	g.SetResolvers(resolvers)
	// The gossip RPC context doesn't measure clock offsets, isn't
	// shared with the other RPC clients which the node may be using,
	// and disables reconnects to make it possible to know for certain
	// which other nodes in the cluster are incoming via gossip.
	if rpcContext != nil {
		g.rpcContext = rpcContext.Copy()
		g.rpcContext.DisableCache = true
		g.rpcContext.DisableReconnects = true
		g.rpcContext.RemoteClocks = nil
	}

	// Add ourselves as a SystemConfig watcher.
	g.is.registerCallback(KeySystemConfig, g.updateSystemConfig)
	// Add ourselves as a node descriptor watcher.
	g.is.registerCallback(MakePrefixPattern(KeyNodeIDPrefix), g.updateNodeAddress)

	return g
}
Beispiel #2
0
// New creates an instance of a gossip node.
func New(rpcContext *rpc.Context, gossipInterval time.Duration, resolvers []resolver.Resolver) *Gossip {
	g := &Gossip{
		Connected:     make(chan struct{}),
		RPCContext:    rpcContext,
		server:        newServer(gossipInterval),
		outgoing:      makeNodeSet(MaxPeers),
		bootstrapping: map[string]struct{}{},
		clients:       []*client{},
		disconnected:  make(chan *client, MaxPeers),
		stalled:       make(chan struct{}, 1),
		resolvers:     resolvers,
	}
	// Create the bootstrapping RPC context. This context doesn't
	// measure clock offsets and doesn't cache clients because bootstrap
	// connections may go through a load balancer.
	if rpcContext != nil {
		g.bsRPCContext = rpcContext.Copy()
		g.bsRPCContext.DisableCache = true
		g.bsRPCContext.RemoteClocks = nil
	}

	// Add ourselves as a SystemConfig watcher.
	g.is.registerCallback(KeySystemConfig, g.updateSystemConfig)
	return g
}
Beispiel #3
0
// New creates an instance of a gossip node.
func New(rpcContext *rpc.Context, resolvers []resolver.Resolver) *Gossip {
	g := &Gossip{
		Connected:     make(chan struct{}),
		server:        newServer(),
		outgoing:      makeNodeSet(1),
		bootstrapping: map[string]struct{}{},
		clients:       []*client{},
		disconnected:  make(chan *client, 10),
		stalled:       make(chan struct{}, 1),
		resolverIdx:   len(resolvers) - 1,
		resolvers:     resolvers,
	}
	// The gossip RPC context doesn't measure clock offsets, isn't
	// shared with the other RPC clients which the node may be using,
	// and disables reconnects to make it possible to know for certain
	// which other nodes in the cluster are incoming via gossip.
	if rpcContext != nil {
		g.rpcContext = rpcContext.Copy()
		g.rpcContext.DisableCache = true
		g.rpcContext.DisableReconnects = true
		g.rpcContext.RemoteClocks = nil
	}

	// Add ourselves as a SystemConfig watcher.
	g.is.registerCallback(KeySystemConfig, g.updateSystemConfig)
	return g
}