Address code review feedback

This commit is contained in:
Cody Soyland 2018-09-20 16:05:28 -05:00
parent ebc4d7fc13
commit 52ba336461
7 changed files with 22 additions and 39 deletions

View file

@ -45,7 +45,7 @@ func BuildServerFlags(cmd *cobra.Command, srv *server.Command) {
// Translation
flags.StringVarP(&srv.Config.Translation.PrimaryURL, "translation.primary-url", "", srv.Config.Translation.PrimaryURL, "DEPRECATED: URL for primary translation node for replication.")
flags.IntVarP(&srv.Config.Translation.MapSize, "translation.map-size", "", srv.Config.Translation.MapSize, "Size of mmap to allocate for key translation.")
flags.IntVarP(&srv.Config.Translation.MapSize, "translation.map-size", "", srv.Config.Translation.MapSize, "Size in bytes of mmap to allocate for key translation.")
// Gossip
flags.StringVarP(&srv.Config.Gossip.Port, "gossip.port", "", srv.Config.Gossip.Port, "Port to which pilosa should bind for internal state sharing.")

View file

@ -307,6 +307,18 @@ The config file is in the [toml format](https://github.com/toml-lang/toml) and h
skip-verify = true
```
#### Translation Map Size
* Description: Size in bytes of mmap to allocate for key translation
* Flag: `translation.map-size`
* Env: `PILOSA_TRANSLATION_MAP_SIZE`
* Config:
```toml
[translation]
map-size = 10737418240
```
### Example Cluster Configuration
A three node cluster running on different hosts could be minimally configured as follows:

View file

@ -77,19 +77,9 @@ type Holder struct {
Logger Logger
}
// HolderOption is a functional option type for pilosa.Holder
type HolderOption func(f *Holder) error
func OptHolderTranslateFileMapSize(mapSize int) HolderOption {
return func(h *Holder) error {
h.translateFile = NewTranslateFile(OptTranslateFileMapSize(mapSize))
return nil
}
}
// NewHolder returns a new instance of Holder.
func NewHolder(opts ...HolderOption) *Holder {
h := &Holder{
func NewHolder() *Holder {
return &Holder{
indexes: make(map[string]*Index),
closing: make(chan struct{}),
@ -107,15 +97,6 @@ func NewHolder(opts ...HolderOption) *Holder {
Logger: NopLogger,
}
for _, opt := range opts {
err := opt(h)
if err != nil {
// TODO (2.0): Change func signature to return error
panic(errors.Wrap(err, "applying option"))
}
}
return h
}
// Open initializes the root data directory for the holder.

View file

@ -234,14 +234,9 @@ func OptServerClusterHasher(h Hasher) ServerOption {
}
}
func OptServerHolderOptions(opts ...HolderOption) ServerOption {
func OptServerTranslateFileMapSize(mapSize int) ServerOption {
return func(s *Server) error {
for _, opt := range opts {
err := opt(s.holder)
if err != nil {
return errors.Wrap(err, "applying option")
}
}
s.holder.translateFile = NewTranslateFile(OptTranslateFileMapSize(mapSize))
return nil
}
}

View file

@ -286,10 +286,8 @@ func (m *Command) SetupServer() error {
if m.Config.Translation.MapSize > 0 {
serverOptions = append(
serverOptions,
pilosa.OptServerHolderOptions(
pilosa.OptHolderTranslateFileMapSize(
m.Config.Translation.MapSize,
),
pilosa.OptServerTranslateFileMapSize(
m.Config.Translation.MapSize,
),
)
}

View file

@ -64,10 +64,8 @@ func newCommand(opts ...server.CommandOption) *Command {
opts = append([]server.CommandOption{
server.OptCommandCloseTimeout(time.Millisecond * 2),
server.OptCommandServerOptions(
pilosa.OptServerHolderOptions(
pilosa.OptHolderTranslateFileMapSize(
2 << 25,
),
pilosa.OptServerTranslateFileMapSize(
2 << 25,
),
),
}, opts...)

View file

@ -93,7 +93,7 @@ func OptTranslateFileMapSize(mapSize int) TranslateFileOption {
// NewTranslateFile returns a new instance of TranslateFile.
func NewTranslateFile(opts ...TranslateFileOption) *TranslateFile {
var defaultMapSize64 int64 = 1 << 33
var defaultMapSize64 int64 = 10 * (1 << 30)
var defaultMapSize int
if ^uint(0)>>32 > 0 {
@ -103,7 +103,6 @@ func NewTranslateFile(opts ...TranslateFileOption) *TranslateFile {
// Use 2GB default map size on 32-bit systems
defaultMapSize = (1 << 31) - 1
}
f := &TranslateFile{
writeNotify: make(chan struct{}),
closing: make(chan struct{}),