func (c *JCtrlrConfig) GetChunkConfig() chunkfs.Config {
	return chunkfs.Config{
		CheckFullScan:     c.CheckFullScan,
		RecoverDisabled:   c.RecoverDisabled,
		RecoverLostDataOk: c.RecoverLostDataOk,
		WriteIdleSec:      c.WriteIdleSec,
		WriteFlushMs:      c.WriteFlushMs,
		MaxChunkSize:      c.MaxChunkSize,
		MaxRecordSize:     c.MaxRecordSize,
	}
}
GetChunkConfig returns chunkfs.Config object, which will be used for constructing
chunks
package server
import (
	"encoding/json"
	"fmt"
	"github.com/logrange/logrange/pkg/pipe"
	"github.com/logrange/range/pkg/records/chunk/chunkfs"
	"github.com/logrange/range/pkg/transport"
	"io/ioutil"
	"reflect"
	"time"
	"github.com/jrivets/log4g"
	"github.com/logrange/range/pkg/cluster"
	"github.com/logrange/range/pkg/cluster/model"
)
type Config struct {
	BaseDir string
	HostHostId cluster.HostId
	HostLeaseTTLSec int
	HostRegisterTimeoutSec int
	PublicApiRpc transport.Config
	PrivateApiRpc transport.Config
	JrnlCtrlConfig JCtrlrConfig
	PipesConfig pipe.PipesConfig
	NewTIndexOk bool
}
type JCtrlrConfig struct {
	JournalsDir string
	MaxOpenFileDescs int
	CheckFullScan bool
	RecoverDisabled bool
	RecoverLostDataOk bool
	WriteIdleSec int
	WriteFlushMs int
	MaxChunkSize int64
	MaxRecordSize int64
}
var configLog = log4g.GetLogger("Config")
func (c *Config) String() string {
	return fmt.Sprint(
		"\n\tBaseDir=", c.BaseDir,
		"\n\tHostHostId=", c.HostHostId,
		"\n\tHostLeaseTTLSec=", c.HostLeaseTTLSec,
		"\n\tHostRegisterTimeoutSec=", c.HostRegisterTimeoutSec,
		"\n\tPublicApiRpc=", c.PublicApiRpc,
		"\n\tPrivateApiRpc=", c.PrivateApiRpc,
		"\n\tJrnlCtrlConfig=", c.JrnlCtrlConfig,
		"\n\tNewTIndexOk=", c.NewTIndexOk,
		"\n\tPipesConfig=", c.PipesConfig,
	)
}
func GetDefaultConfig() *Config {
	c := new(Config)
	c.PublicApiRpc.ListenAddr = "127.0.0.1:9966"
	c.PrivateApiRpc.ListenAddr = "127.0.0.1:9967"
	c.HostLeaseTTLSec = 5
	c.BaseDir = "/opt/logrange/data"
	c.JrnlCtrlConfig = GetDefaultJCtrlrConfig()
	return c
}
func GetDefaultJCtrlrConfig() JCtrlrConfig {
	jcc := JCtrlrConfig{}
	jcc.MaxOpenFileDescs = 250
	jcc.WriteIdleSec = 30
	jcc.WriteFlushMs = 500
	jcc.MaxChunkSize = 100 * 1024 * 1024
	jcc.MaxRecordSize = 1 * 1024 * 1024
	return jcc
}
func (c *Config) HostId() cluster.HostId {
	return c.HostHostId
}
func (c *Config) Localhost() model.HostInfo {
	return model.HostInfo{RpcAddr: cluster.HostAddr(c.PrivateApiRpc.ListenAddr)}
}
func (c *Config) LeaseTTL() time.Duration {
	return time.Duration(c.HostLeaseTTLSec) * time.Second
}
func (c *Config) RegisterTimeout() time.Duration {
	return time.Duration(c.HostRegisterTimeoutSec) * time.Second
}
func (c *Config) Apply(cfg *Config) {
	if cfg == nil {
		return
	}
	c.JrnlCtrlConfig.Apply(&cfg.JrnlCtrlConfig)
	c.PipesConfig.Apply(&cfg.PipesConfig)
	if cfg.BaseDir != "" {
		c.BaseDir = cfg.BaseDir
	}
	if cfg.HostHostId > 0 {
		c.HostHostId = cfg.HostHostId
	}
	if !reflect.DeepEqual(c.PublicApiRpc, cfg.PublicApiRpc) {
		c.PublicApiRpc = cfg.PublicApiRpc
	}
	if !reflect.DeepEqual(c.PrivateApiRpc, cfg.PrivateApiRpc) {
		c.PrivateApiRpc = cfg.PrivateApiRpc
	}
	if cfg.HostLeaseTTLSec > 0 {
		c.HostLeaseTTLSec = cfg.HostLeaseTTLSec
	}
	if cfg.HostRegisterTimeoutSec > 0 {
		c.HostRegisterTimeoutSec = cfg.HostRegisterTimeoutSec
	}
}
func (c *JCtrlrConfig) Apply(cfg *JCtrlrConfig) {
	if cfg == nil {
		return
	}
	if len(cfg.JournalsDir) > 0 {
		c.JournalsDir = cfg.JournalsDir
	}
	if cfg.MaxOpenFileDescs > 0 {
		c.MaxOpenFileDescs = cfg.MaxOpenFileDescs
	}
	c.CheckFullScan = cfg.CheckFullScan
	c.RecoverDisabled = cfg.RecoverDisabled
	c.RecoverLostDataOk = cfg.RecoverLostDataOk
	if cfg.WriteIdleSec > 0 {
		c.WriteIdleSec = cfg.WriteIdleSec
	}
	if cfg.WriteFlushMs > 0 {
		c.WriteFlushMs = cfg.WriteFlushMs
	}
	if cfg.MaxChunkSize > 0 {
		c.MaxChunkSize = cfg.MaxChunkSize
	}
	if cfg.MaxRecordSize > 0 {
		c.MaxRecordSize = cfg.MaxRecordSize
	}
}
func (c *JCtrlrConfig) FdPoolSize() int {
	fps := 100
	if c.MaxOpenFileDescs > 0 {
		fps = c.MaxOpenFileDescs
	}
	return fps
}
func (c *JCtrlrConfig) StorageDir() string {
	return c.JournalsDir
}
func (c JCtrlrConfig) String() string {
	return fmt.Sprint(
		"\n\t{\n\t\tJournalsDir=", c.JournalsDir,
		"\n\t\tMaxOpenFileDescs=", c.MaxOpenFileDescs,
		"\n\t\tCheckFullScan=", c.CheckFullScan,
		"\n\t\tRecoverDisabled=", c.RecoverDisabled,
		"\n\t\tRecoverLostDataOk=", c.RecoverLostDataOk,
		"\n\t\tWriteIdleSec=", c.WriteIdleSec,
		"\n\t\tWriteFlushMs=", c.WriteFlushMs,
		"\n\t\tMaxChunkSize=", c.MaxChunkSize,
		"\n\t\tMaxRecordSize=", c.MaxRecordSize,
		"\n\t}",
	)
}