Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support joining nodes to an existing cluster #3372

Merged
merged 32 commits into from
Jul 23, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
abfd438
Implement remote meta data fetch
jwilder Jul 14, 2015
e06f6f4
Add ability to join an existing cluster
jwilder Jul 15, 2015
3f90891
Proxy raft and rpc connections to leader transparently
jwilder Jul 15, 2015
9db3a77
Assign and store a node ID when joining an existing cluster
jwilder Jul 15, 2015
cb718b9
Only allow adding non-raft nodes for now
jwilder Jul 16, 2015
43f0407
Ensure a node can join an existing single node raft cluster
jwilder Jul 16, 2015
5486d3e
Move invalidate to raft state
jwilder Jul 16, 2015
ad8948b
Fix up rpc error handling
jwilder Jul 16, 2015
a7fa5eb
Propogate metadata changes from raft nodes to non-raft nodes
jwilder Jul 16, 2015
f3fcfeb
Make raftState interface private
jwilder Jul 17, 2015
5ea8342
Move raft state to separate file
jwilder Jul 17, 2015
fb8a4db
Move raft closing to localRaft state
jwilder Jul 17, 2015
33730da
Move isLeader to raft state
jwilder Jul 17, 2015
9e43397
Move leaderCh() to raft state
jwilder Jul 17, 2015
b86fecf
Move setPeers to raft state
jwilder Jul 17, 2015
80248f9
Remote leaderCh
jwilder Jul 17, 2015
72e2e1a
Move addPeer to raft state
jwilder Jul 17, 2015
17a9bb0
Remove raftEnabled func
jwilder Jul 17, 2015
a9314d6
Move raft index to raft state
jwilder Jul 17, 2015
54e1165
Move apply to raft state
jwilder Jul 17, 2015
790733d
Move snapshot to raft state
jwilder Jul 17, 2015
85db9c4
Move remaining raft impl details to local raft state
jwilder Jul 17, 2015
29b11a2
Support multiple comma-separated join addresses
jwilder Jul 17, 2015
c1fc83e
Make join private so it does not show up in config command
jwilder Jul 17, 2015
84a8d7d
Add cluster-tracing option to meta config
jwilder Jul 17, 2015
b78ac4b
Add RPC tests
jwilder Jul 20, 2015
29011c5
Code review fixes
jwilder Jul 20, 2015
eb7d181
Fix race in test code
jwilder Jul 20, 2015
47b8de7
Hide Meta.Join from config command using toml skip annotation
jwilder Jul 22, 2015
e904416
Invalidate raft member by fetching from leader
jwilder Jul 22, 2015
9dd66fa
Make meta RPC private
jwilder Jul 23, 2015
3c308e3
Update changelog
jwilder Jul 23, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

