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

proxy: enable tcp keepalive and add options for tuning. #357

Merged
merged 1 commit into from
Sep 22, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
21 changes: 21 additions & 0 deletions cmd/proxy/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ type config struct {
stopListening bool
logLevel string
debug bool

keepAliveIdle int
keepAliveCount int
keepAliveInterval int
}

var cfg config
Expand All @@ -73,6 +77,9 @@ func init() {
cmdProxy.PersistentFlags().BoolVar(&cfg.stopListening, "stop-listening", true, "stop listening on store error")
cmdProxy.PersistentFlags().StringVar(&cfg.logLevel, "log-level", "info", "debug, info (default), warn or error")
cmdProxy.PersistentFlags().BoolVar(&cfg.debug, "debug", false, "enable debug logging")
cmdProxy.PersistentFlags().IntVar(&cfg.keepAliveIdle, "tcp-keepalive-idle", 0, "set tcp keepalive idle (seconds)")
cmdProxy.PersistentFlags().IntVar(&cfg.keepAliveCount, "tcp-keepalive-count", 0, "set tcp keepalive probe count number")
cmdProxy.PersistentFlags().IntVar(&cfg.keepAliveInterval, "tcp-keepalive-interval", 0, "set tcp keepalive interval (seconds)")

cmdProxy.PersistentFlags().MarkDeprecated("debug", "use --log-level=debug instead")
}
Expand Down Expand Up @@ -155,6 +162,11 @@ func (c *ClusterChecker) startPollonProxy() error {
if err != nil {
return fmt.Errorf("error creating pollon proxy: %v", err)
}
pp.SetKeepAlive(true)
pp.SetKeepAliveIdle(time.Duration(cfg.keepAliveIdle) * time.Second)
pp.SetKeepAliveCount(cfg.keepAliveCount)
pp.SetKeepAliveInterval(time.Duration(cfg.keepAliveInterval) * time.Second)

c.pp = pp
c.listener = listener

Expand Down Expand Up @@ -366,6 +378,15 @@ func proxy(cmd *cobra.Command, args []string) {
if cfg.storeBackend == "" {
die("store backend type required")
}
if cfg.keepAliveIdle < 0 {
die("tcp keepalive idle value must be greater or equal to 0")
}
if cfg.keepAliveCount < 0 {
die("tcp keepalive idle value must be greater or equal to 0")
}
if cfg.keepAliveInterval < 0 {
die("tcp keepalive idle value must be greater or equal to 0")
}

uid := common.UID()
log.Infow("proxy uid", "uid", uid)
Expand Down
10 changes: 6 additions & 4 deletions glide.lock

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

2 changes: 1 addition & 1 deletion glide.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import:
- package: github.com/sgotti/gexpect
version: 0afc6c19f50a08b5f97f8c75f4b417f496d92377
- package: github.com/sorintlab/pollon
version: 279eb94a1432a0656f6da72d36f133dc68c2e064
version: 1213dda9f770439e1f0dc2dc30635de368d55619
- package: github.com/spf13/cobra
version: 9c28e4bbd74e5c3ed7aacbc552b2cab7cfdfe744
- package: github.com/spf13/pflag
Expand Down
8 changes: 4 additions & 4 deletions vendor/github.com/mitchellh/reflectwalk/location_string.go

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

28 changes: 28 additions & 0 deletions vendor/github.com/sorintlab/pollon/pollon.go

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

31 changes: 31 additions & 0 deletions vendor/github.com/sorintlab/pollon/tcpkeepalive.go

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

14 changes: 14 additions & 0 deletions vendor/github.com/sorintlab/pollon/tcpkeepalive_go18.go

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

Loading