From cda46245d82f67f13a294b2c8d7c1a7ba5431127 Mon Sep 17 00:00:00 2001 From: Linh Vo Date: Fri, 7 Jul 2017 12:04:49 -0500 Subject: [PATCH 1/5] update config to match with json tag --- config.go | 4 ++-- ctl/server.go | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/config.go b/config.go index 439e9c3ed..cf886464f 100644 --- a/config.go +++ b/config.go @@ -69,8 +69,8 @@ type Config struct { Metric struct { Service string `toml:"service"` Host string `toml:"host"` - PollingInterval Duration `toml:"interval"` - } `toml:"metrics"` + PollingInterval Duration `toml:"poll-interval"` + } `toml:"metric"` } // NewConfig returns an instance of Config with default options. diff --git a/ctl/server.go b/ctl/server.go index 6186443f8..7860dfe5f 100644 --- a/ctl/server.go +++ b/ctl/server.go @@ -25,12 +25,13 @@ import ( func BuildServerFlags(cmd *cobra.Command, srv *server.Command) { flags := cmd.Flags() flags.StringVarP(&srv.Config.DataDir, "data-dir", "d", "~/.pilosa", "Directory to store pilosa data files.") - flags.StringVarP(&srv.Config.Host, "bind", "b", ":10101", "Default URI on which pilosa should listen.") + flags.StringVarP(&srv.Config.Host, "host", "", ":10101", "Default URI on which pilosa should listen.") flags.IntVarP(&srv.Config.MaxWritesPerRequest, "max-writes-per-request", "", srv.Config.MaxWritesPerRequest, "Number of write commands per request.") flags.IntVarP(&srv.Config.Cluster.ReplicaN, "cluster.replicas", "", 1, "Number of hosts each piece of data should be stored on.") flags.StringSliceVarP(&srv.Config.Cluster.Hosts, "cluster.hosts", "", []string{}, "Comma separated list of hosts in cluster.") flags.StringSliceVarP(&srv.Config.Cluster.InternalHosts, "cluster.internal-hosts", "", []string{}, "Comma separated list of hosts in cluster used for internal communication.") - flags.DurationVarP((*time.Duration)(&srv.Config.Cluster.PollingInterval), "cluster.poll-interval", "", time.Minute, "Polling interval for cluster.") // TODO what actually is this? + flags.DurationVarP((*time.Duration)(&srv.Config.Cluster.PollingInterval), "cluster.polling-interval", "", time.Minute, "Polling interval for cluster.") // TODO what actually is this? + flags.DurationVarP((*time.Duration)(&srv.Config.Cluster.LongQueryTime), "cluster.long-query-time", "", time.Minute, "Long time query.") flags.StringVarP(&srv.Config.Plugins.Path, "plugins.path", "", "", "Path to plugin directory.") flags.StringVar(&srv.Config.LogPath, "log-path", "", "Log path") flags.DurationVarP((*time.Duration)(&srv.Config.AntiEntropy.Interval), "anti-entropy.interval", "", time.Minute*10, "Interval at which to run anti-entropy routine.") From e3090cb0c315869983db9e24dc884632bb8d426c Mon Sep 17 00:00:00 2001 From: Linh Vo Date: Fri, 7 Jul 2017 15:12:16 -0500 Subject: [PATCH 2/5] update doc for configuration --- cmd/root_test.go | 4 ++-- cmd/server_test.go | 14 +++++++------- config.go | 2 +- ctl/generate_config.go | 4 ++-- ctl/server.go | 2 +- docs/configuration.md | 22 +++++++++++----------- 6 files changed, 24 insertions(+), 24 deletions(-) diff --git a/cmd/root_test.go b/cmd/root_test.go index e1aaaf31d..37c235322 100644 --- a/cmd/root_test.go +++ b/cmd/root_test.go @@ -178,10 +178,10 @@ func TestRootCommand_Config(t *testing.T) { panic(err) } config := `data-dir = "/tmp/pil5_0" -bind = "127.0.0.1:10101" +host = "127.0.0.1:10101" [cluster] - poll-interval = "2m0s" + polling-interval = "2m0s" replicas = 2 partitions = 128 hosts = [ diff --git a/cmd/server_test.go b/cmd/server_test.go index 10851e45b..4a8fa349f 100644 --- a/cmd/server_test.go +++ b/cmd/server_test.go @@ -44,14 +44,14 @@ func TestServerConfig(t *testing.T) { tests := []commandTest{ // TEST 0 { - args: []string{"server", "--data-dir", actualDataDir, "--cluster.hosts", "example.com:10111,example.com:10110", "--bind", "example.com:10111"}, - env: map[string]string{"PILOSA_DATA_DIR": "/tmp/myEnvDatadir", "PILOSA_CLUSTER.POLL_INTERVAL": "3m2s"}, + args: []string{"server", "--data-dir", actualDataDir, "--cluster.hosts", "example.com:10111,example.com:10110", "--host", "example.com:10111"}, + env: map[string]string{"PILOSA_DATA_DIR": "/tmp/myEnvDatadir", "PILOSA_CLUSTER.POLLING_INTERVAL": "3m2s"}, cfgFileContent: ` data-dir = "/tmp/myFileDatadir" - bind = "localhost:0" + host = "localhost:0" [cluster] - poll-interval = "45s" + polling-interval = "45s" replicas = 2 hosts = [ "localhost:19444", @@ -72,7 +72,7 @@ func TestServerConfig(t *testing.T) { args: []string{"server", "--anti-entropy.interval", "9m0s"}, env: map[string]string{"PILOSA_CLUSTER.HOSTS": "example.com:1110,example.com:1111", "PILOSA_BIND": "example.com:1110"}, cfgFileContent: ` - bind = "localhost:0" + host = "localhost:0" data-dir = "` + actualDataDir + `" [cluster] hosts = [ @@ -94,10 +94,10 @@ func TestServerConfig(t *testing.T) { args: []string{"server", "--log-path", logFile.Name()}, env: map[string]string{"PILOSA_PROFILE.CPU_TIME": "1m"}, cfgFileContent: ` - bind = "localhost:19444" + host = "localhost:19444" data-dir = "` + actualDataDir + `" [cluster] - poll-interval = "2m0s" + polling-interval = "2m0s" hosts = [ "localhost:19444", ] diff --git a/config.go b/config.go index cf886464f..f3479e214 100644 --- a/config.go +++ b/config.go @@ -69,7 +69,7 @@ type Config struct { Metric struct { Service string `toml:"service"` Host string `toml:"host"` - PollingInterval Duration `toml:"poll-interval"` + PollingInterval Duration `toml:"polling-interval"` } `toml:"metric"` } diff --git a/ctl/generate_config.go b/ctl/generate_config.go index 87f866bb8..62d59b784 100644 --- a/ctl/generate_config.go +++ b/ctl/generate_config.go @@ -43,7 +43,7 @@ bind = "localhost:10101" max-writes-per-request = 5000 [cluster] - poll-interval = "2m0s" + polling-interval = "2m0s" replicas = 1 hosts = [ "localhost:10101", @@ -59,7 +59,7 @@ max-writes-per-request = 5000 [metric] service = "statsd" host = "127.0.0.1:8125" - poll-interval = "0m15s" + polling-interval = "0m15s" [plugins] path = "" diff --git a/ctl/server.go b/ctl/server.go index 7860dfe5f..9e07fcd9c 100644 --- a/ctl/server.go +++ b/ctl/server.go @@ -42,5 +42,5 @@ func BuildServerFlags(cmd *cobra.Command, srv *server.Command) { flags.StringVarP(&srv.Config.Cluster.InternalPort, "cluster.internal-port", "", "", "Port to which pilosa should bind for internal state sharing.") flags.StringVarP(&srv.Config.Metric.Service, "metric.service", "", "nop", "Default URI on which pilosa should listen.") flags.StringVarP(&srv.Config.Metric.Host, "metric.host", "", "", "Default URI to send metrics.") - flags.DurationVarP((*time.Duration)(&srv.Config.Metric.PollingInterval), "metric.poll-interval", "", time.Minute*0, "Polling interval metrics.") + flags.DurationVarP((*time.Duration)(&srv.Config.Metric.PollingInterval), "metric.polling-interval", "", time.Minute*0, "Polling interval metrics.") } diff --git a/docs/configuration.md b/docs/configuration.md index f93647cb5..40d06a595 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -20,10 +20,10 @@ Every command line flag has a corresponding environment variable. The environmen ### Config file -The config file is in the [toml format](https://github.com/toml-lang/toml) and has exactly the same options available as the flags and environment variables. Any flag which contains a dot (".") denotes nesting within the config file, so the two flags `--cluster.poll-interval=2m0s` and `--cluster.replicas=1` look like this in the config file: +The config file is in the [toml format](https://github.com/toml-lang/toml) and has exactly the same options available as the flags and environment variables. Any flag which contains a dot (".") denotes nesting within the config file, so the two flags `--cluster.polling-interval=2m0s` and `--cluster.replicas=1` look like this in the config file: ```toml [cluster] - poll-interval = "2m0s" + polling-interval = "2m0s" replicas = 1 ``` @@ -47,15 +47,15 @@ Any flag that has a value that is a comma separated list on the command line bec interval = "10m0s" ``` -#### Bind +#### Host * Description: host:port on which the Pilosa server will listen for requests. Host defaults to localhost and port to 10101. -* Flag: `--bind="localhost:10101"` +* Flag: `--host="localhost:10101"` * Env: `PILOSA_BIND="localhost:10101"` * Config: ```toml - bind = localhost:10101 + host = localhost:10101 ``` #### Cluster Hosts @@ -97,13 +97,13 @@ Any flag that has a value that is a comma separated list on the command line bec #### Cluster Poll Interval * Description: Polling interval for cluster. -* Flag: `cluster.poll-interval="1m0s"` -* Env: `PILOSA_CLUSTER.POLL_INTERVAL="1m0s"` +* Flag: `cluster.polling-interval="1m0s"` +* Env: `PILOSA_CLUSTER.POLLING_INTERVAL="1m0s"` * Config: ```toml [cluster] - poll-interval = "1m0s" + polling-interval = "1m0s" ``` #### Cluster Replicas @@ -192,11 +192,11 @@ Any flag that has a value that is a comma separated list on the command line bec ##### Metric Poll Interval * Description: Polling interval for runtime metrics. -* Flag: `metric.poll-interval=”0m15s”` -* Env: `PILOSA_METRIC.POLL_INTERVAL=0m15s` +* Flag: `metric.polling-interval=”0m15s”` +* Env: `PILOSA_METRIC.POLLING_INTERVAL=0m15s` * Config: ```toml [metric] - poll-interval = "0m15s" + polling-interval = "0m15s" ``` \ No newline at end of file From 95166fd0ee4f0ceb9fa76798993bd692b7cc58f3 Mon Sep 17 00:00:00 2001 From: Linh Vo Date: Mon, 10 Jul 2017 11:28:32 -0500 Subject: [PATCH 3/5] revert config and fix json tag --- cmd/root_test.go | 4 ++-- cmd/server_test.go | 14 +++++++------- config.go | 6 +++--- ctl/server.go | 8 ++++---- docs/configuration.md | 22 +++++++++++----------- server/server_test.go | 2 +- 6 files changed, 28 insertions(+), 28 deletions(-) diff --git a/cmd/root_test.go b/cmd/root_test.go index 37c235322..e1aaaf31d 100644 --- a/cmd/root_test.go +++ b/cmd/root_test.go @@ -178,10 +178,10 @@ func TestRootCommand_Config(t *testing.T) { panic(err) } config := `data-dir = "/tmp/pil5_0" -host = "127.0.0.1:10101" +bind = "127.0.0.1:10101" [cluster] - polling-interval = "2m0s" + poll-interval = "2m0s" replicas = 2 partitions = 128 hosts = [ diff --git a/cmd/server_test.go b/cmd/server_test.go index 4a8fa349f..10851e45b 100644 --- a/cmd/server_test.go +++ b/cmd/server_test.go @@ -44,14 +44,14 @@ func TestServerConfig(t *testing.T) { tests := []commandTest{ // TEST 0 { - args: []string{"server", "--data-dir", actualDataDir, "--cluster.hosts", "example.com:10111,example.com:10110", "--host", "example.com:10111"}, - env: map[string]string{"PILOSA_DATA_DIR": "/tmp/myEnvDatadir", "PILOSA_CLUSTER.POLLING_INTERVAL": "3m2s"}, + args: []string{"server", "--data-dir", actualDataDir, "--cluster.hosts", "example.com:10111,example.com:10110", "--bind", "example.com:10111"}, + env: map[string]string{"PILOSA_DATA_DIR": "/tmp/myEnvDatadir", "PILOSA_CLUSTER.POLL_INTERVAL": "3m2s"}, cfgFileContent: ` data-dir = "/tmp/myFileDatadir" - host = "localhost:0" + bind = "localhost:0" [cluster] - polling-interval = "45s" + poll-interval = "45s" replicas = 2 hosts = [ "localhost:19444", @@ -72,7 +72,7 @@ func TestServerConfig(t *testing.T) { args: []string{"server", "--anti-entropy.interval", "9m0s"}, env: map[string]string{"PILOSA_CLUSTER.HOSTS": "example.com:1110,example.com:1111", "PILOSA_BIND": "example.com:1110"}, cfgFileContent: ` - host = "localhost:0" + bind = "localhost:0" data-dir = "` + actualDataDir + `" [cluster] hosts = [ @@ -94,10 +94,10 @@ func TestServerConfig(t *testing.T) { args: []string{"server", "--log-path", logFile.Name()}, env: map[string]string{"PILOSA_PROFILE.CPU_TIME": "1m"}, cfgFileContent: ` - host = "localhost:19444" + bind = "localhost:19444" data-dir = "` + actualDataDir + `" [cluster] - polling-interval = "2m0s" + poll-interval = "2m0s" hosts = [ "localhost:19444", ] diff --git a/config.go b/config.go index f3479e214..aa743dcef 100644 --- a/config.go +++ b/config.go @@ -39,14 +39,14 @@ const ( // Config represents the configuration for the command. type Config struct { DataDir string `toml:"data-dir"` - Host string `toml:"host"` + Host string `toml:"bind"` Cluster struct { ReplicaN int `toml:"replicas"` Type string `toml:"type"` Hosts []string `toml:"hosts"` InternalHosts []string `toml:"internal-hosts"` - PollingInterval Duration `toml:"polling-interval"` + PollingInterval Duration `toml:"poll-interval"` InternalPort string `toml:"internal-port"` GossipSeed string `toml:"gossip-seed"` LongQueryTime Duration `toml:"long-query-time"` @@ -69,7 +69,7 @@ type Config struct { Metric struct { Service string `toml:"service"` Host string `toml:"host"` - PollingInterval Duration `toml:"polling-interval"` + PollingInterval Duration `toml:"poll-interval"` } `toml:"metric"` } diff --git a/ctl/server.go b/ctl/server.go index 9e07fcd9c..b1b77a71a 100644 --- a/ctl/server.go +++ b/ctl/server.go @@ -25,13 +25,13 @@ import ( func BuildServerFlags(cmd *cobra.Command, srv *server.Command) { flags := cmd.Flags() flags.StringVarP(&srv.Config.DataDir, "data-dir", "d", "~/.pilosa", "Directory to store pilosa data files.") - flags.StringVarP(&srv.Config.Host, "host", "", ":10101", "Default URI on which pilosa should listen.") + flags.StringVarP(&srv.Config.Host, "bind", "b", ":10101", "Default URI on which pilosa should listen.") flags.IntVarP(&srv.Config.MaxWritesPerRequest, "max-writes-per-request", "", srv.Config.MaxWritesPerRequest, "Number of write commands per request.") flags.IntVarP(&srv.Config.Cluster.ReplicaN, "cluster.replicas", "", 1, "Number of hosts each piece of data should be stored on.") flags.StringSliceVarP(&srv.Config.Cluster.Hosts, "cluster.hosts", "", []string{}, "Comma separated list of hosts in cluster.") flags.StringSliceVarP(&srv.Config.Cluster.InternalHosts, "cluster.internal-hosts", "", []string{}, "Comma separated list of hosts in cluster used for internal communication.") - flags.DurationVarP((*time.Duration)(&srv.Config.Cluster.PollingInterval), "cluster.polling-interval", "", time.Minute, "Polling interval for cluster.") // TODO what actually is this? - flags.DurationVarP((*time.Duration)(&srv.Config.Cluster.LongQueryTime), "cluster.long-query-time", "", time.Minute, "Long time query.") + flags.DurationVarP((*time.Duration)(&srv.Config.Cluster.PollingInterval), "cluster.poll-interval", "", time.Minute, "Polling interval for cluster.") // TODO what actually is this? + flags.DurationVarP((*time.Duration)(&srv.Config.Cluster.LongQueryTime), "cluster.long-query-time", "", time.Minute, "Long Query Time.") flags.StringVarP(&srv.Config.Plugins.Path, "plugins.path", "", "", "Path to plugin directory.") flags.StringVar(&srv.Config.LogPath, "log-path", "", "Log path") flags.DurationVarP((*time.Duration)(&srv.Config.AntiEntropy.Interval), "anti-entropy.interval", "", time.Minute*10, "Interval at which to run anti-entropy routine.") @@ -42,5 +42,5 @@ func BuildServerFlags(cmd *cobra.Command, srv *server.Command) { flags.StringVarP(&srv.Config.Cluster.InternalPort, "cluster.internal-port", "", "", "Port to which pilosa should bind for internal state sharing.") flags.StringVarP(&srv.Config.Metric.Service, "metric.service", "", "nop", "Default URI on which pilosa should listen.") flags.StringVarP(&srv.Config.Metric.Host, "metric.host", "", "", "Default URI to send metrics.") - flags.DurationVarP((*time.Duration)(&srv.Config.Metric.PollingInterval), "metric.polling-interval", "", time.Minute*0, "Polling interval metrics.") + flags.DurationVarP((*time.Duration)(&srv.Config.Metric.PollingInterval), "metric.poll-interval", "", time.Minute*0, "Polling interval metrics.") } diff --git a/docs/configuration.md b/docs/configuration.md index 40d06a595..f93647cb5 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -20,10 +20,10 @@ Every command line flag has a corresponding environment variable. The environmen ### Config file -The config file is in the [toml format](https://github.com/toml-lang/toml) and has exactly the same options available as the flags and environment variables. Any flag which contains a dot (".") denotes nesting within the config file, so the two flags `--cluster.polling-interval=2m0s` and `--cluster.replicas=1` look like this in the config file: +The config file is in the [toml format](https://github.com/toml-lang/toml) and has exactly the same options available as the flags and environment variables. Any flag which contains a dot (".") denotes nesting within the config file, so the two flags `--cluster.poll-interval=2m0s` and `--cluster.replicas=1` look like this in the config file: ```toml [cluster] - polling-interval = "2m0s" + poll-interval = "2m0s" replicas = 1 ``` @@ -47,15 +47,15 @@ Any flag that has a value that is a comma separated list on the command line bec interval = "10m0s" ``` -#### Host +#### Bind * Description: host:port on which the Pilosa server will listen for requests. Host defaults to localhost and port to 10101. -* Flag: `--host="localhost:10101"` +* Flag: `--bind="localhost:10101"` * Env: `PILOSA_BIND="localhost:10101"` * Config: ```toml - host = localhost:10101 + bind = localhost:10101 ``` #### Cluster Hosts @@ -97,13 +97,13 @@ Any flag that has a value that is a comma separated list on the command line bec #### Cluster Poll Interval * Description: Polling interval for cluster. -* Flag: `cluster.polling-interval="1m0s"` -* Env: `PILOSA_CLUSTER.POLLING_INTERVAL="1m0s"` +* Flag: `cluster.poll-interval="1m0s"` +* Env: `PILOSA_CLUSTER.POLL_INTERVAL="1m0s"` * Config: ```toml [cluster] - polling-interval = "1m0s" + poll-interval = "1m0s" ``` #### Cluster Replicas @@ -192,11 +192,11 @@ Any flag that has a value that is a comma separated list on the command line bec ##### Metric Poll Interval * Description: Polling interval for runtime metrics. -* Flag: `metric.polling-interval=”0m15s”` -* Env: `PILOSA_METRIC.POLLING_INTERVAL=0m15s` +* Flag: `metric.poll-interval=”0m15s”` +* Env: `PILOSA_METRIC.POLL_INTERVAL=0m15s` * Config: ```toml [metric] - polling-interval = "0m15s" + poll-interval = "0m15s" ``` \ No newline at end of file diff --git a/server/server_test.go b/server/server_test.go index f1ee11b23..72c8243e3 100644 --- a/server/server_test.go +++ b/server/server_test.go @@ -346,7 +346,7 @@ func TestMain_FrameRestore(t *testing.T) { // Ensure the host can be parsed. func TestConfig_Parse_Host(t *testing.T) { - if c, err := ParseConfig(`host = "local"`); err != nil { + if c, err := ParseConfig(`bind = "local"`); err != nil { t.Fatal(err) } else if c.Host != "local" { t.Fatalf("unexpected host: %s", c.Host) From 308ea8e9938bb6675dbf0137c1f43009ebb6f28c Mon Sep 17 00:00:00 2001 From: Linh Vo Date: Mon, 10 Jul 2017 11:31:43 -0500 Subject: [PATCH 4/5] revert to poll-interval --- ctl/generate_config.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ctl/generate_config.go b/ctl/generate_config.go index 62d59b784..87f866bb8 100644 --- a/ctl/generate_config.go +++ b/ctl/generate_config.go @@ -43,7 +43,7 @@ bind = "localhost:10101" max-writes-per-request = 5000 [cluster] - polling-interval = "2m0s" + poll-interval = "2m0s" replicas = 1 hosts = [ "localhost:10101", @@ -59,7 +59,7 @@ max-writes-per-request = 5000 [metric] service = "statsd" host = "127.0.0.1:8125" - polling-interval = "0m15s" + poll-interval = "0m15s" [plugins] path = "" From 6a5042762988fc713ed242e2b0e4ca419b9255d8 Mon Sep 17 00:00:00 2001 From: Linh Vo Date: Mon, 10 Jul 2017 13:34:10 -0500 Subject: [PATCH 5/5] rename Config's fields --- cmd/server_test.go | 6 +++--- config.go | 28 ++++++++++++++-------------- ctl/server.go | 6 +++--- server/server.go | 10 +++++----- server/server_test.go | 6 +++--- 5 files changed, 28 insertions(+), 28 deletions(-) diff --git a/cmd/server_test.go b/cmd/server_test.go index 10851e45b..a0f6096c8 100644 --- a/cmd/server_test.go +++ b/cmd/server_test.go @@ -60,10 +60,10 @@ func TestServerConfig(t *testing.T) { validation: func() error { v := validator{} v.Check(cmd.Server.Config.DataDir, actualDataDir) - v.Check(cmd.Server.Config.Host, "example.com:10111") + v.Check(cmd.Server.Config.Bind, "example.com:10111") v.Check(cmd.Server.Config.Cluster.ReplicaN, 2) v.Check(cmd.Server.Config.Cluster.Hosts, []string{"example.com:10111", "example.com:10110"}) - v.Check(cmd.Server.Config.Cluster.PollingInterval, pilosa.Duration(time.Second*182)) + v.Check(cmd.Server.Config.Cluster.PollInterval, pilosa.Duration(time.Second*182)) return v.Error() }, }, @@ -113,7 +113,7 @@ func TestServerConfig(t *testing.T) { validation: func() error { v := validator{} 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.Cluster.PollInterval, pilosa.Duration(time.Minute*2)) v.Check(cmd.Server.Config.AntiEntropy.Interval, pilosa.Duration(time.Minute*11)) v.Check(cmd.Server.CPUProfile, profFile.Name()) v.Check(cmd.Server.CPUTime, time.Minute) diff --git a/config.go b/config.go index aa743dcef..b6961850b 100644 --- a/config.go +++ b/config.go @@ -39,17 +39,17 @@ const ( // Config represents the configuration for the command. type Config struct { DataDir string `toml:"data-dir"` - Host string `toml:"bind"` + Bind string `toml:"bind"` Cluster struct { - ReplicaN int `toml:"replicas"` - Type string `toml:"type"` - Hosts []string `toml:"hosts"` - InternalHosts []string `toml:"internal-hosts"` - PollingInterval Duration `toml:"poll-interval"` - InternalPort string `toml:"internal-port"` - GossipSeed string `toml:"gossip-seed"` - LongQueryTime Duration `toml:"long-query-time"` + ReplicaN int `toml:"replicas"` + Type string `toml:"type"` + Hosts []string `toml:"hosts"` + InternalHosts []string `toml:"internal-hosts"` + PollInterval Duration `toml:"poll-interval"` + InternalPort string `toml:"internal-port"` + GossipSeed string `toml:"gossip-seed"` + LongQueryTime Duration `toml:"long-query-time"` } `toml:"cluster"` Plugins struct { @@ -67,21 +67,21 @@ type Config struct { LogPath string `toml:"log-path"` Metric struct { - Service string `toml:"service"` - Host string `toml:"host"` - PollingInterval Duration `toml:"poll-interval"` + Service string `toml:"service"` + Host string `toml:"host"` + PollInterval Duration `toml:"poll-interval"` } `toml:"metric"` } // NewConfig returns an instance of Config with default options. func NewConfig() *Config { c := &Config{ - Host: DefaultHost + ":" + DefaultPort, + Bind: DefaultHost + ":" + DefaultPort, MaxWritesPerRequest: DefaultMaxWritesPerRequest, } c.Cluster.ReplicaN = DefaultReplicaN c.Cluster.Type = DefaultClusterType - c.Cluster.PollingInterval = Duration(DefaultPollingInterval) + c.Cluster.PollInterval = Duration(DefaultPollingInterval) c.Cluster.Hosts = []string{} c.Cluster.InternalHosts = []string{} c.AntiEntropy.Interval = Duration(DefaultAntiEntropyInterval) diff --git a/ctl/server.go b/ctl/server.go index b1b77a71a..cde11424b 100644 --- a/ctl/server.go +++ b/ctl/server.go @@ -25,12 +25,12 @@ import ( func BuildServerFlags(cmd *cobra.Command, srv *server.Command) { flags := cmd.Flags() flags.StringVarP(&srv.Config.DataDir, "data-dir", "d", "~/.pilosa", "Directory to store pilosa data files.") - flags.StringVarP(&srv.Config.Host, "bind", "b", ":10101", "Default URI on which pilosa should listen.") + flags.StringVarP(&srv.Config.Bind, "bind", "b", ":10101", "Default URI on which pilosa should listen.") flags.IntVarP(&srv.Config.MaxWritesPerRequest, "max-writes-per-request", "", srv.Config.MaxWritesPerRequest, "Number of write commands per request.") flags.IntVarP(&srv.Config.Cluster.ReplicaN, "cluster.replicas", "", 1, "Number of hosts each piece of data should be stored on.") flags.StringSliceVarP(&srv.Config.Cluster.Hosts, "cluster.hosts", "", []string{}, "Comma separated list of hosts in cluster.") flags.StringSliceVarP(&srv.Config.Cluster.InternalHosts, "cluster.internal-hosts", "", []string{}, "Comma separated list of hosts in cluster used for internal communication.") - flags.DurationVarP((*time.Duration)(&srv.Config.Cluster.PollingInterval), "cluster.poll-interval", "", time.Minute, "Polling interval for cluster.") // TODO what actually is this? + flags.DurationVarP((*time.Duration)(&srv.Config.Cluster.PollInterval), "cluster.poll-interval", "", time.Minute, "Polling interval for cluster.") // TODO what actually is this? flags.DurationVarP((*time.Duration)(&srv.Config.Cluster.LongQueryTime), "cluster.long-query-time", "", time.Minute, "Long Query Time.") flags.StringVarP(&srv.Config.Plugins.Path, "plugins.path", "", "", "Path to plugin directory.") flags.StringVar(&srv.Config.LogPath, "log-path", "", "Log path") @@ -42,5 +42,5 @@ func BuildServerFlags(cmd *cobra.Command, srv *server.Command) { flags.StringVarP(&srv.Config.Cluster.InternalPort, "cluster.internal-port", "", "", "Port to which pilosa should bind for internal state sharing.") flags.StringVarP(&srv.Config.Metric.Service, "metric.service", "", "nop", "Default URI on which pilosa should listen.") flags.StringVarP(&srv.Config.Metric.Host, "metric.host", "", "", "Default URI to send metrics.") - flags.DurationVarP((*time.Duration)(&srv.Config.Metric.PollingInterval), "metric.poll-interval", "", time.Minute*0, "Polling interval metrics.") + flags.DurationVarP((*time.Duration)(&srv.Config.Metric.PollInterval), "metric.poll-interval", "", time.Minute*0, "Polling interval metrics.") } diff --git a/server/server.go b/server/server.go index f66b88870..fd4462be9 100644 --- a/server/server.go +++ b/server/server.go @@ -131,7 +131,7 @@ func (m *Command) SetupServer() error { // Configure holder. m.Server.Logger().Printf("Using data from: %s\n", m.Config.DataDir) m.Server.Holder.Path = m.Config.DataDir - m.Server.MetricInterval = time.Duration(m.Config.Metric.PollingInterval) + m.Server.MetricInterval = time.Duration(m.Config.Metric.PollInterval) m.Server.Holder.Stats, err = NewStatsClient(m.Config.Metric.Service, m.Config.Metric.Host) if err != nil { return err @@ -142,7 +142,7 @@ func (m *Command) SetupServer() error { // Copy configuration flags. m.Server.MaxWritesPerRequest = m.Config.MaxWritesPerRequest - m.Server.Host, err = normalizeHost(m.Config.Host) + m.Server.Host, err = normalizeHost(m.Config.Bind) if err != nil { return err } @@ -172,11 +172,11 @@ func (m *Command) SetupServer() error { gossipSeed = m.Config.Cluster.GossipSeed } // get the host portion of addr to use for binding - gossipHost, _, err := net.SplitHostPort(m.Config.Host) + gossipHost, _, err := net.SplitHostPort(m.Config.Bind) if err != nil { - gossipHost = m.Config.Host + gossipHost = m.Config.Bind } - gossipNodeSet := gossip.NewGossipNodeSet(m.Config.Host, gossipHost, gossipPort, gossipSeed, m.Server) + gossipNodeSet := gossip.NewGossipNodeSet(m.Config.Bind, gossipHost, gossipPort, gossipSeed, m.Server) m.Server.Cluster.NodeSet = gossipNodeSet m.Server.Broadcaster = gossipNodeSet m.Server.BroadcastReceiver = gossipNodeSet diff --git a/server/server_test.go b/server/server_test.go index 72c8243e3..094d23ae8 100644 --- a/server/server_test.go +++ b/server/server_test.go @@ -348,8 +348,8 @@ func TestMain_FrameRestore(t *testing.T) { func TestConfig_Parse_Host(t *testing.T) { if c, err := ParseConfig(`bind = "local"`); err != nil { t.Fatal(err) - } else if c.Host != "local" { - t.Fatalf("unexpected host: %s", c.Host) + } else if c.Bind != "local" { + t.Fatalf("unexpected host: %s", c.Bind) } } @@ -583,7 +583,7 @@ func NewMain() *Main { m := &Main{Command: server.NewCommand(os.Stdin, os.Stdout, os.Stderr)} m.Server.Network = *test.Network m.Config.DataDir = path - m.Config.Host = "localhost:0" + m.Config.Bind = "localhost:0" m.Command.Stdin = &m.Stdin m.Command.Stdout = &m.Stdout m.Command.Stderr = &m.Stderr