libf 3 月之前
父節點
當前提交
7a8208a683
共有 6 個文件被更改,包括 26 次插入25 次删除
  1. 1 1
      context/context_test.go
  2. 1 1
      dfstest/dfstest.go
  3. 1 1
      grpc-odbserver/main.go
  4. 2 2
      ping/ping.go
  5. 2 2
      ping/probing/cfglog.go
  6. 19 18
      ping/utils/utils.go

+ 1 - 1
context/context_test.go

@@ -6,7 +6,7 @@ import (
 	"testing"
 	"testing"
 	"time"
 	"time"
 
 
-	"git.wecise.com/wecise/common/logger"
+	"github.com/wecisecode/util/logger
 )
 )
 
 
 func TestContext(t *testing.T) {
 func TestContext(t *testing.T) {

+ 1 - 1
dfstest/dfstest.go

@@ -17,7 +17,7 @@ import (
 	"git.wecise.com/wecise/common/cassandra"
 	"git.wecise.com/wecise/common/cassandra"
 	"git.wecise.com/wecise/common/dfs"
 	"git.wecise.com/wecise/common/dfs"
 	"git.wecise.com/wecise/common/etcd"
 	"git.wecise.com/wecise/common/etcd"
-	"git.wecise.com/wecise/common/matrix/logger"
+	"github.com/wecisecode/util/logger"
 	"gopkg.in/src-d/go-billy.v4"
 	"gopkg.in/src-d/go-billy.v4"
 )
 )
 
 

+ 1 - 1
grpc-odbserver/main.go

@@ -7,9 +7,9 @@ import (
 	"trial/grpc-odbserver/mnode"
 	"trial/grpc-odbserver/mnode"
 	"trial/grpc-odbserver/msn"
 	"trial/grpc-odbserver/msn"
 
 
-	"git.wecise.com/wecise/common/matrix/logger"
 	"git.wecise.com/wecise/common/matrix/util"
 	"git.wecise.com/wecise/common/matrix/util"
 	z "git.wecise.com/wecise/odbserver/mring/z/m"
 	z "git.wecise.com/wecise/odbserver/mring/z/m"
+	"github.com/wecisecode/util/logger"
 )
 )
 
 
 var _ = z.RunShadowCount(5, 0, 0, -1)
 var _ = z.RunShadowCount(5, 0, 0, -1)

+ 2 - 2
ping/ping.go