### Features
- [#3376](https://github.com/influxdb/influxdb/pull/3376): Support for remote shard query mapping
- [#3372](https://github.com/influxdb/influxdb/pull/3372): Support joining nodes to existing cluster

### Bugfixes
- [#3405](https://github.com/influxdb/influxdb/pull/3405): Prevent database panic when fields are missing. Thanks @jhorwit2
Expand Down
4 changes: 2 additions & 2 deletions cmd/influxd/restore/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,8 @@ restore uses a snapshot of a data node to rebuild a cluster.

// Config represents a partial config for rebuilding the server.
type Config struct {
Meta meta.Config `toml:"meta"`
Data tsdb.Config `toml:"data"`
Meta *meta.Config `toml:"meta"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps it will become apparent later, but why this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needed to set a private join value on the config if it's specified via the command-line.

Data tsdb.Config `toml:"data"`
}

type nopListener struct {
Expand Down
4 changes: 4 additions & 0 deletions cmd/influxd/run/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ func (cmd *Command) Run(args ...string) error {
config.Meta.Hostname = options.Hostname
}

if options.Join != "" {
config.Meta.Join = options.Join
}

// Validate the configuration.
if err := config.Validate(); err != nil {
return fmt.Errorf("%s. To generate a valid configuration file run `influxd config > influxdb.generated.conf`.", err)
Expand Down
2 changes: 1 addition & 1 deletion cmd/influxd/run/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (

// Config represents the configuration format for the influxd binary.
type Config struct {
Meta meta.Config `toml:"meta"`
Meta *meta.Config `toml:"meta"`
Data tsdb.Config `toml:"data"`
Cluster cluster.Config `toml:"cluster"`
Retention retention.Config `toml:"retention"`
Expand Down
8 changes: 8 additions & 0 deletions cmd/influxd/run/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"os"
"runtime"
"runtime/pprof"
"strings"
"time"

"github.com/influxdb/influxdb/cluster"
Expand Down Expand Up @@ -290,10 +291,17 @@ func (s *Server) Open() error {
}
s.Listener = ln

// The port 0 is used, we need to retrieve the port assigned by the kernel
if strings.HasSuffix(s.BindAddress, ":0") {
s.MetaStore.Addr = ln.Addr()
}

// Multiplex listener.
mux := tcp.NewMux()
s.MetaStore.RaftListener = mux.Listen(meta.MuxRaftHeader)
s.MetaStore.ExecListener = mux.Listen(meta.MuxExecHeader)
s.MetaStore.RPCListener = mux.Listen(meta.MuxRPCHeader)

s.ClusterService.Listener = mux.Listen(cluster.MuxHeader)
s.SnapshotterService.Listener = mux.Listen(snapshotter.MuxHeader)
go mux.Serve(ln)
Expand Down
8 changes: 6 additions & 2 deletions meta/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,14 @@ type Config struct {
HeartbeatTimeout toml.Duration `toml:"heartbeat-timeout"`
LeaderLeaseTimeout toml.Duration `toml:"leader-lease-timeout"`
CommitTimeout toml.Duration `toml:"commit-timeout"`
ClusterTracing bool `toml:"cluster-tracing"`

// The join command-line argument
Join string `toml:"-"`
}

func NewConfig() Config {
return Config{
func NewConfig() *Config {
return &Config{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why return a pointer?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The config needs to be modified if -join is specified now.

Hostname: DefaultHostname,
BindAddress: DefaultBindAddress,
RetentionAutoCreate: true,
Expand Down
32 changes: 20 additions & 12 deletions meta/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -706,14 +706,18 @@ func (di *DatabaseInfo) unmarshal(pb *internal.DatabaseInfo) {
di.Name = pb.GetName()
di.DefaultRetentionPolicy = pb.GetDefaultRetentionPolicy()

di.RetentionPolicies = make([]RetentionPolicyInfo, len(pb.GetRetentionPolicies()))
for i, x := range pb.GetRetentionPolicies() {
di.RetentionPolicies[i].unmarshal(x)
if len(pb.GetRetentionPolicies()) > 0 {
di.RetentionPolicies = make([]RetentionPolicyInfo, len(pb.GetRetentionPolicies()))
for i, x := range pb.GetRetentionPolicies() {
di.RetentionPolicies[i].unmarshal(x)
}
}

di.ContinuousQueries = make([]ContinuousQueryInfo, len(pb.GetContinuousQueries()))
for i, x := range pb.GetContinuousQueries() {
di.ContinuousQueries[i].unmarshal(x)
if len(pb.GetContinuousQueries()) > 0 {
di.ContinuousQueries = make([]ContinuousQueryInfo, len(pb.GetContinuousQueries()))
for i, x := range pb.GetContinuousQueries() {
di.ContinuousQueries[i].unmarshal(x)
}
}
}

Expand Down Expand Up @@ -794,9 +798,11 @@ func (rpi *RetentionPolicyInfo) unmarshal(pb *internal.RetentionPolicyInfo) {
rpi.Duration = time.Duration(pb.GetDuration())
rpi.ShardGroupDuration = time.Duration(pb.GetShardGroupDuration())

rpi.ShardGroups = make([]ShardGroupInfo, len(pb.GetShardGroups()))
for i, x := range pb.GetShardGroups() {
rpi.ShardGroups[i].unmarshal(x)
if len(pb.GetShardGroups()) > 0 {
rpi.ShardGroups = make([]ShardGroupInfo, len(pb.GetShardGroups()))
for i, x := range pb.GetShardGroups() {
rpi.ShardGroups[i].unmarshal(x)
}
}
}

Expand Down Expand Up @@ -900,9 +906,11 @@ func (sgi *ShardGroupInfo) unmarshal(pb *internal.ShardGroupInfo) {
sgi.EndTime = UnmarshalTime(pb.GetEndTime())
sgi.DeletedAt = UnmarshalTime(pb.GetDeletedAt())

sgi.Shards = make([]ShardInfo, len(pb.GetShards()))
for i, x := range pb.GetShards() {
sgi.Shards[i].unmarshal(x)
if len(pb.GetShards()) > 0 {
sgi.Shards = make([]ShardInfo, len(pb.GetShards()))
for i, x := range pb.GetShards() {
sgi.Shards[i].unmarshal(x)
}
}
}

Expand Down
217 changes: 217 additions & 0 deletions meta/internal/meta.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading