From 4c8e46e17fbcfaf0483eae45a92787df6e572176 Mon Sep 17 00:00:00 2001 From: Travis Date: Wed, 19 Apr 2017 09:39:16 -0500 Subject: [PATCH] change Config.Nodes to Config.Hosts --- cmd/server.go | 4 ++-- cmd/server_test.go | 6 +++--- config.go | 8 ++++---- server/server.go | 7 +++++-- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/cmd/server.go b/cmd/server.go index d4e72a411..358793af3 100644 --- a/cmd/server.go +++ b/cmd/server.go @@ -76,8 +76,8 @@ on the configured port.`, flags.StringVarP(&Server.Config.DataDir, "data-dir", "d", "~/.pilosa", "Directory to store pilosa data files.") flags.StringVarP(&Server.Config.Host, "bind", "b", ":10101", "Default URI on which pilosa should listen.") flags.IntVarP(&Server.Config.Cluster.ReplicaN, "cluster.replicas", "", 1, "Number of hosts each piece of data should be stored on.") - flags.StringSliceVarP(&Server.Config.Cluster.Nodes, "cluster.hosts", "", []string{}, "Comma separated list of hosts in cluster.") - flags.StringSliceVarP(&Server.Config.Cluster.InternalNodes, "cluster.internal-hosts", "", []string{}, "Comma separated list of hosts in cluster used for internal communication.") + flags.StringSliceVarP(&Server.Config.Cluster.Hosts, "cluster.hosts", "", []string{}, "Comma separated list of hosts in cluster.") + flags.StringSliceVarP(&Server.Config.Cluster.InternalHosts, "cluster.internal-hosts", "", []string{}, "Comma separated list of hosts in cluster used for internal communication.") flags.DurationVarP((*time.Duration)(&Server.Config.Cluster.PollingInterval), "cluster.poll-interval", "", time.Minute, "Polling interval for cluster.") // TODO what actually is this? flags.StringVarP(&Server.Config.Plugins.Path, "plugins.path", "", "", "Path to plugin directory.") flags.StringVar(&Server.Config.LogPath, "log-path", "", "Log path") diff --git a/cmd/server_test.go b/cmd/server_test.go index f1310abc2..e51825e60 100644 --- a/cmd/server_test.go +++ b/cmd/server_test.go @@ -47,7 +47,7 @@ bind = "localhost:0" v.Check(cmd.Server.Config.DataDir, actualDataDir) v.Check(cmd.Server.Config.Host, "localhost:0") v.Check(cmd.Server.Config.Cluster.ReplicaN, 2) - v.Check(cmd.Server.Config.Cluster.Nodes, []string{"example.com:10101", "example.com:10110"}) + v.Check(cmd.Server.Config.Cluster.Hosts, []string{"example.com:10101", "example.com:10110"}) v.Check(cmd.Server.Config.Cluster.PollingInterval, pilosa.Duration(time.Second*182)) return v.Error() }, @@ -68,7 +68,7 @@ data-dir = "` + actualDataDir + `" `, validation: func() error { v := validator{} - v.Check(cmd.Server.Config.Cluster.Nodes, []string{"example.com:1110", "example.com:1111"}) + v.Check(cmd.Server.Config.Cluster.Hosts, []string{"example.com:1110", "example.com:1111"}) v.Check(cmd.Server.Config.Plugins.Path, "/var/sloth") v.Check(cmd.Server.Config.AntiEntropy.Interval, pilosa.Duration(time.Minute*9)) return v.Error() @@ -94,7 +94,7 @@ data-dir = "` + actualDataDir + `" `, validation: func() error { v := validator{} - v.Check(cmd.Server.Config.Cluster.Nodes, []string{"localhost:19444"}) + v.Check(cmd.Server.Config.Cluster.Hosts, []string{"localhost:19444"}) v.Check(cmd.Server.Config.Cluster.PollingInterval, pilosa.Duration(time.Minute*2)) v.Check(cmd.Server.Config.AntiEntropy.Interval, pilosa.Duration(time.Minute*11)) v.Check(cmd.Server.CPUProfile, profFile.Name()) diff --git a/config.go b/config.go index b577f6281..d5d725ece 100644 --- a/config.go +++ b/config.go @@ -18,8 +18,8 @@ type Config struct { Cluster struct { ReplicaN int `toml:"replicas"` Type string `toml:"type"` - Nodes []string `toml:"hosts"` - InternalNodes []string `toml:"internal-hosts"` + Hosts []string `toml:"hosts"` + InternalHosts []string `toml:"internal-hosts"` PollingInterval Duration `toml:"polling-interval"` InternalPort string `toml:"internal-port"` GossipSeed string `toml:"gossip-seed"` @@ -44,8 +44,8 @@ func NewConfig() *Config { c.Cluster.ReplicaN = DefaultReplicaN c.Cluster.Type = DefaultClusterType c.Cluster.PollingInterval = Duration(DefaultPollingInterval) - c.Cluster.Nodes = []string{} - c.Cluster.InternalNodes = []string{} + c.Cluster.Hosts = []string{} + c.Cluster.InternalHosts = []string{} c.AntiEntropy.Interval = Duration(DefaultAntiEntropyInterval) return c } diff --git a/server/server.go b/server/server.go index 574941c42..ec2b55c7c 100644 --- a/server/server.go +++ b/server/server.go @@ -93,10 +93,13 @@ func (m *Command) SetupServer() error { cluster := pilosa.NewCluster() cluster.ReplicaN = m.Config.Cluster.ReplicaN - for _, hostport := range m.Config.Cluster.Nodes { + for _, hostport := range m.Config.Cluster.Hosts { cluster.Nodes = append(cluster.Nodes, &pilosa.Node{Host: hostport}) } - for i, internalhostport := range m.Config.Cluster.InternalNodes { + // TODO: if InternalHosts is not provided then pilosa.Node.InternalHost is empty. + // This will throw an error when trying to Broadcast messages over HTTP. + // One option may be to fall back to using host from hostport + config.InternalPort. + for i, internalhostport := range m.Config.Cluster.InternalHosts { cluster.Nodes[i].InternalHost = internalhostport } m.Server.Cluster = cluster