From 777a8596657cb5512b2ef7571cb70a7ebf5ae35b Mon Sep 17 00:00:00 2001 From: Yijun Zhao Date: Tue, 26 May 2020 15:33:36 +0800 Subject: [PATCH] Merge master (#37) --- .github/workflows/go.yml | 33 +++++++++++++++++++++++++++++++++ .travis.yml | 30 ------------------------------ Makefile | 1 - README.md | 6 ++++-- go.mod | 7 +++---- go.sum | 20 ++++++-------------- loghub/analysislog.go | 8 ++++---- memcache/server.go | 4 ++-- store/bucket.go | 8 +++++--- 9 files changed, 57 insertions(+), 60 deletions(-) create mode 100644 .github/workflows/go.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml new file mode 100644 index 0000000..a6e1d3a --- /dev/null +++ b/.github/workflows/go.yml @@ -0,0 +1,33 @@ +on: [push, pull_request] +name: GoBeansDB Test +jobs: + test: + strategy: + matrix: + compiler: [gcc] + go-version: [1.12.x, 1.13.x] + platform: [ubuntu-latest, macos-latest] + runs-on: ${{ matrix.platform }} + steps: + - name: Install Go + uses: actions/setup-go@v1 + with: + go-version: ${{ matrix.go-version }} + + - name: Checkout code + uses: actions/checkout@v1 + + - name: Get test tools + run: go get -u -v golang.org/x/tools/cmd/goimports + + - name: Test + env: + CC: ${{ matrix.compiler }} + run: | + export PATH=${PATH}:`go env GOPATH`/bin + diff <(goimports -d .) <(printf "") + go mod vendor + make test + + - name: Install + run: make install diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index f8503bd..0000000 --- a/.travis.yml +++ /dev/null @@ -1,30 +0,0 @@ -language: go - -os: - - linux - - osx - -go: - - "1.11.x" - - "1.12.x" - - "1.13.x" - -env: - - GO111MODULE=on - -addons: - apt: - packages: - - gcc - -before_install: - - if [[ "TRAVIS_OS_NAME" == "osx" ]]; then brew update ; fi - - if [[ "TRAVIS_OS_NAME" == "osx" ]]; then brew install gcc; fi - -install: - - go get -u golang.org/x/tools/cmd/goimports - -script: - - diff <(goimports -d .) <(printf "") - - make install - - make test diff --git a/Makefile b/Makefile index 711e83a..b677149 100644 --- a/Makefile +++ b/Makefile @@ -12,5 +12,4 @@ pytest:install ./tests/run_test.sh install: - GO111MODULE=on go mod vendor go install ./ diff --git a/README.md b/README.md index b4f9ca4..8f585e8 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ -# GoBeansDB [![Build Status](https://travis-ci.org/douban/gobeansdb.svg?branch=master)](https://travis-ci.org/douban/gobeansdb) [![Release](https://img.shields.io/github/v/release/douban/gobeansdb)](https://github.com/douban/gobeansdb/releases) + +# GoBeansDB ![](https://github.com/douban/gobeansdb/workflows/GoBeansDB%20Test/badge.svg) [![Release](https://img.shields.io/github/v/release/douban/gobeansdb)](https://github.com/douban/gobeansdb/releases) Yet anonther distributed key-value storage system from Douban Inc. @@ -20,6 +21,7 @@ GoBeansDB use `go mod` manage dependencies, please make sure your Go version >= ```shell $ git clone http://github.com/douban/gobeansdb.git $ cd gobeansdb +$ go mod vendor $ make ``` @@ -98,7 +100,7 @@ mc_client --- cache 缺点/注意 1. 一致性支持较弱,时间戳目前是秒级(受限于数据文件格式)。 -2. 全内存索引,有一定内存开销,在启动载入索引略慢(约十几秒到半分钟, 决定于key 数量)。 +2. 全内存索引,有一定内存开销,在启动时载入索引略慢(约十几秒到半分钟, 决定于key 数量)。 3. 数据文件格式的 padding 对小 value 有一定浪费。 diff --git a/go.mod b/go.mod index a4159e3..60c63d6 100644 --- a/go.mod +++ b/go.mod @@ -1,10 +1,9 @@ module github.com/douban/gobeansdb require ( - github.com/samuel/go-zookeeper v0.0.0-20180130194729-c4fab1ac1bec - github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72 - golang.org/x/tools v0.0.0-20191011211836-4c025a95b26e // indirect - gopkg.in/yaml.v2 v2.2.1 + github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da + github.com/spaolacci/murmur3 v1.1.0 + gopkg.in/yaml.v2 v2.2.7 ) go 1.13 diff --git a/go.sum b/go.sum index dee75fa..1513a9c 100644 --- a/go.sum +++ b/go.sum @@ -1,16 +1,8 @@ -github.com/samuel/go-zookeeper v0.0.0-20180130194729-c4fab1ac1bec h1:6ncX5ko6B9LntYM0YBRXkiSaZMmLYeZ/NWcmeB43mMY= -github.com/samuel/go-zookeeper v0.0.0-20180130194729-c4fab1ac1bec/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E= -github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72 h1:qLC7fQah7D6K1B0ujays3HV9gkFtllcxhzImRR7ArPQ= -github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/tools v0.0.0-20191011211836-4c025a95b26e h1:1o2bDs9pCd2xFhdwqJTrCIswAeEsn4h/PCNelWpfcsI= -golang.org/x/tools v0.0.0-20191011211836-4c025a95b26e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da h1:p3Vo3i64TCLY7gIfzeQaUJ+kppEO5WQG3cL8iE8tGHU= +github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E= +github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI= +github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v2 v2.2.1 h1:mUhvW9EsL+naU5Q3cakzfE91YhliOondGd6ZrsDBHQE= -gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.7 h1:VUgggvou5XRW9mHwD/yXxIYSMtY0zoKQf/v226p2nyo= +gopkg.in/yaml.v2 v2.2.7/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/loghub/analysislog.go b/loghub/analysislog.go index 4d7dc92..cf52c5d 100644 --- a/loghub/analysislog.go +++ b/loghub/analysislog.go @@ -19,10 +19,10 @@ type AnalysisLogHub struct { } func init() { - logger := openLogWithFd(os.Stderr, AnalysisLogFlag) - hub := &AnalysisLogHub{logger: logger} - hub.InitBuffer(200) - AnalysisLogger = NewLogger("", hub, DEBUG) + //logger := openLogWithFd(os.Stderr, AnalysisLogFlag) + //hub := &AnalysisLogHub{logger: logger} + //hub.InitBuffer(200) + AnalysisLogger = NewLogger("", nil, DEBUG) } func InitAnalysisLog(path string, level int, bufferSize int) (err error) { diff --git a/memcache/server.go b/memcache/server.go index 96d7714..968c4ca 100644 --- a/memcache/server.go +++ b/memcache/server.go @@ -346,13 +346,13 @@ func (s *Server) HandleSignals(errorlog string, accesslog string, analysislog st // logger.Hub is always inited, so we call Reopen without check it. logger.Hub.Reopen(errorlog) - if accessLogger.Hub != nil { + if accessLogger != nil && accessLogger.Hub != nil { if err := accessLogger.Hub.Reopen(accesslog); err != nil { logger.Warnf("open %s failed: %s", accesslog, err.Error()) } } - if analysisLogger.Hub != nil { + if analysisLogger != nil && analysisLogger.Hub != nil { if err := analysisLogger.Hub.Reopen(analysislog); err != nil { logger.Warnf("open %s failed: %s", analysislog, err.Error()) } diff --git a/store/bucket.go b/store/bucket.go index 67fd1eb..4a6c133 100644 --- a/store/bucket.go +++ b/store/bucket.go @@ -442,9 +442,11 @@ func (bkt *Bucket) get(ki *KeyInfo, memOnly bool) (payload *Payload, pos Positio } else if bytes.Compare(rec.Key, ki.Key) == 0 { payload = rec.Payload payload.Ver = meta.Ver - analysisLogger.Infof("%s %d %f BKT_%02x %d %d %d %v %s", - config.AnalysisLogVersion, rec.Payload.TS, getRecordTimeCost, bkt.ID, - pos.ChunkID, pos.Offset, rec.Payload.RecSize, inbuffer, ki.StringKey) + if analysisLogger != nil && analysisLogger.Hub != nil { + analysisLogger.Infof("%s %d %f BKT_%02x %d %d %d %v %s", + config.AnalysisLogVersion, rec.Payload.TS, getRecordTimeCost, bkt.ID, + pos.ChunkID, pos.Offset, rec.Payload.RecSize, inbuffer, ki.StringKey) + } return } defer func() {