@@ -17,10 +17,10 @@ import (
 	"trial/ping/probing/icmp"
 	"trial/ping/probing/icmp"
 	"trial/ping/utils"
 	"trial/ping/utils"
 
 
-	"git.wecise.com/wecise/common/matrix/cfg"
-	"git.wecise.com/wecise/common/matrix/logger"
 	"git.wecise.com/wecise/common/matrix/util"
 	"git.wecise.com/wecise/common/matrix/util"
 	"github.com/scylladb/go-set/strset"
 	"github.com/scylladb/go-set/strset"
+	"github.com/wecisecode/util/cfg"
+	"github.com/wecisecode/util/logger"
 )
 )
 
 
 type task struct {
 type task struct {

+ 2 - 2
ping/probing/cfglog.go

@@ -1,8 +1,8 @@
 package probing
 package probing
 
 
 import (
 import (
-	cfg "git.wecise.com/wecise/common/matrix/cfg"
-	log "git.wecise.com/wecise/common/matrix/logger"
+	cfg "github.com/wecisecode/util/cfg"
+	log "github.com/wecisecode/util/logger"
 )
 )
 
 
 var mcfg = cfg.MConfig()
 var mcfg = cfg.MConfig()

+ 19 - 18
ping/utils/utils.go

@@ -2,16 +2,17 @@ package utils
 
 
 import (
 import (
 	"fmt"
 	"fmt"
-	"git.wecise.com/wecise/common/logger"
-	"io/ioutil"
+	"github.com/wecisecode/util/logger
 	"os"
 	"os"
 	"strings"
 	"strings"
 	"sync"
 	"sync"
 	"time"
 	"time"
+
+	"github.com/wecisecode/util/logger"
 )
 )
 
 
 var (
 var (
-	dataStats = make(map[string]*DataStat) // <title-name>:DataStat
+	dataStats   = make(map[string]*DataStat) // <title-name>:DataStat
 	dataStatsMu sync.Mutex
 	dataStatsMu sync.Mutex
 )
 )
 
 
@@ -56,7 +57,7 @@ type DataStat struct {
 func NewDataStat(title, name string, interval int, chanSize int) *DataStat {
 func NewDataStat(title, name string, interval int, chanSize int) *DataStat {
 	dataStatsMu.Lock()
 	dataStatsMu.Lock()
 	defer dataStatsMu.Unlock()
 	defer dataStatsMu.Unlock()
-	key := title+"-"+name
+	key := title + "-" + name
 	if ds, ok := dataStats[key]; ok {
 	if ds, ok := dataStats[key]; ok {
 		if ds.statChan != nil {
 		if ds.statChan != nil {
 			close(ds.statChan)
 			close(ds.statChan)
@@ -103,9 +104,9 @@ func (ds *DataStat) Close() {
 }
 }
 
 
 func (ds *DataStat) Start() {
 func (ds *DataStat) Start() {
-	tc := time.NewTicker(time.Duration(ds.Interval)*time.Second)
+	tc := time.NewTicker(time.Duration(ds.Interval) * time.Second)
 	startTime := time.Now()
 	startTime := time.Now()
-	ds.StartTime = startTime.UnixNano()/int64(time.Millisecond)
+	ds.StartTime = startTime.UnixNano() / int64(time.Millisecond)
 	ds.running = true
 	ds.running = true
 	defer func() {
 	defer func() {
 		ds.running = false
 		ds.running = false
@@ -113,30 +114,30 @@ func (ds *DataStat) Start() {
 L:
 L:
 	for {
 	for {
 		select {
 		select {
-		case <- tc.C:
+		case <-tc.C:
 			now := time.Now()
 			now := time.Now()
-			speed := float64(ds.Success + ds.Fail + ds.Ignore) / now.Sub(startTime).Seconds()
+			speed := float64(ds.Success+ds.Fail+ds.Ignore) / now.Sub(startTime).Seconds()
 			startTime = now
 			startTime = now
 			logger.Infof("Stat %s %s: success:%d fail:%d ignore:%d within %ds, total success:%d total fail:%d total ignore:%d speed:%.1f/s.\n", ds.title, ds.name, ds.Success, ds.Fail, ds.Ignore, ds.Interval, ds.TotalSuccess, ds.TotalFail, ds.TotalIgnore, speed)
 			logger.Infof("Stat %s %s: success:%d fail:%d ignore:%d within %ds, total success:%d total fail:%d total ignore:%d speed:%.1f/s.\n", ds.title, ds.name, ds.Success, ds.Fail, ds.Ignore, ds.Interval, ds.TotalSuccess, ds.TotalFail, ds.TotalIgnore, speed)
-			ds.StatTime = now.UnixNano()/int64(time.Millisecond)
+			ds.StatTime = now.UnixNano() / int64(time.Millisecond)
 			ds.Success = 0
 			ds.Success = 0
 			ds.Fail = 0
 			ds.Fail = 0
 			ds.Ignore = 0
 			ds.Ignore = 0
-		case n, ok := <- ds.statChan:
+		case n, ok := <-ds.statChan:
 			if !ok {
 			if !ok {
 				break L
 				break L
 			}
 			}
-			ds.LastTime = time.Now().UnixNano()/int64(time.Millisecond)
+			ds.LastTime = time.Now().UnixNano() / int64(time.Millisecond)
 			switch n {
 			switch n {
 			case 0:
 			case 0:
-				ds.Success ++
-				ds.TotalSuccess ++
+				ds.Success++
+				ds.TotalSuccess++
 			case 1:
 			case 1:
-				ds.Fail ++
-				ds.TotalFail ++
+				ds.Fail++
+				ds.TotalFail++
 			case 2:
 			case 2:
-				ds.Ignore ++
-				ds.TotalIgnore ++
+				ds.Ignore++
+				ds.TotalIgnore++
 			}
 			}
 		}
 		}
 	}
 	}
@@ -188,4 +189,4 @@ func (ds *DataStat) GetName() string {
 //			}
 //			}
 //		}
 //		}
 //	}
 //	}
-//}
+//}