本文整理汇总了Golang中github.com/ngaut/log.Fatal函数的典型用法代码示例。如果您正苦于以下问题:Golang Fatal函数的具体用法?Golang Fatal怎么用?Golang Fatal使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Fatal函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: getSuitableBlock
func (b BlockContainer) getSuitableBlock(nodeID uint64, compressedSize int) *Block {
if nodeID < MinNodeId {
logger.Fatal("NodeId Error")
}
if compressedSize == 0 {
logger.Fatal("CompressedSize = 0")
}
block := b.getBlockByNodeID(nodeID)
// if block != nil && !block.availableNewSize(uint32(compressedSize)) {
// b.evitAndReallocBlock(block)
// }
if block == nil {
for i := 0; i < MaxBlockCount; i++ {
bl := b.blocks[i]
if bl.available(uint32(compressedSize)) {
block = bl
break
}
}
}
if block == nil {
logger.Fatal("Not Found Available Block, Error!!!")
}
return block
}
开发者ID:yqingp,项目名称:lodb,代码行数:31,代码来源:block_container.go
示例2: batchRawPut
// blind put bench
func batchRawPut(value []byte) {
cli, err := tikv.NewRawKVClient(strings.Split(*pdAddr, ","))
if err != nil {
log.Fatal(err)
}
wg := sync.WaitGroup{}
base := *dataCnt / *workerCnt
wg.Add(*workerCnt)
for i := 0; i < *workerCnt; i++ {
go func(i int) {
defer wg.Done()
for j := 0; j < base; j++ {
k := base*i + j
key := fmt.Sprintf("key_%d", k)
err = cli.Put([]byte(key), value)
if err != nil {
log.Fatal(errors.ErrorStack(err))
}
}
}(i)
}
wg.Wait()
}
开发者ID:pingcap,项目名称:tidb,代码行数:26,代码来源:main.go
示例3: main
func main() {
flag.Parse()
if *lease < 0 {
log.Fatalf("invalid lease seconds %d", *lease)
}
tidb.SetSchemaLease(time.Duration(*lease) * time.Second)
log.SetLevelByString(*logLevel)
store, err := tidb.NewStore(fmt.Sprintf("%s://%s", *store, *storePath))
if err != nil {
log.Fatal(err)
}
var driver relay.IDriver
driver = relay.NewTiDBDriver(store)
replayer, err := relay.NewReplayer(driver, *relayPath, *check)
if err != nil {
log.Fatal(err)
}
replayer.OnRecordRead = func(rec *relay.Record) {
fmt.Printf("%s\n", rec)
}
err = replayer.Run()
if err != nil {
log.Fatal(errors.ErrorStack(err))
}
}
开发者ID:pingcap,项目名称:mysqlrelay,代码行数:31,代码来源:main.go
示例4: doDMLWorks
// Execute DML statements in bootstrap stage.
// All the statements run in a single transaction.
func doDMLWorks(s Session) {
mustExecute(s, "BEGIN")
// Insert a default user with empty password.
mustExecute(s, `INSERT INTO mysql.user VALUES
("%", "root", "", "Y", "Y", "Y", "Y", "Y", "Y", "Y", "Y", "Y", "Y", "Y", "Y")`)
// Init global system variables table.
values := make([]string, 0, len(variable.SysVars))
for k, v := range variable.SysVars {
value := fmt.Sprintf(`("%s", "%s")`, strings.ToLower(k), v.Value)
values = append(values, value)
}
sql := fmt.Sprintf("INSERT INTO %s.%s VALUES %s;", mysql.SystemDB, mysql.GlobalVariablesTable,
strings.Join(values, ", "))
mustExecute(s, sql)
sql = fmt.Sprintf(`INSERT INTO %s.%s VALUES("%s", "%s", "Bootstrap flag. Do not delete.")
ON DUPLICATE KEY UPDATE VARIABLE_VALUE="%s"`,
mysql.SystemDB, mysql.TiDBTable, bootstrappedVar, bootstrappedVarTrue, bootstrappedVarTrue)
mustExecute(s, sql)
_, err := s.Execute("COMMIT")
if err != nil {
time.Sleep(1 * time.Second)
// Check if TiDB is already bootstrapped.
b, err1 := checkBootstrapped(s)
if err1 != nil {
log.Fatal(err1)
}
if b {
return
}
log.Fatal(err)
}
}
开发者ID:yubobo,项目名称:tidb,代码行数:37,代码来源:bootstrap.go
示例5: main
func main() {
cus, err := nsq.NewConsumer("log", "logxx", nsq.NewConfig())
if err != nil {
log.Fatal(err)
}
var th = &TailHandler{SouceMap: getSourceMap()}
go func() {
t := time.NewTicker(time.Hour)
for {
select {
case <-t.C:
th.SouceMap = getSourceMap()
}
}
}()
cus.AddHandler(th)
if err := cus.ConnectToNSQD(*nsqhost); err != nil {
log.Fatal(err)
}
for {
select {
case <-cus.StopChan:
return
}
}
}
开发者ID:qgweb,项目名称:new,代码行数:31,代码来源:logserver.go
示例6: get
func (n *Node) get(key string) (message *Message, err error) {
index := n.getSuitablePivotIndex(key)
if index >= int(n.pivotCount) {
logger.Fatal("Unknow Error, pivot index out range")
}
pivot := n.pivots[index]
if pivot == nil {
logger.Fatal("Unknow error, Pivot Is Nil, Min pivot count is 1, but current = 0")
}
message = pivot.get(key)
if message != nil {
return
}
if n.isLeaf {
return
}
if pivot.hasChild() {
childNode := n.tree.nodes[pivot.childNodeID]
if childNode == nil {
logger.Debug("Get Node Error")
}
message, err = childNode.get(key)
}
return
}
开发者ID:yqingp,项目名称:lodb,代码行数:32,代码来源:node.go
示例7: main
func main() {
pub, err := nsq.NewProducer(*tHost, nsq.NewConfig())
if err != nil {
log.Fatal(err)
}
t, err := tail.TailFile(*tFile, tail.Config{Follow: true,
//Location: &tail.SeekInfo{Offset: 0, Whence: os.SEEK_END}})
Location: &tail.SeekInfo{Offset: 0, Whence: os.SEEK_CUR}})
if err != nil {
log.Fatal(err)
}
for line := range t.Lines {
if *tTag != "" {
for k, tag := range strings.Split(*tTag, "|") {
var ks = []string{"pv", "click", "other"}
if strings.Contains(line.Text, tag) {
if *tDebug == "1" {
fmt.Println(fmt.Println(line.Text))
}
pub.Publish("log", []byte(ks[k]+"\t"+line.Text))
}
}
}
}
}
开发者ID:qgweb,项目名称:new,代码行数:26,代码来源:logclient.go
示例8: flush
func (h *Header) flush() {
file := h.tree.file
buffer := &bytes.Buffer{}
serializeHeader(buffer, h)
if _, err := file.WriteAt(buffer.Bytes(), 0); err != nil {
logger.Fatal(err)
}
// h.serializeContainerToDisk()
buffer = &bytes.Buffer{}
h.container.writeTo(buffer)
crcValue := checksum(buffer) // uint32
crcBuffer := &bytes.Buffer{}
binary.Write(crcBuffer, binary.LittleEndian, crcValue)
binary.Write(crcBuffer, binary.LittleEndian, uint32(buffer.Len()))
if _, err := file.WriteAt(crcBuffer.Bytes(), HeaderSize); err != nil {
logger.Fatal(err)
}
offset := HeaderSize + int64(Uint32Size)*2
if _, err := file.WriteAt(buffer.Bytes(), offset); err != nil {
logger.Fatal(err)
}
if err := file.Sync(); err != nil {
logger.Fatal(err)
}
}
开发者ID:yqingp,项目名称:lodb,代码行数:34,代码来源:header.go
示例9: deserializeBlockContainer
func deserializeBlockContainer(reader *bytes.Reader, blockContainer *BlockContainer) {
var nodesOffset uint64
if err := binary.Read(reader, binary.LittleEndian, &nodesOffset); err != nil {
logger.Fatal(err)
}
blockContainer.nodesOffset = nodesOffset
logger.Debug("Serialize nodesOffset =", nodesOffset)
var blockCount uint32
if err := binary.Read(reader, binary.LittleEndian, &blockCount); err != nil {
logger.Fatal(err)
}
blockContainer.blockCount = blockCount
var blockSize uint64
if err := binary.Read(reader, binary.LittleEndian, &blockSize); err != nil {
logger.Fatal(err)
}
blockContainer.blockSize = blockSize
var blockUsedCount uint32
if err := binary.Read(reader, binary.LittleEndian, &blockUsedCount); err != nil {
logger.Fatal(err)
}
blockContainer.blockUsedCount = blockUsedCount
}
开发者ID:yqingp,项目名称:lodb,代码行数:28,代码来源:serializer.go
示例10: main
func main() {
tidb.RegisterLocalStore("boltdb", boltdb.Driver{})
tidb.RegisterStore("tikv", tikv.Driver{})
metric.RunMetric(3 * time.Second)
printer.PrintTiDBInfo()
runtime.GOMAXPROCS(runtime.NumCPU())
flag.Parse()
if *lease < 0 {
log.Fatalf("invalid lease seconds %d", *lease)
}
tidb.SetSchemaLease(time.Duration(*lease) * time.Second)
cfg := &server.Config{
Addr: fmt.Sprintf(":%s", *port),
LogLevel: *logLevel,
StatusAddr: fmt.Sprintf(":%s", *statusPort),
Socket: *socket,
}
log.SetLevelByString(cfg.LogLevel)
store, err := tidb.NewStore(fmt.Sprintf("%s://%s", *store, *storePath))
if err != nil {
log.Fatal(errors.ErrorStack(err))
}
// Create a session to load information schema.
se, err := tidb.CreateSession(store)
if err != nil {
log.Fatal(errors.ErrorStack(err))
}
se.Close()
var driver server.IDriver
driver = server.NewTiDBDriver(store)
var svr *server.Server
svr, err = server.NewServer(cfg, driver)
if err != nil {
log.Fatal(errors.ErrorStack(err))
}
sc := make(chan os.Signal, 1)
signal.Notify(sc,
syscall.SIGHUP,
syscall.SIGINT,
syscall.SIGTERM,
syscall.SIGQUIT)
go func() {
sig := <-sc
log.Infof("Got signal [%d] to exit.", sig)
svr.Close()
os.Exit(0)
}()
log.Error(svr.Run())
}
开发者ID:anywhy,项目名称:tidb,代码行数:59,代码来源:main.go
示例11: processAction
func (s *Server) processAction(e interface{}) {
if strings.Index(GetEventPath(e), models.GetProxyPath(s.top.ProductName)) == 0 {
// proxy event, should be order for me to suicide
s.handleProxyCommand()
return
}
// re-watch
nodes, err := s.top.WatchChildren(models.GetWatchActionPath(s.top.ProductName), s.evtbus)
if err != nil {
log.Fatal(errors.ErrorStack(err))
}
seqs, err := models.ExtraSeqList(nodes)
if err != nil {
log.Fatal(errors.ErrorStack(err))
}
if len(seqs) == 0 || !s.top.IsChildrenChangedEvent(e) {
return
}
// get last pos
index := -1
for i, seq := range seqs {
if s.lastActionSeq < seq {
index = i
break
}
}
if index < 0 {
return
}
actions := seqs[index:]
for _, seq := range actions {
exist, err := s.top.Exist(path.Join(s.top.GetActionResponsePath(seq), s.pi.ID))
if err != nil {
log.Fatal(errors.ErrorStack(err))
}
if exist {
continue
}
if s.checkAndDoTopoChange(seq) {
s.responseAction(int64(seq))
}
}
s.lastActionSeq = seqs[len(seqs)-1]
}
开发者ID:GavinHwa,项目名称:reborn,代码行数:53,代码来源:router.go
示例12: prepareBenchSession
func prepareBenchSession() Session {
store, err := NewStore("memory://bench")
if err != nil {
log.Fatal(err)
}
log.SetLevel(log.LOG_LEVEL_ERROR)
se, err := CreateSession(store)
if err != nil {
log.Fatal(err)
}
mustExecute(se, "use test")
return se
}
开发者ID:yangxuanjia,项目名称:tidb,代码行数:13,代码来源:bench_test.go
示例13: valid
func (p Pivot) valid() bool {
if p.messageContainer == nil {
logger.Fatal("Pivot MessageContainer Is Nil")
return false
}
if p.node == nil {
logger.Fatal("Pivot Node Is Nil")
return false
}
return true
}
开发者ID:yqingp,项目名称:lodb,代码行数:13,代码来源:pivot.go
示例14: readResult
func readResult(rs ast.RecordSet, count int) {
for count > 0 {
x, err := rs.Next()
if err != nil {
log.Fatal(err)
}
if x == nil {
log.Fatal(count)
}
count--
}
rs.Close()
}
开发者ID:yangxuanjia,项目名称:tidb,代码行数:13,代码来源:bench_test.go
示例15: fatal
func fatal(msg interface{}) {
if globalConn != nil {
globalConn.Close()
}
// cleanup
switch msg.(type) {
case string:
log.Fatal(msg)
case error:
log.Fatal(errors.ErrorStack(msg.(error)))
}
}
开发者ID:vebin,项目名称:reborn,代码行数:13,代码来源:main.go
示例16: main
func main() {
runtime.GOMAXPROCS(runtime.NumCPU())
flag.Parse()
if len(*configFile) == 0 {
log.Fatal("must use a config file")
os.Exit(1)
}
cfg, err := config.LoadConfig(*configFile)
if err != nil {
log.Fatal(err.Error())
os.Exit(1)
}
if err = cluster.Init(cfg); err != nil {
log.Fatal(err.Error())
os.Exit(1)
}
mysql.SetLogger(log.Logger())
sc := make(chan os.Signal, 1)
signal.Notify(sc,
syscall.SIGHUP,
syscall.SIGINT,
syscall.SIGTERM,
syscall.SIGQUIT)
var svr *proxy.Server
svr, err = proxy.NewServer(cfg)
if err != nil {
log.Fatal(err.Error())
os.Exit(1)
}
go func() {
http.ListenAndServe(":11888", nil)
}()
go func() {
sig := <-sc
log.Infof("Got signal [%d] to exit.", sig)
svr.Close()
}()
svr.Serve()
}
开发者ID:wangjild,项目名称:dbatman,代码行数:50,代码来源:main.go
示例17: main
func main() {
metric.RunMetric(3 * time.Second)
printer.PrintTiDBInfo()
runtime.GOMAXPROCS(runtime.NumCPU())
flag.Parse()
if *lease <= 0 {
log.Fatalf("invalid lease seconds %d", *lease)
}
tidb.SetSchemaLease(time.Duration(*lease) * time.Second)
cfg := &server.Config{
Addr: fmt.Sprintf(":%s", *port),
LogLevel: *logLevel,
}
log.SetLevelByString(cfg.LogLevel)
store, err := tidb.NewStore(fmt.Sprintf("%s://%s", *store, *storePath))
if err != nil {
log.Fatal(err)
}
var driver server.IDriver
driver = server.NewTiDBDriver(store)
var svr *server.Server
svr, err = server.NewServer(cfg, driver)
if err != nil {
log.Fatal(err)
}
sc := make(chan os.Signal, 1)
signal.Notify(sc,
syscall.SIGHUP,
syscall.SIGINT,
syscall.SIGTERM,
syscall.SIGQUIT)
go func() {
sig := <-sc
log.Infof("Got signal [%d] to exit.", sig)
svr.Close()
os.Exit(0)
}()
log.Error(svr.Run())
}
开发者ID:yzl11,项目名称:vessel,代码行数:48,代码来源:main.go
示例18: mustExecute
func mustExecute(s Session, sql string) {
_, err := s.Execute(sql)
if err != nil {
debug.PrintStack()
log.Fatal(err)
}
}
开发者ID:huozhe3136,项目名称:tidb,代码行数:7,代码来源:bootstrap.go
示例19: InitCoordConn
func (top *Topology) InitCoordConn() {
var err error
top.coordConn, err = top.fact(top.coordAddr)
if err != nil {
log.Fatal(err)
}
}
开发者ID:superwood,项目名称:reborn,代码行数:7,代码来源:topology.go
示例20: startStatusHTTP
func (s *Server) startStatusHTTP() {
once.Do(func() {
go func() {
http.HandleFunc("/status", func(w http.ResponseWriter, req *http.Request) {
w.Header().Set("Content-Type", "application/json")
s := status{
Connections: s.ConnectionCount(),
Version: mysql.ServerVersion,
GitHash: printer.TiDBGitHash,
}
js, err := json.Marshal(s)
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
log.Error("Encode json error", err)
} else {
w.Write(js)
}
})
// HTTP path for prometheus.
http.Handle("/metrics", prometheus.Handler())
addr := s.cfg.StatusAddr
if len(addr) == 0 {
addr = defaultStatusAddr
}
log.Infof("Listening on %v for status and metrics report.", addr)
err := http.ListenAndServe(addr, nil)
if err != nil {
log.Fatal(err)
}
}()
})
}
开发者ID:pingcap,项目名称:tidb,代码行数:33,代码来源:server.go
注:本文中的github.com/ngaut/log.Fatal函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论