本文整理匯總了Golang中github.com/ngaut/log.Warningf函數的典型用法代碼示例。如果您正苦於以下問題:Golang Warningf函數的具體用法?Golang Warningf怎麽用?Golang Warningf使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Warningf函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: doWatch
func (top *Topology) doWatch(evtch <-chan topo.Event, evtbus chan interface{}) {
e := <-evtch
log.Warningf("topo event %+v", e)
switch e.Type {
//case topo.EventNodeCreated:
//case topo.EventNodeDataChanged:
case topo.EventNodeChildrenChanged: //only care children changed
// TODO: get changed node and decode event
default:
log.Warningf("%+v", e)
}
evtbus <- e
}
示例2: handleComStmtPrepare
func (c *Session) handleComStmtPrepare(sqlstmt string) error {
stmt, err := parser.Parse(sqlstmt)
if err != nil {
log.Warningf(`parse sql "%s" error "%s"`, sqlstmt, err.Error())
return c.handleMySQLError(
mysql.NewDefaultError(mysql.ER_SYNTAX_ERROR, err.Error()))
}
// Only a few statements supported by prepare statements
// http://dev.mysql.com/worklog/task/?id=2871
switch v := stmt.(type) {
case parser.ISelect, *parser.Insert, *parser.Update, *parser.Delete,
*parser.Replace,
parser.IDDLStatement,
*parser.ShowTables,
*parser.ShowColumns,
*parser.ShowVariables,
*parser.ShowIndex,
*parser.Set,
*parser.DescribeTable,
*parser.Do:
return c.prepare(v, sqlstmt)
default:
log.Warnf("statement %T[%s] not support prepare ops", stmt, sqlstmt)
return c.handleMySQLError(
mysql.NewDefaultError(mysql.ER_UNSUPPORTED_PS))
}
}
示例3: run
func (h *Handler) run() error {
log.Infof("open listen address '%s' and start service", h.l.Addr())
for {
if nc, err := h.l.Accept(); err != nil {
return errors.Trace(err)
} else {
h.counters.clientsAccepted.Add(1)
go func() {
h.counters.clients.Add(1)
defer h.counters.clients.Sub(1)
c := newConn(nc, h, h.config.ConnTimeout)
log.Infof("new connection: %s", c)
if err := c.serve(h); err != nil {
if errors.Cause(err) == io.EOF {
log.Infof("connection lost: %s [io.EOF]", c)
} else {
log.Warningf("connection lost: %s, err = %s", c, err)
}
} else {
log.Infof("connection exit: %s", c)
}
}()
}
}
return nil
}
示例4: SlotsRestore
// SLOTSRESTORE key ttlms value [key ttlms value ...]
func (s *Store) SlotsRestore(db uint32, args [][]byte) error {
if len(args) == 0 || len(args)%3 != 0 {
return errArguments("len(args) = %d, expect != 0 && mod 3 = 0", len(args))
}
objs := make([]*rdb.ObjEntry, len(args)/3)
for i := 0; i < len(objs); i++ {
key := args[i*3]
ttlms, err := ParseInt(args[i*3+1])
if err != nil {
return errArguments("parse args failed - %s", err)
}
value := args[i*3+2]
expireat := int64(0)
if ttlms != 0 {
if v, ok := TTLmsToExpireAt(ttlms); ok && v > 0 {
expireat = v
} else {
return errArguments("parse args[%d] ttlms = %d", i*3+1, ttlms)
}
}
obj, err := rdb.DecodeDump(value)
if err != nil {
return errArguments("decode args[%d] failed, %s", i*3+2, err)
}
objs[i] = &rdb.ObjEntry{
DB: db,
Key: key,
ExpireAt: uint64(expireat),
Value: obj,
}
}
if err := s.acquire(); err != nil {
return errors.Trace(err)
}
defer s.release()
ms := &markSet{}
bt := engine.NewBatch()
for i := len(objs) - 1; i >= 0; i-- {
e := objs[i]
if ms.Has(e.Key) {
log.Debugf("[%d] restore batch, db = %d, key = %v, ignore", i, e.DB, e.Key)
continue
} else {
log.Debugf("[%d] restore batch, db = %d, key = %v", i, e.DB, e.Key)
}
if err := s.restore(bt, e.DB, e.Key, int64(e.ExpireAt), e.Value); err != nil {
log.Warningf("restore object failed, db = %d, key = %v, err = %s", e.DB, e.Key, err)
return errors.Trace(err)
}
ms.Set(e.Key)
}
fw := &Forward{DB: db, Op: "SlotsRestore", Args: args}
return s.commit(bt, fw)
}
示例5: travelPostCommitHandlers
func (s *Store) travelPostCommitHandlers(f *Forward) {
for _, h := range s.postCommitHandlers {
if err := h(f); err != nil {
log.Warningf("handle DidCommitHandler err - %s", err)
}
}
}
示例6: handleRequest
func (c *conn) handleRequest(h *Handler) (redis.Resp, error) {
if c.timeout > 0 {
deadline := time.Now().Add(c.timeout)
if err := c.nc.SetReadDeadline(deadline); err != nil {
return nil, errors.Trace(err)
}
}
request, err := redis.DecodeRequest(c.r)
if err != nil {
return nil, errors.Trace(err)
}
if request.Type() == redis.TypePing {
return nil, nil
}
h.counters.commands.Add(1)
response, err := c.dispatch(h, request)
if err != nil {
h.counters.commandsFailed.Add(1)
b, _ := redis.EncodeToBytes(request)
log.Warningf("handle commands failed, conn = %s, request = '%s', err = %s", c, base64.StdEncoding.EncodeToString(b), err)
}
return response, nil
}
示例7: Interrupt
// Interrupt releases a lock that's held.
func (zm *zMutex) Interrupt() {
select {
case zm.interrupted <- struct{}{}:
default:
log.Warningf("zmutex interrupt blocked")
}
}
示例8: Do
func (c *conn) Do(cmd *redis.Array, timeout time.Duration) (redis.Resp, error) {
if c.err != nil {
return nil, errors.Trace(c.err)
}
if err := c.encodeResp(cmd, timeout); err != nil {
c.err = err
log.Warningf("encode resp failed - %s", err)
return nil, errors.Trace(c.err)
}
if rsp, err := c.decodeResp(timeout); err != nil {
c.err = err
log.Warningf("decode resp failed - %s", err)
return nil, errors.Trace(c.err)
} else {
c.last = time.Now()
return rsp, nil
}
}
示例9: doMigrate
func doMigrate(addr string, timeout time.Duration, db uint32, bins []*rdb.BinEntry) error {
c, err := getSockConn(addr, timeout)
if err != nil {
log.Warningf("connect to %s failed, timeout = %d, err = %s", addr, timeout, err)
return errors.Trace(err)
}
defer putSockConn(addr, c)
cmd1 := redis.NewArray()
cmd1.AppendBulkBytes([]byte("select"))
cmd1.AppendBulkBytes([]byte(FormatUint(uint64(db))))
if err := c.DoMustOK(cmd1, timeout); err != nil {
log.Warningf("command select failed, addr = %s, db = %d, err = %s", addr, db, err)
return errors.Trace(err)
}
log.Debugf("command select ok, addr = %s, db = %d, err = %s", addr, db, err)
cmd2 := redis.NewArray()
cmd2.AppendBulkBytes([]byte("slotsrestore"))
for _, bin := range bins {
cmd2.AppendBulkBytes(bin.Key)
ttlms := int64(0)
if bin.ExpireAt != 0 {
if v, ok := ExpireAtToTTLms(int64(bin.ExpireAt)); ok && v > 0 {
ttlms = v
} else {
ttlms = 1
}
}
cmd2.AppendBulkBytes([]byte(FormatInt(ttlms)))
cmd2.AppendBulkBytes(bin.Value)
}
if err := c.DoMustOK(cmd2, timeout); err != nil {
log.Warningf("command restore failed, addr = %s, db = %d, len(bins) = %d, err = %s", addr, db, len(bins), err)
return errors.Trace(err)
} else {
log.Debugf("command restore ok, addr = %s, db = %d, len(bins) = %d", addr, db, len(bins))
return nil
}
}
示例10: loadSavedProcs
func loadSavedProcs() error {
files, err := ioutil.ReadDir(baseProcDataDir())
if err != nil {
return errors.Trace(err)
}
for _, f := range files {
if !f.IsDir() {
continue
}
baseName := path.Base(f.Name())
tp, id, ok := getPathType(baseName)
if !ok {
continue
}
datFile := path.Join(baseProcDataDir(), baseName, fmt.Sprintf("%s.dat", tp))
if p, err := loadProcess(datFile); err != nil {
log.Warningf("load process data %s err %v, skip", dataDir, err)
continue
} else if p == nil {
log.Infof("proc %s has no need to be reload, skip", id)
continue
} else {
if id != p.ID {
log.Warningf("we need proc %s, but got %s", id, p.ID)
continue
}
// TODO: bind after start func for different type
if err := bindProcHandler(p); err != nil {
log.Errorf("bind proc %s err %v, skip", p.Cmd, err)
continue
}
addCheckProc(p)
}
}
return nil
}
示例11: putSockConn
func putSockConn(addr string, c *conn) {
if c.err != nil {
c.sock.Close()
log.Warningf("close error connection %s : %s - err = %s", addr, c, c.err)
} else {
poolmap.Lock()
pool := poolmap.m[addr]
if pool == nil {
pool = list.New()
poolmap.m[addr] = pool
}
c.last = time.Now()
pool.PushFront(c)
poolmap.Unlock()
}
}
示例12: checkAlive
func (p *process) checkAlive() (bool, error) {
proc, err := ps.FindProcess(p.Pid)
if err != nil {
return false, errors.Trace(err)
} else if proc == nil {
// proc is not alive
return false, nil
} else {
if strings.Contains(proc.Executable(), p.Cmd) {
return true, nil
} else {
log.Warningf("pid %d exits, but exeutable name is %s, not %s", p.Pid, proc.Executable(), p.Cmd)
return false, nil
}
}
}
示例13: OnSlotRangeChange
func (s *Server) OnSlotRangeChange(param *models.SlotMultiSetParam) {
log.Warningf("slotRangeChange %+v", param)
if !validSlot(param.From) || !validSlot(param.To) {
log.Errorf("invalid slot number, %+v", param)
return
}
for i := param.From; i <= param.To; i++ {
switch param.Status {
case models.SLOT_STATUS_OFFLINE:
s.clearSlot(i)
case models.SLOT_STATUS_ONLINE:
s.fillSlot(i, true)
default:
log.Errorf("can not handle status %v", param.Status)
}
}
}
示例14: checkProcs
func checkProcs() {
restartProcs := []*process{}
m.Lock()
for _, p := range procs {
if b, err := p.checkAlive(); err != nil {
log.Errorf("check %d (%s) alive err %v, retry later", p.Pid, p.Cmd, err)
} else if !b {
needRestart := p.needRestart()
log.Warningf("%d (%s) is not alive, need restart: %v", p.Pid, p.Cmd, needRestart)
if needRestart {
restartProcs = append(restartProcs, p)
}
// clear old log
p.clearLog()
// remove from procs
delete(procs, p.ID)
}
}
m.Unlock()
for _, p := range restartProcs {
switch strings.ToLower(p.Type) {
case proxyType:
// for proxy type, we will use a new id to avoid zk node exists error
args := new(proxyArgs)
map2Args(args, p.Ctx)
p.clearData()
startProxy(args)
default:
if err := p.start(); err != nil {
log.Errorf("restart %s err %v", p.Cmd, err)
} else {
addCheckProc(p)
}
}
}
}
示例15: comQuery
func (c *Session) comQuery(sqlstmt string) error {
stmt, err := parser.Parse(sqlstmt)
if err != nil {
log.Warningf(`parse sql "%s" error "%s"`, sqlstmt, err.Error())
return c.handleMySQLError(
NewDefaultError(ER_SYNTAX_ERROR, err.Error()))
}
switch v := stmt.(type) {
case parser.ISelect:
return c.handleQuery(v, sqlstmt)
case *parser.Insert, *parser.Update, *parser.Delete, *parser.Replace:
return c.handleExec(stmt, sqlstmt, false)
case *parser.Set:
return c.handleSet(v, sqlstmt)
case *parser.Begin, *parser.StartTrans:
return c.handleBegin()
case *parser.Commit:
return c.handleCommit()
case *parser.Rollback:
return c.handleRollback()
case parser.IShow:
return c.handleShow(sqlstmt, v)
case parser.IDDLStatement:
return c.handleDDL(v, sqlstmt)
case *parser.Do, *parser.Call, *parser.FlushTables:
return c.handleExec(stmt, sqlstmt, false)
case *parser.Use:
if err := c.useDB(hack.String(stmt.(*parser.Use).DB)); err != nil {
return c.handleMySQLError(err)
} else {
return c.fc.WriteOK(nil)
}
default:
log.Warnf("statement %T[%s] not support now", stmt, sqlstmt)
return nil
}
return nil
}