Skip to content

Commit

Permalink
Add ability to join an existing cluster
Browse files Browse the repository at this point in the history
This adds some basic ability to join a node to an existing cluster. It
uses a rpc layer to initiate a join request to an existing memeber. The
response indicates whether the joining node should take part in the raft
cluster and who it's peers should be.  If raft should not be started, the
peers are the addresses of the current raft members that it should delegate
consensus operations.

To keep the meta store implementation agnostic of whether it's running
a local raft or not, a consensusStrategy type was also added.
  • Loading branch information
jwilder committed Jul 23, 2015
1 parent abfd438 commit e06f6f4
Show file tree
Hide file tree
Showing 6 changed files with 466 additions and 235 deletions.
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
3 changes: 3 additions & 0 deletions meta/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ type Config struct {
HeartbeatTimeout toml.Duration `toml:"heartbeat-timeout"`
LeaderLeaseTimeout toml.Duration `toml:"leader-lease-timeout"`
CommitTimeout toml.Duration `toml:"commit-timeout"`

// The join command-line argument
Join string
}

func NewConfig() Config {
Expand Down
197 changes: 114 additions & 83 deletions meta/internal/meta.pb.go

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

38 changes: 24 additions & 14 deletions meta/internal/meta.proto
Original file line number Diff line number Diff line change
Expand Up @@ -264,24 +264,34 @@ message Response {
//
//========================================================================

message RPCRequest {
extensions 100 to max;
enum RPCType {
FetchData = 1;
Join = 2;
}

enum Type {
QueryDataRequest = 1;
}
message ResponseHeader {
required bool OK = 1;
optional string Error = 2;
}

required Type type = 1;
message FetchDataRequest {
}

message QueryDataRequest {
extend RPCRequest {
optional QueryDataRequest command = 101;
}
message FetchDataResponse {
required ResponseHeader Header = 1;
optional bytes Data = 2;
}

message RPCResponse {
required bool OK = 1;
optional string Error = 2;
optional bytes Data = 3;
message JoinRequest {
required string Addr = 1;
}

message JoinResponse {
required ResponseHeader Header = 1;


optional bool EnableRaft = 2;
// The addresses of raft peers to use if joining as a raft member. If not joining
// as a raft member, these are the nodes running raft.
repeated string Peers = 3;
}
Loading

0 comments on commit e06f6f4

Please sign in to comment.