本文整理汇总了Golang中github.com/ngaut/log.Warn函数的典型用法代码示例。如果您正苦于以下问题:Golang Warn函数的具体用法?Golang Warn怎么用?Golang Warn使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Warn函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: handleConnection
func (tso *TimestampOracle) handleConnection(s *session) {
defer func() {
tso.connLock.Lock()
delete(tso.conns, s.conn)
tso.connLock.Unlock()
s.conn.Close()
tso.wg.Done()
}()
var buf [1]byte
for {
_, err := s.r.Read(buf[:])
if err != nil {
log.Warn(err)
return
}
resp := tso.getRespTS()
resp.Encode(s.w)
if s.r.Buffered() <= 0 {
err = s.w.Flush()
if err != nil {
log.Warn(err)
return
}
}
}
}
开发者ID:siddontang,项目名称:tso,代码行数:30,代码来源:server.go
示例2: mustNewConn
func mustNewConn(urls []string, quit chan struct{}) *conn {
for {
conn, err := rpcConnectLeader(urls)
if err == nil {
return newConn(conn)
}
log.Warn(err)
conn, err = rpcConnect(urls)
if err == nil {
c := newConn(conn)
c.wg.Add(1)
go c.connectLeader(urls, reconnectPDTimeout)
return c
}
log.Warn(err)
select {
case <-time.After(connectPDTimeout):
break
case <-quit:
return nil
}
}
}
开发者ID:jmptrader,项目名称:tidb,代码行数:25,代码来源:conn.go
示例3: HandleMessage
func (this *NSQDataStream) HandleMessage(message *nsq.Message) error {
data := string(message.Body)
if data == "" {
log.Warn("数据丢失")
return nil
}
data = encrypt.GetEnDecoder(encrypt.TYPE_BASE64).Decode(data)
urlData, err := url.ParseQuery(data)
if err != nil {
log.Warn("解析数据失败")
return nil
}
//数据存放在队列中
if urlData.Get("date") != time.Now().Format("2006-01-02") {
return nil
}
this.Dispatch(urlData)
r := rand.New(rand.NewSource(time.Now().UnixNano()))
_ = time.Millisecond * time.Duration(r.Intn(1000)+200)
time.Sleep(time.Microsecond)
return nil
}
开发者ID:qgweb,项目名称:new,代码行数:27,代码来源:ds.go
示例4: handleConnection
func (tso *TimestampOracle) handleConnection(s *session) {
defer func() {
tso.closeConn(s.conn)
tso.wg.Done()
}()
var buf [1]byte
for {
_, err := s.r.Read(buf[:])
if err != nil {
log.Warn(err)
return
}
resp := tso.getRespTS()
if resp == nil {
log.Errorf("get repsone timestamp timeout, close %v", s.conn.RemoteAddr())
return
}
resp.Encode(s.w)
if s.r.Buffered() <= 0 {
err = s.w.Flush()
if err != nil {
log.Warn(err)
return
}
}
}
}
开发者ID:pingcap,项目名称:tso,代码行数:31,代码来源:server.go
示例5: watchLeader
func (c *client) watchLeader(leaderPath string, revision int64) {
defer c.wg.Done()
WATCH:
for {
log.Infof("[pd] start watch pd leader on path %v, revision %v", leaderPath, revision)
rch := c.etcdClient.Watch(context.Background(), leaderPath, clientv3.WithRev(revision))
select {
case resp := <-rch:
if resp.Canceled {
log.Warn("[pd] leader watcher canceled")
continue WATCH
}
leaderAddr, rev, err := getLeader(c.etcdClient, leaderPath)
if err != nil {
log.Warn(err)
continue WATCH
}
log.Infof("[pd] found new pd-server leader addr: %v", leaderAddr)
c.workerMutex.Lock()
c.worker.stop(errors.New("[pd] leader change"))
c.worker = newRPCWorker(leaderAddr, c.clusterID)
c.workerMutex.Unlock()
revision = rev
case <-c.quit:
return
}
}
}
开发者ID:yubobo,项目名称:tidb,代码行数:28,代码来源:client.go
示例6: TestAsyncCommit
func (s *TransactionTestSuit) TestAsyncCommit(c *C) {
conf := defaultTxnConf
conf.brokenCommitSecondaryTest = true
tx := newTxn(s.cli, conf)
// simulating broken commit
for i := 0; i < 10; i++ {
p := hbase.NewPut([]byte(fmt.Sprintf("test_%d", i)))
p.AddValue(cf, q, []byte(fmt.Sprintf("%d", tx.(*themisTxn).GetStartTS())))
tx.Put(themisTestTableName, p)
}
err := tx.Commit()
c.Assert(err, Equals, nil)
// wait until lock expired.
log.Warn("Wait for lock expired. Sleep...")
tick := 6
for tick > 0 {
time.Sleep(1 * time.Second)
tick--
log.Infof("remain %ds...", tick)
}
log.Warn("Try commit again")
// new transction will not see lock
for {
tx = newTxn(s.cli, defaultTxnConf)
for i := 0; i < 5; i++ {
p := hbase.NewPut([]byte(fmt.Sprintf("test_%d", i)))
p.AddValue(cf, q, []byte(fmt.Sprintf("%d", tx.(*themisTxn).GetStartTS())))
tx.Put(themisTestTableName, p)
}
err = tx.Commit()
if err == nil || !errorEqual(err, ErrRetryable) {
break
}
time.Sleep(100 * time.Millisecond)
}
c.Assert(err, Equals, nil)
for {
tx = newTxn(s.cli, defaultTxnConf)
for i := 5; i < 10; i++ {
p := hbase.NewPut([]byte(fmt.Sprintf("test_%d", i)))
p.AddValue(cf, q, []byte(fmt.Sprintf("%d", tx.(*themisTxn).GetStartTS())))
tx.Put(themisTestTableName, p)
}
err = tx.Commit()
if err == nil || !errorEqual(err, ErrRetryable) {
break
}
time.Sleep(100 * time.Millisecond)
}
c.Assert(err, Equals, nil)
}
开发者ID:pingcap,项目名称:go-themis,代码行数:55,代码来源:txn_test.go
示例7: updateTimestamp
func (tso *TimestampOracle) updateTimestamp() error {
prev := tso.ts.Load().(*atomicObject)
now := time.Now()
// ms
since := now.Sub(prev.physical).Nanoseconds() / 1e6
if since > 2*updateTimestampStep {
log.Warnf("clock offset: %v, prev: %v, now %v", since, prev.physical, now)
}
// Avoid the same physical time stamp
if since <= 0 {
log.Warn("invalid physical time stamp, re-update later again")
return nil
}
if now.Sub(tso.lastSavedTime).Nanoseconds()/1e6 > tso.cfg.SaveInterval {
if err := tso.saveTimestamp(now); err != nil {
return errors.Trace(err)
}
}
current := &atomicObject{
physical: now,
}
tso.ts.Store(current)
return nil
}
开发者ID:pingcap,项目名称:tso,代码行数:28,代码来源:server.go
示例8: batchCommitSecondary
func (txn *themisTxn) batchCommitSecondary(wait bool) error {
//will batch commit all rows in a region
rsRowMap, err := txn.groupByRegion()
if err != nil {
return errors.Trace(err)
}
wg := sync.WaitGroup{}
for _, regionRowMap := range rsRowMap {
wg.Add(1)
_, firstRowM := getFirstEntity(regionRowMap)
go func(cli *themisRPC, tbl string, rMap map[string]*rowMutation, startTs, commitTs uint64) {
defer wg.Done()
err := cli.batchCommitSecondaryRows([]byte(tbl), rMap, startTs, commitTs)
if err != nil {
// fail of secondary commit will not stop the commits of next
// secondaries
if isWrongRegionErr(err) {
txn.client.CleanAllRegionCache()
log.Warn("region info outdated when committing secondary rows, don't panic")
}
}
}(txn.rpc, string(firstRowM.tbl), regionRowMap, txn.startTs, txn.commitTs)
}
if wait {
wg.Wait()
}
return nil
}
开发者ID:pingcap,项目名称:go-themis,代码行数:29,代码来源:themis_txn.go
示例9: NewServer
func NewServer(cfg *config.Conf) (*Server, error) {
s := new(Server)
s.cfg = cfg
var err error
s.fingerprints = make(map[string]*LimitReqNode)
// s.users = make(map[string]*User)
// s.qpsOnServer = &LimitReqNode{}
s.mu = &sync.Mutex{}
s.restart = false
port := s.cfg.GetConfig().Global.Port
// get listenfd from file when restart
if os.Getenv("_GRACEFUL_RESTART") == "true" {
log.Info("graceful restart with previous listenfd")
//get the linstenfd
file := os.NewFile(3, "")
s.listener, err = net.FileListener(file)
if err != nil {
log.Warn("get linstener err ")
}
} else {
s.listener, err = net.Listen("tcp4", fmt.Sprintf(":%d", port))
}
if err != nil {
return nil, err
}
log.Infof("Dbatman Listen(tcp4) at [%d]", port)
return s, nil
}
开发者ID:bytedance,项目名称:dbatman,代码行数:35,代码来源:server.go
示例10: extractLockInfoFromKeyErr
func extractLockInfoFromKeyErr(keyErr *pb.KeyError) (*pb.LockInfo, error) {
if locked := keyErr.GetLocked(); locked != nil {
return locked, nil
}
if keyErr.Retryable != nil {
err := errors.Errorf("tikv restarts txn: %s", keyErr.GetRetryable())
log.Warn(err)
return nil, errors.Annotate(err, txnRetryableMark)
}
if keyErr.Abort != nil {
err := errors.Errorf("tikv aborts txn: %s", keyErr.GetAbort())
log.Warn(err)
return nil, errors.Trace(err)
}
return nil, errors.Errorf("unexpected KeyError: %s", keyErr.String())
}
开发者ID:yubobo,项目名称:tidb,代码行数:16,代码来源:snapshot.go
示例11: updateTicker
func (tso *TimestampOracle) updateTicker() {
// TODO: save latest TS to persistent storage(zookeeper/etcd...)
for {
select {
case <-tso.ticker.C:
prev := tso.ts.Load().(*atomicObject)
now := time.Now()
// ms
since := now.Sub(prev.physical).Nanoseconds() / 1e6
if since > 2*updateTimtestampStep {
log.Warnf("clock offset: %v, prev:%v, now %v", since, prev.physical, now)
}
// Avoid the same physical time stamp
if since <= 0 {
log.Warn("invalid physical time stamp")
continue
}
current := &atomicObject{
physical: now,
}
tso.ts.Store(current)
}
}
}
开发者ID:siddontang,项目名称:tso,代码行数:26,代码来源:server.go
示例12: Run
func (session *Session) Run() error {
for {
data, err := session.fc.ReadPacket()
if err != nil {
log.Warn(err)
return err
}
if data[0] == ComQuit {
return errSessionQuit
}
if err := session.dispatch(data); err != nil {
if err == driver.ErrBadConn {
// TODO handle error
}
log.Warnf("dispatch error: %s", err.Error())
return err
}
session.fc.ResetSequence()
if session.closed {
// TODO return MySQL Go Away ?
return errors.New("session closed!")
}
}
return nil
}
开发者ID:wangjild,项目名称:dbatman,代码行数:34,代码来源:session.go
示例13: Dispatch
func (this *NSQDataStream) Dispatch(data url.Values) {
var (
uidsAry = strings.Split(data.Get("uids"), ",")
info = make(map[string]interface{})
ginfoAry = this.GrabData(uidsAry)
)
data.Set("ua", encrypt.DefaultBase64.Decode(data.Get("ua")))
for k, _ := range data {
info[k] = data.Get(k)
}
if len(ginfoAry) == 0 {
return
}
info["ginfos"] = ginfoAry
j, err := json.Marshal(&info)
if err != nil {
log.Warn(err)
return
}
go this.Save(j)
}
开发者ID:qgweb,项目名称:new,代码行数:27,代码来源:ds.go
示例14: cleanupPending
func (c *Client) cleanupPending(err error) {
log.Warn(err)
length := c.pending.Len()
for i := 0; i < length; i++ {
e := c.pending.Front()
c.pending.Remove(e)
e.Value.(*PipelineRequest).MarkDone(nil, err)
}
}
开发者ID:yzl11,项目名称:vessel,代码行数:9,代码来源:client.go
示例15: workerLoop
func (c *Client) workerLoop() {
for {
err := c.do()
if err != nil {
log.Warn(err)
}
time.Sleep(time.Second)
}
}
开发者ID:disksing,项目名称:tso,代码行数:9,代码来源:client.go
示例16: Save
func (this *NSQDataStream) Save(data []byte) {
err := this.nsqproducer.Ping()
if err != nil {
log.Warn("无法和nsq通讯,错误信息为:", err)
return
}
err = this.nsqproducer.Publish(this.config.SendKey, data)
if err != nil {
log.Warn("推送数据失败,错误信息为:", err)
}
//数据冗余处理(临时)
err = this.nsqproducer.Publish(this.config.SendKey+"_es", data)
if err != nil {
log.Warn("推送数据失败,错误信息为:", err)
}
}
开发者ID:qgweb,项目名称:new,代码行数:18,代码来源:ds.go
示例17: SetUpSuite
func (s *TransactionTestSuit) SetUpSuite(c *C) {
var err error
s.cli, err = createHBaseClient()
c.Assert(err, Equals, nil)
log.Warn("new test, reset tables")
err = createNewTableAndDropOldTable(s.cli, themisTestTableName, string(cf), nil)
c.Assert(err, IsNil)
}
开发者ID:yzl11,项目名称:vessel,代码行数:9,代码来源:txn_test.go
示例18: watchLeader
func (c *client) watchLeader(leaderPath string, revision int64) {
defer c.wg.Done()
for {
log.Infof("[pd] start watch pd leader on path %v, revision %v", leaderPath, revision)
ctx, cancel := context.WithTimeout(c.etcdClient.Ctx(), defaultWatchLeaderTimeout)
rch := c.etcdClient.Watch(ctx, leaderPath, clientv3.WithRev(revision))
for resp := range rch {
if resp.Canceled {
log.Warn("[pd] leader watcher canceled")
break
}
// We don't watch any changed, no need to check leader again.
if len(resp.Events) == 0 {
break
}
leaderAddr, rev, err := getLeader(c.etcdClient, leaderPath)
if err != nil {
log.Warn(err)
break
}
log.Infof("[pd] found new pd-server leader addr: %v", leaderAddr)
c.workerMutex.Lock()
c.worker.stop(errors.New("[pd] leader change"))
c.worker = newRPCWorker(leaderAddr, c.clusterID)
c.workerMutex.Unlock()
revision = rev
}
cancel()
select {
case <-c.quit:
return
default:
}
}
}
开发者ID:yangxuanjia,项目名称:tidb,代码行数:42,代码来源:client.go
示例19: NewShPut
func NewShPut() *ShPut {
var sh = &ShPut{}
sh.kf = dbfactory.NewKVFile(fmt.Sprintf("./%s.txt", convert.ToString(time.Now().Unix())))
sh.putTags = make(map[string]map[string]int)
sh.Timestamp = timestamp.GetDayTimestamp(-1)
sh.initPutAdverts()
sh.initPutTags("TAGS_3*", "tb_", "mg_")
sh.initPutTags("TAGS_5*", "url_", "")
log.Warn(sh.putAdverts)
return sh
}
开发者ID:qgweb,项目名称:new,代码行数:11,代码来源:sh.go
示例20: doSend
func (c *rpcClient) doSend(conn net.Conn, msg *msgpb.Message) error {
curMsgID := atomic.AddUint64(&c.msgID, 1)
log.Debugf("Send request msgID[%d] type[%v]", curMsgID, msg.GetMsgType())
if err := conn.SetWriteDeadline(time.Now().Add(writeTimeout)); err != nil {
log.Warn("Set write deadline failed, it may be blocked.")
}
if err := util.WriteMessage(conn, curMsgID, msg); err != nil {
return errors.Trace(err)
}
if err := conn.SetReadDeadline(time.Now().Add(readTimeout)); err != nil {
log.Warn("Set read deadline failed, it may be blocked.")
}
msgID, err := util.ReadMessage(conn, msg)
if err != nil {
return errors.Trace(err)
}
if curMsgID != msgID {
log.Errorf("Sent msgID[%d] mismatches recv msgID[%d]", curMsgID, msgID)
}
log.Debugf("Receive response msgID[%d] type[%v]", msgID, msg.GetMsgType())
return nil
}
开发者ID:anywhy,项目名称:tidb,代码行数:22,代码来源:client.go
注:本文中的github.com/ngaut/log.Warn函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论