Restructure the codebase to be more idiomatic

pull/743/head
John Shahid 2014-06-27 12:57:06 -04:00
parent 397de00ad2
commit e5276112c1
213 changed files with 307 additions and 318 deletions

27
.gitignore vendored
View File

@ -13,21 +13,21 @@ refresh_tags.sh
a.out
*.test
/src/query/a.out*
/query/a.out*
.DS_Store
# ignore generated files.
src/daemon/version.go
src/parser/lex.yy.c
src/parser/y.tab.h
src/parser/y.tab.c
src/protocol/protocol.pb.go
daemon/version.go
parser/lex.yy.c
parser/y.tab.h
parser/y.tab.c
protocol/protocol.pb.go
build/
# executables
/server
/daemon
/benchmark
/influxdb
/benchmark-tool
/main
/benchmark-storage
godef
@ -36,17 +36,6 @@ gocode
inspect-raft
# dependencies
src/code.google.com/p/log4go
src/code.google.com/p/go.crypto/
/src/code.google.com/p/goplan9/
/src/code.google.com/p/goprotobuf/
/src/code.google.com/p/gogoprotobuf/
/src/code.google.com/p/rog-go/
src/code.google.com/p/go.tools
src/launchpad.net/gocheck/
/src/github.com/nsf/gocode/
/src/github.com/*
!/src/github.com/goraft/
out_rpm/
packages/

View File

@ -56,20 +56,29 @@ export CGO_ENABLED
all: | parser valgrind build test integration_test
parser:
$(MAKE) -C src/parser
$(MAKE) -C parser
GOPATH := $(shell pwd)
ifeq ($(GOPATH),)
GOPATH := $(shell pwd)/../../../..
export GOPATH
endif
uname_S = $(shell sh -c "uname -s 2>/dev/null || echo not")
valgrind:
ifeq ($(uname_S),Linux)
$(MAKE) -C src/parser valgrind
$(MAKE) -C parser valgrind
endif
# packages
packages = admin api/http api/graphite cluster common configuration \
packages_base = admin api/http api/graphite cluster common configuration \
checkers coordinator datastore engine parser protocol wal
build_packages = $(addprefix github.com/influxdb/influxdb/,$(packages_base))
test_packages =
ifneq ($(packages),)
test_packages = $(addprefix github.com/influxdb/influxdb/,$(packages))
else
test_packages = $(build_packages)
endif
# Storage engines libraries
@ -113,11 +122,11 @@ endif
# levigo flags
ifeq ($(uname_S),Linux)
storage_engines += src/$(hyperleveldb_dependency)
storage_engines += $(hyperleveldb_deps)
GO_BUILD_TAGS += hyperleveldb
ifeq ($(rocksdb),yes)
GO_BUILD_TAGS += rocksdb
storage_engines += src/$(rocksdb_dependency)
storage_engines += $(rocksdb_deps)
CGO_CFLAGS += -I$(rocksdb_dir)/include
CGO_LDFLAGS += -L$(rocksdb_dir) -lrocksdb
endif
@ -183,9 +192,6 @@ ifeq ($(uname_S),Linux)
$(MAKE) V=1"
endif
levigo_dependency = github.com/jmhodges/levigo
rocksdb_dependency = github.com/influxdb/rocksdb
hyperleveldb_dependency = github.com/influxdb/hyperleveldb-go
proto_dependency = code.google.com/p/goprotobuf/protoc-gen-go
dependencies = code.google.com/p/go.crypto/bcrypt \
@ -195,47 +201,40 @@ github.com/bmizerany/pat \
github.com/fitstar/falcore \
github.com/fitstar/falcore/filter \
github.com/gorilla/mux \
github.com/goraft/raft \
github.com/influxdb/influxdb/_vendor/raft \
github.com/influxdb/go-cache \
github.com/BurntSushi/toml \
github.com/influxdb/influxdb-go \
code.google.com/p/gogoprotobuf/proto \
github.com/influxdb/gomdb \
code.google.com/p/go.tools/cmd/vet \
github.com/jmhodges/levigo \
github.com/influxdb/rocksdb \
github.com/influxdb/hyperleveldb-go \
$(proto_dependency)
dependencies_paths := $(addprefix src/,$(dependencies))
src/$(levigo_dependency): $(leveldb_deps)
$(GO) get -d $(levigo_dependency)
src/$(rocksdb_dependency): $(rocksdb_deps)
$(GO) get -d $(rocksdb_dependency)
src/$(hyperleveldb_dependency): $(hyperleveldb_deps)
$(GO) get -d $(hyperleveldb_dependency)
dependencies_paths := $(addprefix $(GOPATH)/src/,$(dependencies))
$(dependencies_paths):
for i in $(dependencies); do $(GO) get -d $$i; done
storage_engines += src/$(levigo_dependency)
storage_engines += $(leveldb_deps)
dependencies: $(storage_engines) $(dependencies_paths)
test_dependencies: dependencies
$(GO) get launchpad.net/gocheck
protobuf:
$(GO) get $(proto_dependency)
rm -f src/protocol/*.pb.go
PATH=$$PWD/bin:$$PATH $(PROTOC) --go_out=. src/protocol/*.proto
protobuf: $(GOPATH)/src/$(proto_dependency)
rm -f protocol/*.pb.go
PATH=$$GOPATH/bin:$$PATH $(PROTOC) --go_out=. protocol/*.proto
build: | dependencies protobuf parser build_version_string
# TODO: build all packages, otherwise we won't know
# if there's an error
$(GO) build $(GO_BUILD_OPTIONS) daemon
$(GO) build $(GO_BUILD_OPTIONS) tools/benchmark-storage
$(GO) build benchmark
$(GO) build -o influxdb $(GO_BUILD_OPTIONS) github.com/influxdb/influxdb/daemon
$(GO) build -o benchmark-storage $(GO_BUILD_OPTIONS) github.com/influxdb/influxdb/tools/benchmark-storage
$(GO) build -o benchmark-tool github.com/influxdb/influxdb/benchmark
clean:
git status --ignored | grep src\/ | grep -v Makefile | xargs rm -rf
@ -245,7 +244,7 @@ clean:
rm -rf $(leveldb_dir)
rm -rf $(hyperleveldb_dir)
rm -rf $(rocksdb_dir)
$(MAKE) -C src/parser clean
$(MAKE) -C parser clean
only =
verbose = off
@ -265,18 +264,18 @@ timeout = 10m
GOTEST_OPTS += -test.timeout=$(timeout)
bench:
$(GO) test coordinator -test.bench=. -test.benchmem
$(GO) test github.com/influxdb/influxdb/coordinator -test.bench=. -test.benchmem
test: test_dependencies parser protobuf
$(GO) test $(packages) $(GOTEST_OPTS)
$(GO) test $(test_packages) $(GOTEST_OPTS)
coverage: test_dependencies
for i in $(packages); do $(GO) test -coverprofile ${TMPDIR}/influxdb.$${i/\//}.coverage $$i $(GOTEST_OPTS); \
for i in $(build_packages); do $(GO) test -coverprofile ${TMPDIR}/influxdb.$${i/\//}.coverage $$i $(GOTEST_OPTS); \
$(GO) tool cover -html=${TMPDIR}/influxdb.$${i/\//}.coverage; done
integration_test: test_dependencies build
$(GO) test integration $(GOTEST_OPTS)
$(GO) test github.com/influxdb/influxdb/integration $(GOTEST_OPTS)
package_version=$(subst -,_,$(version))
admin_dir = ${TMPDIR}/admin.influxdb
@ -300,9 +299,9 @@ files = $(binary_package) $(debian_package) $(rpm_package) $(source_package)
sha1 = $(shell sh -c "git rev-list --max-count=1 --abbrev-commit HEAD")
build_version_string:
@echo "package main" > src/daemon/version.go
@echo "const version = \"$(version)\"" >> src/daemon/version.go
@echo "const gitSha = \"$(sha1)\"" >> src/daemon/version.go
@echo "package main" > daemon/version.go
@echo "const version = \"$(version)\"" >> daemon/version.go
@echo "const gitSha = \"$(sha1)\"" >> daemon/version.go
package_version_string: build_version_string
sed -i.bak -e "s/REPLACE_VERSION/$(version)/" scripts/post_install.sh
@ -328,7 +327,7 @@ $(debian_package): $(admin_dir)/build build
mv out_rpm/$(shell basename $(debian_package)) packages/
$(source_package): dependencies
rm -rf src/$(levigo_dependency)
rm -rf $(levigo_dependency)
$(GO) get -d $(levigo_dependency)
rm -f daemon
rm -f benchmark
@ -346,7 +345,7 @@ $(source_package): dependencies
rm $(source_package)
bash -c "pushd ${TMPDIR}/; tar -czf `basename $(source_package)` influxdb; popd"
mv ${TMPDIR}/$(shell basename $(source_package)) $(source_package)
rm -rf src/$(levigo_dependency)
rm -rf $(levigo_dependency)
rm -rf admin
$(binary_package): $(admin_dir)/build build packages
@ -354,7 +353,7 @@ $(binary_package): $(admin_dir)/build build packages
mkdir build
mv daemon build/influxdb
mv benchmark build/influxdb-benchmark
cp src/benchmark/benchmark_config.sample.toml build/benchmark_config.toml
cp benchmark/benchmark_config.sample.toml build/benchmark_config.toml
mkdir build/admin
cp -R $(admin_dir)/build/* build/admin/
cp -R scripts/ build/

View File

@ -5,7 +5,7 @@ import (
"io/ioutil"
"code.google.com/p/gogoprotobuf/proto"
"github.com/goraft/raft/protobuf"
"github.com/influxdb/influxdb/_vendor/raft/protobuf"
)
// The request sent to a server to append entries to the log.

View File

@ -8,7 +8,7 @@ import (
"os"
"sync"
"github.com/goraft/raft/protobuf"
"github.com/influxdb/influxdb/_vendor/raft/protobuf"
)
//------------------------------------------------------------------------------

View File

@ -7,7 +7,7 @@ import (
"io"
"code.google.com/p/gogoprotobuf/proto"
"github.com/goraft/raft/protobuf"
"github.com/influxdb/influxdb/_vendor/raft/protobuf"
)
// A log entry stores a single item in the log.

View File

@ -5,7 +5,7 @@ import (
"io/ioutil"
"code.google.com/p/gogoprotobuf/proto"
"github.com/goraft/raft/protobuf"
"github.com/influxdb/influxdb/_vendor/raft/protobuf"
)
// The request sent to a server to vote for a candidate to become a leader.

View File

@ -9,7 +9,7 @@ import (
"os"
"code.google.com/p/gogoprotobuf/proto"
"github.com/goraft/raft/protobuf"
"github.com/influxdb/influxdb/_vendor/raft/protobuf"
)
// Snapshot represents an in-memory representation of the current state of the system.

View File

@ -14,16 +14,17 @@ package graphite
import (
"bufio"
"cluster"
. "common"
"configuration"
"coordinator"
"io"
"net"
"protocol"
"strings"
"time"
"github.com/influxdb/influxdb/cluster"
. "github.com/influxdb/influxdb/common"
"github.com/influxdb/influxdb/configuration"
"github.com/influxdb/influxdb/coordinator"
"github.com/influxdb/influxdb/protocol"
log "code.google.com/p/log4go"
)

View File

@ -2,10 +2,7 @@ package http
import (
"bytes"
"cluster"
. "common"
"compress/gzip"
"coordinator"
"crypto/tls"
"encoding/base64"
"encoding/json"
@ -14,15 +11,18 @@ import (
"io/ioutil"
"net"
libhttp "net/http"
"parser"
"path/filepath"
"protocol"
"strconv"
"strings"
"time"
log "code.google.com/p/log4go"
"github.com/bmizerany/pat"
"github.com/influxdb/influxdb/cluster"
. "github.com/influxdb/influxdb/common"
"github.com/influxdb/influxdb/coordinator"
"github.com/influxdb/influxdb/parser"
"github.com/influxdb/influxdb/protocol"
)
type HttpServer struct {

View File

@ -2,10 +2,6 @@ package http
import (
"bytes"
"cluster"
. "common"
"configuration"
"coordinator"
"encoding/base64"
"encoding/json"
"fmt"
@ -13,11 +9,15 @@ import (
"net"
libhttp "net/http"
"net/url"
"parser"
"protocol"
"testing"
"time"
"github.com/influxdb/influxdb/cluster"
. "github.com/influxdb/influxdb/common"
"github.com/influxdb/influxdb/configuration"
"github.com/influxdb/influxdb/coordinator"
"github.com/influxdb/influxdb/parser"
"github.com/influxdb/influxdb/protocol"
. "launchpad.net/gocheck"
)

View File

@ -1,8 +1,9 @@
package http
import (
"common"
"fmt"
"github.com/influxdb/influxdb/common"
)
type Operation struct {

View File

@ -3,7 +3,7 @@ package http
// This implements the SeriesWriter interface for use with the API
import (
"protocol"
"github.com/influxdb/influxdb/protocol"
)
type SeriesWriter struct {

View File

@ -1,7 +1,7 @@
package http
import (
"common"
"github.com/influxdb/influxdb/common"
)
type UserManager interface {

View File

@ -2,14 +2,14 @@ package udp
import (
"bytes"
"cluster"
. "common"
"coordinator"
"encoding/json"
"net"
"protocol"
log "code.google.com/p/log4go"
"github.com/influxdb/influxdb/cluster"
. "github.com/influxdb/influxdb/common"
"github.com/influxdb/influxdb/coordinator"
"github.com/influxdb/influxdb/protocol"
)
type Server struct {

View File

@ -2,9 +2,10 @@ package checkers
import (
"fmt"
. "launchpad.net/gocheck"
"protocol"
"reflect"
"github.com/influxdb/influxdb/protocol"
. "launchpad.net/gocheck"
)
type SeriesEqualsChecker struct {

View File

@ -2,8 +2,6 @@ package cluster
import (
"bytes"
"common"
"configuration"
"crypto/sha1"
"encoding/binary"
"encoding/gob"
@ -11,14 +9,16 @@ import (
"fmt"
"math"
"math/rand"
"parser"
"protocol"
"sort"
"sync"
"time"
"wal"
log "code.google.com/p/log4go"
"github.com/influxdb/influxdb/common"
"github.com/influxdb/influxdb/configuration"
"github.com/influxdb/influxdb/parser"
"github.com/influxdb/influxdb/protocol"
"github.com/influxdb/influxdb/wal"
)
// defined by cluster config (in cluster package)

View File

@ -1,14 +1,14 @@
package cluster
import (
c "configuration"
"errors"
"fmt"
"net"
"protocol"
"time"
log "code.google.com/p/log4go"
c "github.com/influxdb/influxdb/configuration"
"github.com/influxdb/influxdb/protocol"
)
const (

View File

@ -1,17 +1,17 @@
package cluster
import (
"common"
"engine"
"fmt"
"parser"
p "protocol"
"sort"
"strings"
"time"
"wal"
log "code.google.com/p/log4go"
"github.com/influxdb/influxdb/common"
"github.com/influxdb/influxdb/engine"
"github.com/influxdb/influxdb/parser"
p "github.com/influxdb/influxdb/protocol"
"github.com/influxdb/influxdb/wal"
)
// A shard implements an interface for writing and querying data.

View File

@ -1,11 +1,11 @@
package cluster
import (
"common"
"regexp"
"code.google.com/p/go.crypto/bcrypt"
"github.com/influxdb/go-cache"
"github.com/influxdb/influxdb/common"
)
var userCache *cache.Cache

View File

@ -1,9 +1,10 @@
package cluster
import (
"common"
. "launchpad.net/gocheck"
"testing"
"github.com/influxdb/influxdb/common"
. "launchpad.net/gocheck"
)
type UserSuite struct{}

View File

@ -1,11 +1,11 @@
package cluster
import (
"protocol"
"reflect"
"time"
log "code.google.com/p/log4go"
"github.com/influxdb/influxdb/protocol"
)
// Acts as a buffer for writes

View File

@ -1,7 +1,7 @@
package common
import (
"protocol"
"github.com/influxdb/influxdb/protocol"
)
type Type int

View File

@ -5,9 +5,9 @@ import (
"fmt"
"math/big"
"os"
"protocol"
"time"
"github.com/influxdb/influxdb/protocol"
)
// Returns the parsed duration in nanoseconds, support 'u', 's', 'm',

View File

@ -1,8 +1,9 @@
package common
import (
"protocol"
"reflect"
"github.com/influxdb/influxdb/protocol"
)
func pointMaps(s *protocol.Series) (result []map[string]*protocol.FieldValue) {

View File

@ -3,9 +3,9 @@ package common
import (
"encoding/json"
"fmt"
"protocol"
log "code.google.com/p/log4go"
"github.com/influxdb/influxdb/protocol"
)
var (

View File

@ -1,7 +1,6 @@
package configuration
import (
"common"
"encoding/json"
"fmt"
"io/ioutil"
@ -12,6 +11,7 @@ import (
log "code.google.com/p/log4go"
"github.com/BurntSushi/toml"
"github.com/influxdb/influxdb/common"
)
type Size int

4
configure vendored
View File

@ -2974,7 +2974,7 @@ fi
if test x"${with_bison}" == x"notfound"; then
as_fn_error $? "Please install bison before trying to build Influxdb" "$LINENO" 5
fi
ac_config_files="$ac_config_files Makefile src/parser/Makefile"
ac_config_files="$ac_config_files Makefile parser/Makefile"
cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
@ -3683,7 +3683,7 @@ for ac_config_target in $ac_config_targets
do
case $ac_config_target in
"Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
"src/parser/Makefile") CONFIG_FILES="$CONFIG_FILES src/parser/Makefile" ;;
"parser/Makefile") CONFIG_FILES="$CONFIG_FILES parser/Makefile" ;;
*) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
esac

View File

@ -54,4 +54,4 @@ fi
if test x"${with_bison}" == x"notfound"; then
AC_MSG_ERROR([Please install bison before trying to build Influxdb])
fi
AC_OUTPUT([Makefile src/parser/Makefile])
AC_OUTPUT([Makefile parser/Makefile])

View File

@ -4,11 +4,12 @@ import (
"encoding/binary"
"encoding/json"
"fmt"
. "launchpad.net/gocheck"
"net"
"protocol"
"testing"
"time"
"github.com/influxdb/influxdb/protocol"
. "launchpad.net/gocheck"
)
type ClientServerSuite struct{}

View File

@ -1,14 +1,14 @@
package coordinator
import (
"cluster"
"encoding/json"
"fmt"
"io"
"time"
log "code.google.com/p/log4go"
"github.com/goraft/raft"
"github.com/influxdb/influxdb/_vendor/raft"
"github.com/influxdb/influxdb/cluster"
)
var internalRaftCommands map[string]raft.Command
@ -337,7 +337,7 @@ func (c *CreateShardsCommand) CommandName() string {
}
// TODO: Encode/Decode are not needed once this pr
// https://github.com/goraft/raft/pull/221 is merged in and our goraft
// https://github.com/influxdb/influxdb/vendor/raft/pull/221 is merged in and our goraft
// is updated to a commit that includes the pr
func (c *CreateShardsCommand) Encode(w io.Writer) error {

View File

@ -3,7 +3,7 @@ package coordinator
// This implements the SeriesWriter interface for use with continuous queries to write their output back into the db
import (
"protocol"
"github.com/influxdb/influxdb/protocol"
)
type ContinuousQueryWriter struct {

View File

@ -1,20 +1,20 @@
package coordinator
import (
"cluster"
"common"
"configuration"
"engine"
"fmt"
"math"
"parser"
"protocol"
"regexp"
"strings"
"sync"
"time"
log "code.google.com/p/log4go"
"github.com/influxdb/influxdb/cluster"
"github.com/influxdb/influxdb/common"
"github.com/influxdb/influxdb/configuration"
"github.com/influxdb/influxdb/engine"
"github.com/influxdb/influxdb/parser"
"github.com/influxdb/influxdb/protocol"
)
type CoordinatorImpl struct {

View File

@ -1,12 +1,13 @@
package coordinator
import (
"cluster"
"configuration"
"fmt"
. "launchpad.net/gocheck"
"parser"
"time"
"github.com/influxdb/influxdb/cluster"
"github.com/influxdb/influxdb/configuration"
"github.com/influxdb/influxdb/parser"
. "launchpad.net/gocheck"
)
type CoordinatorSuite struct{}

View File

@ -1,10 +1,11 @@
package coordinator
import (
"cluster"
"common"
"net"
"protocol"
"github.com/influxdb/influxdb/cluster"
"github.com/influxdb/influxdb/common"
"github.com/influxdb/influxdb/protocol"
)
type Coordinator interface {

View File

@ -1,7 +1,7 @@
package coordinator
import (
"common"
"github.com/influxdb/influxdb/common"
)
type Permissions struct{}

View File

@ -1,9 +1,8 @@
package coordinator
import (
"cluster"
"common"
"github.com/influxdb/influxdb/cluster"
"github.com/influxdb/influxdb/common"
. "launchpad.net/gocheck"
)

View File

@ -6,12 +6,12 @@ import (
"fmt"
"io"
"net"
"protocol"
"sync"
"sync/atomic"
"time"
log "code.google.com/p/log4go"
"github.com/influxdb/influxdb/protocol"
)
type ProtobufClient struct {

View File

@ -5,11 +5,11 @@ import (
"encoding/binary"
"io"
"net"
"protocol"
"testing"
"time"
log "code.google.com/p/log4go"
"github.com/influxdb/influxdb/protocol"
)
type PingResponseServer struct {

View File

@ -2,16 +2,16 @@ package coordinator
import (
"bytes"
"cluster"
"common"
"encoding/binary"
"errors"
"fmt"
"net"
"parser"
"protocol"
log "code.google.com/p/log4go"
"github.com/influxdb/influxdb/cluster"
"github.com/influxdb/influxdb/common"
"github.com/influxdb/influxdb/parser"
"github.com/influxdb/influxdb/protocol"
)
type ProtobufRequestHandler struct {

Some files were not shown because too many files have changed in this diff Show More