本文整理汇总了Golang中github.com/cockroachdb/cockroach/server/status.NewRuntimeStatRecorder函数的典型用法代码示例。如果您正苦于以下问题:Golang NewRuntimeStatRecorder函数的具体用法?Golang NewRuntimeStatRecorder怎么用?Golang NewRuntimeStatRecorder使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewRuntimeStatRecorder函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: Start
// Start runs the RPC and HTTP servers, starts the gossip instance (if
// selfBootstrap is true, uses the rpc server's address as the gossip
// bootstrap), and starts the node using the supplied engines slice.
func (s *Server) Start(selfBootstrap bool) error {
if err := s.rpc.Listen(); err != nil {
return util.Errorf("could not listen on %s: %s", s.ctx.Addr, err)
}
// Handle self-bootstrapping case for a single node.
if selfBootstrap {
selfResolver, err := resolver.NewResolver(&s.ctx.Context, s.rpc.Addr().String())
if err != nil {
return err
}
s.gossip.SetResolvers([]resolver.Resolver{selfResolver})
}
s.gossip.Start(s.rpc, s.stopper)
if err := s.node.start(s.rpc, s.ctx.Engines, s.ctx.NodeAttributes, s.stopper); err != nil {
return err
}
// Begin recording runtime statistics.
runtime := status.NewRuntimeStatRecorder(s.node.Descriptor.NodeID, s.clock)
s.tsDB.PollSource(runtime, s.ctx.MetricsFrequency, ts.Resolution10s, s.stopper)
// Begin recording time series data collected by the status monitor.
s.recorder = status.NewNodeStatusRecorder(s.node.status, s.clock)
s.tsDB.PollSource(s.recorder, s.ctx.MetricsFrequency, ts.Resolution10s, s.stopper)
// Begin recording status summaries.
s.startWriteSummaries()
log.Infof("starting %s server at %s", s.ctx.HTTPRequestScheme(), s.rpc.Addr())
s.initHTTP()
s.rpc.Serve(s)
return nil
}
开发者ID:husttom,项目名称:cockroach,代码行数:38,代码来源:server.go
示例2: Start
// Start runs the RPC and HTTP servers, starts the gossip instance (if
// selfBootstrap is true, uses the rpc server's address as the gossip
// bootstrap), and starts the node using the supplied engines slice.
func (s *Server) Start(selfBootstrap bool) error {
tlsConfig, err := s.ctx.GetServerTLSConfig()
if err != nil {
return err
}
unresolvedAddr := util.MakeUnresolvedAddr("tcp", s.ctx.Addr)
ln, err := util.ListenAndServe(s.stopper, s, unresolvedAddr, tlsConfig)
if err != nil {
return err
}
s.listener = ln
addr := ln.Addr()
addrStr := addr.String()
// Handle self-bootstrapping case for a single node.
if selfBootstrap {
selfResolver, err := resolver.NewResolver(&s.ctx.Context, addrStr)
if err != nil {
return err
}
s.gossip.SetResolvers([]resolver.Resolver{selfResolver})
}
s.gossip.Start(s.rpc, addr, s.stopper)
if err := s.node.start(s.rpc, addr, s.ctx.Engines, s.ctx.NodeAttributes); err != nil {
return err
}
// Begin recording runtime statistics.
runtime := status.NewRuntimeStatRecorder(s.node.Descriptor.NodeID, s.clock)
s.tsDB.PollSource(runtime, s.ctx.MetricsFrequency, ts.Resolution10s, s.stopper)
// Begin recording time series data collected by the status monitor.
s.recorder = status.NewNodeStatusRecorder(s.node.status, s.clock)
s.tsDB.PollSource(s.recorder, s.ctx.MetricsFrequency, ts.Resolution10s, s.stopper)
// Begin recording status summaries.
s.startWriteSummaries()
s.sqlServer.SetNodeID(s.node.Descriptor.NodeID)
s.status = newStatusServer(s.db, s.gossip, s.metaRegistry, s.ctx)
log.Infof("starting %s server at %s", s.ctx.HTTPRequestScheme(), addr)
s.initHTTP()
// TODO(tamird): pick a port here
host, _, err := net.SplitHostPort(addrStr)
if err != nil {
return err
}
return s.pgServer.Start(util.MakeUnresolvedAddr("tcp", net.JoinHostPort(host, "0")))
}
开发者ID:haint504,项目名称:cockroach,代码行数:60,代码来源:server.go
示例3: Start
// Start runs the RPC and HTTP servers, starts the gossip instance (if
// selfBootstrap is true, uses the rpc server's address as the gossip
// bootstrap), and starts the node using the supplied engines slice.
func (s *Server) Start(selfBootstrap bool) error {
tlsConfig, err := s.ctx.GetServerTLSConfig()
if err != nil {
return err
}
unresolvedAddr := util.MakeUnresolvedAddr("tcp", s.ctx.Addr)
ln, err := util.ListenAndServe(s.stopper, s, unresolvedAddr, tlsConfig)
if err != nil {
return err
}
s.listener = ln
addr := ln.Addr()
addrStr := addr.String()
s.rpcContext.SetLocalServer(s.rpc, addrStr)
// Handle self-bootstrapping case for a single node.
if selfBootstrap {
selfResolver, err := resolver.NewResolver(&s.ctx.Context, addrStr)
if err != nil {
return err
}
s.gossip.SetResolvers([]resolver.Resolver{selfResolver})
}
s.gossip.Start(s.rpc, addr)
if err := s.node.start(s.rpc, addr, s.ctx.Engines, s.ctx.NodeAttributes); err != nil {
return err
}
// Begin recording runtime statistics.
runtime := status.NewRuntimeStatRecorder(s.node.Descriptor.NodeID, s.clock)
s.tsDB.PollSource(runtime, s.ctx.MetricsFrequency, ts.Resolution10s, s.stopper)
// Begin recording time series data collected by the status monitor.
s.recorder = status.NewNodeStatusRecorder(s.node.status, s.clock)
s.tsDB.PollSource(s.recorder, s.ctx.MetricsFrequency, ts.Resolution10s, s.stopper)
// Begin recording status summaries.
s.startWriteSummaries()
s.sqlServer.SetNodeID(s.node.Descriptor.NodeID)
// Create and start the schema change manager only after a NodeID
// has been assigned.
s.schemaChangeManager = sql.NewSchemaChangeManager(*s.db, s.gossip, s.leaseMgr)
s.schemaChangeManager.Start(s.stopper)
s.status = newStatusServer(s.db, s.gossip, s.metaRegistry, s.ctx)
log.Infof("starting %s server at %s", s.ctx.HTTPRequestScheme(), addr)
s.initHTTP()
return s.pgServer.Start(util.MakeUnresolvedAddr("tcp", s.ctx.PGAddr))
}
开发者ID:codeVerySlow,项目名称:cockroach,代码行数:59,代码来源:server.go
示例4: Start
// Start starts the server on the specified port, starts gossip and
// initializes the node using the engines from the server's context.
func (s *Server) Start() error {
tlsConfig, err := s.ctx.GetServerTLSConfig()
if err != nil {
return err
}
unresolvedAddr := util.NewUnresolvedAddr("tcp", s.ctx.Addr)
ln, err := util.ListenAndServe(s.stopper, s, unresolvedAddr, tlsConfig)
if err != nil {
return err
}
s.listener = ln // Only used in tests.
if err := officializeAddr(unresolvedAddr, ln.Addr()); err != nil {
return err
}
s.rpcContext.SetLocalServer(s.rpc, unresolvedAddr.String())
s.grpc = grpc.NewServer()
s.gossip.Start(s.grpc, unresolvedAddr)
if err := s.node.start(s.rpc, unresolvedAddr, s.ctx.Engines, s.ctx.NodeAttributes); err != nil {
return err
}
// Begin recording runtime statistics.
runtime := status.NewRuntimeStatRecorder(s.node.Descriptor.NodeID, s.clock)
s.tsDB.PollSource(runtime, s.ctx.MetricsFrequency, ts.Resolution10s, s.stopper)
// Begin recording time series data collected by the status monitor.
s.recorder = status.NewNodeStatusRecorder(s.node.status, s.clock)
s.tsDB.PollSource(s.recorder, s.ctx.MetricsFrequency, ts.Resolution10s, s.stopper)
// Begin recording status summaries.
s.startWriteSummaries()
s.sqlServer.SetNodeID(s.node.Descriptor.NodeID)
// Create and start the schema change manager only after a NodeID
// has been assigned.
s.schemaChangeManager = sql.NewSchemaChangeManager(*s.db, s.gossip, s.leaseMgr)
s.schemaChangeManager.Start(s.stopper)
s.status = newStatusServer(s.db, s.gossip, s.registry, s.ctx)
log.Infof("starting %s server at %s", s.ctx.HTTPRequestScheme(), unresolvedAddr)
s.initHTTP()
return s.pgServer.Start(util.NewUnresolvedAddr("tcp", s.ctx.PGAddr))
}
开发者ID:fndaily,项目名称:cockroach,代码行数:52,代码来源:server.go
示例5: Start
// Start starts the server on the specified port, starts gossip and
// initializes the node using the engines from the server's context.
func (s *Server) Start() error {
s.initHTTP()
tlsConfig, err := s.ctx.GetServerTLSConfig()
if err != nil {
return err
}
// The following code is a specialization of util/net.go's ListenAndServe
// which adds pgwire support. A single port is used to serve all protocols
// (pg, http, h2) via the following construction:
//
// non-TLS case:
// net.Listen -> cmux.New -> pgwire.Match -> pgwire.Server.ServeConn
// |
// - -> cmux.HTTP2 -> http2.(*Server).ServeConn
// - -> cmux.Any -> http.(*Server).Serve
//
// TLS case:
// net.Listen -> cmux.New -> pgwire.Match -> pgwire.Server.ServeConn
// |
// - -> cmux.Any -> tls.NewListener -> http.(*Server).Serve
//
// Note that the difference between the TLS and non-TLS cases exists due to
// Go's lack of an h2c (HTTP2 Clear Text) implementation. See inline comments
// in util.ListenAndServe for an explanation of how h2c is implemented there
// and here.
ln, err := net.Listen("tcp", s.ctx.Addr)
if err != nil {
return err
}
unresolvedAddr, err := officialAddr(s.ctx.Addr, ln.Addr())
if err != nil {
return err
}
s.ctx.Addr = unresolvedAddr.String()
s.stopper.RunWorker(func() {
<-s.stopper.ShouldDrain()
if err := ln.Close(); err != nil {
log.Fatal(err)
}
})
m := cmux.New(ln)
pgL := m.Match(pgwire.Match)
var serveConn func(net.Listener, func(net.Conn)) error
if tlsConfig != nil {
anyL := m.Match(cmux.Any())
serveConn = util.ServeHandler(s.stopper, s, tls.NewListener(anyL, tlsConfig), tlsConfig)
} else {
h2L := m.Match(cmux.HTTP2())
anyL := m.Match(cmux.Any())
var h2 http2.Server
serveConnOpts := &http2.ServeConnOpts{
Handler: s,
}
serveH2 := func(conn net.Conn) {
h2.ServeConn(conn, serveConnOpts)
}
serveConn = util.ServeHandler(s.stopper, s, anyL, tlsConfig)
s.stopper.RunWorker(func() {
util.FatalIfUnexpected(serveConn(h2L, serveH2))
})
}
s.stopper.RunWorker(func() {
util.FatalIfUnexpected(serveConn(pgL, func(conn net.Conn) {
if err := s.pgServer.ServeConn(conn); err != nil && !util.IsClosedConnection(err) {
log.Error(err)
}
}))
})
s.stopper.RunWorker(func() {
util.FatalIfUnexpected(m.Serve())
})
s.rpcContext.SetLocalServer(s.rpc, s.ctx.Addr)
s.gossip.Start(s.grpc, unresolvedAddr)
if err := s.node.start(s.rpc, unresolvedAddr, s.ctx.Engines, s.ctx.NodeAttributes); err != nil {
return err
}
// Begin recording runtime statistics.
runtime := status.NewRuntimeStatRecorder(s.node.Descriptor.NodeID, s.clock)
s.tsDB.PollSource(runtime, s.ctx.MetricsFrequency, ts.Resolution10s, s.stopper)
// Begin recording time series data collected by the status monitor.
s.tsDB.PollSource(s.recorder, s.ctx.MetricsFrequency, ts.Resolution10s, s.stopper)
//.........这里部分代码省略.........
开发者ID:mrtracy,项目名称:cockroach,代码行数:101,代码来源:server.go
注:本文中的github.com/cockroachdb/cockroach/server/status.NewRuntimeStatRecorder函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论