Exemplo n.º 1
0
// NewConfig returns the default configuration for tsdb.
func NewConfig() Config {
	return Config{
		Engine:                 DefaultEngine,
		Enabled:                true, // data node enabled by default
		MaxWALSize:             DefaultMaxWALSize,
		WALFlushInterval:       toml.Duration(DefaultWALFlushInterval),
		WALPartitionFlushDelay: toml.Duration(DefaultWALPartitionFlushDelay),

		WALLoggingEnabled:         true,
		WALReadySeriesSize:        DefaultReadySeriesSize,
		WALCompactionThreshold:    DefaultCompactionThreshold,
		WALMaxSeriesSize:          DefaultMaxSeriesSize,
		WALFlushColdInterval:      toml.Duration(DefaultFlushColdInterval),
		WALPartitionSizeThreshold: DefaultPartitionSizeThreshold,

		QueryLogEnabled: true,

		CacheMaxMemorySize:             DefaultCacheMaxMemorySize,
		CacheSnapshotMemorySize:        DefaultCacheSnapshotMemorySize,
		CacheSnapshotWriteColdDuration: toml.Duration(DefaultCacheSnapshotWriteColdDuration),
		CompactFullWriteColdDuration:   toml.Duration(DefaultCompactFullWriteColdDuration),

		DataLoggingEnabled: true,
	}
}
Exemplo n.º 2
0
// NewConfig returns a new Config with defaults.
func NewConfig() Config {
	return Config{
		Enabled:       true,
		CheckInterval: toml.Duration(DefaultCheckInterval),
		AdvancePeriod: toml.Duration(DefaultAdvancePeriod),
	}
}
Exemplo n.º 3
0
// NewConfig returns an instance of Config with defaults.
func NewConfig() Config {
	return Config{
		WriteTimeout:              toml.Duration(DefaultWriteTimeout),
		ShardWriterTimeout:        toml.Duration(DefaultShardWriterTimeout),
		ShardMapperTimeout:        toml.Duration(DefaultShardMapperTimeout),
		MaxRemoteWriteConnections: DefaultMaxRemoteWriteConnections,
	}
}
Exemplo n.º 4
0
// NewConfig returns an instance of Config with defaults.
func NewConfig() Config {
	return Config{
		WriteTimeout:         toml.Duration(DefaultWriteTimeout),
		QueryTimeout:         toml.Duration(influxql.DefaultQueryTimeout),
		MaxConcurrentQueries: DefaultMaxConcurrentQueries,
		MaxSelectPointN:      DefaultMaxSelectPointN,
		MaxSelectSeriesN:     DefaultMaxSelectSeriesN,
	}
}
Exemplo n.º 5
0
// NewConfig returns an instance of Config with defaults.
func NewConfig() Config {
	return Config{
		WriteTimeout:              toml.Duration(DefaultWriteTimeout),
		ShardWriterTimeout:        toml.Duration(DefaultShardWriterTimeout),
		ShardMapperTimeout:        toml.Duration(DefaultShardMapperTimeout),
		QueryTimeout:              toml.Duration(DefaultQueryTimeout),
		MaxRemoteWriteConnections: DefaultMaxRemoteWriteConnections,
		MaxConcurrentQueries:      DefaultMaxConcurrentQueries,
		MaxSelectSeriesN:          DefaultMaxSelectSeriesN,
	}
}
Exemplo n.º 6
0
func (c *Config) Init() {
	c.Name = "default"
	c.URLs = []string{"http://localhost:8086"}
	c.ExcludedSubscriptions = map[string][]string{
		stats.DefaultDatabse: []string{stats.DefaultRetentionPolicy},
	}
	c.UDPBuffer = udp.DefaultBuffer
	c.StartUpTimeout = toml.Duration(DefaultStartUpTimeout)
	c.SubscriptionProtocol = DefaultSubscriptionProtocol
	c.SubscriptionSyncInterval = toml.Duration(DefaultSubscriptionSyncInterval)
}
Exemplo n.º 7
0
// NewConfig returns a new Config.
func NewConfig() Config {
	return Config{
		Enabled:          false,
		MaxSize:          DefaultMaxSize,
		MaxAge:           toml.Duration(DefaultMaxAge),
		RetryRateLimit:   DefaultRetryRateLimit,
		RetryInterval:    toml.Duration(DefaultRetryInterval),
		RetryMaxInterval: toml.Duration(DefaultRetryMaxInterval),
		PurgeInterval:    toml.Duration(DefaultPurgeInterval),
	}
}
Exemplo n.º 8
0
func (c *Config) SetDefaultValues() {
	if c.UDPBuffer == 0 {
		c.UDPBuffer = udp.DefaultBuffer
	}
	if c.StartUpTimeout == 0 {
		c.StartUpTimeout = toml.Duration(DefaultStartUpTimeout)
	}
	if c.SubscriptionProtocol == "" {
		c.SubscriptionProtocol = DefaultSubscriptionProtocol
	}
	if c.SubscriptionSyncInterval == toml.Duration(0) {
		c.SubscriptionSyncInterval = toml.Duration(DefaultSubscriptionSyncInterval)
	}
}
Exemplo n.º 9
0
// NewConfig builds a new configuration with default values.
func NewConfig() *Config {
	return &Config{
		Enabled:              true, // enabled by default
		BindAddress:          DefaultRaftBindAddress,
		HTTPBindAddress:      DefaultHTTPBindAddress,
		RetentionAutoCreate:  true,
		ElectionTimeout:      toml.Duration(DefaultElectionTimeout),
		HeartbeatTimeout:     toml.Duration(DefaultHeartbeatTimeout),
		LeaderLeaseTimeout:   toml.Duration(DefaultLeaderLeaseTimeout),
		CommitTimeout:        toml.Duration(DefaultCommitTimeout),
		RaftPromotionEnabled: DefaultRaftPromotionEnabled,
		LeaseDuration:        toml.Duration(DefaultLeaseDuration),
		LoggingEnabled:       DefaultLoggingEnabled,
	}
}
Exemplo n.º 10
0
// NewInfluxDBConfig returns a new InfluxDBConfig with the default values.
func NewInfluxDBConfig() (*InfluxDBConfig, error) {
	// Create the default InfluxDB server configuration.
	server, err := influxDBServer.NewDemoConfig()
	if err != nil {
		return nil, err
	}

	// Enables retention policies which will be executed within an interval of 30 minutes.
	server.Retention.Enabled = true
	server.Retention.CheckInterval = toml.Duration(30 * time.Minute)

	return &InfluxDBConfig{
		Server: server,

		// Specify the branch as "appdash" just for identification purposes.
		BuildInfo: &influxDBServer.BuildInfo{
			Branch: "appdash",
		},

		// Create a retention policy which keeps data for only three days, this is
		// because the Dashboard is hard-coded to displaying a 72hr timeline.
		//
		// Minimum duration time is 1 hour ("1h") - See: github.com/influxdata/influxdb/issues/5198
		DefaultRP: InfluxDBRetentionPolicy{
			Name:     "three_days_only",
			Duration: "3d",
		},

		MaxBatchSizeBytes:  128 * 1024 * 1024, // 128 MB
		BatchFlushInterval: 500 * time.Millisecond,
	}, nil
}
Exemplo n.º 11
0
// WithDefaults takes the given config and returns a new config with any required
// default values set.
func (c *Config) WithDefaults() *Config {
	d := *c
	if d.BindAddress == "" {
		d.BindAddress = DefaultBindAddress
	}
	if d.Database == "" {
		d.Database = DefaultDatabase
	}
	if d.RetentionPolicy == "" {
		d.RetentionPolicy = DefaultRetentionPolicy
	}
	if d.ConsistencyLevel == "" {
		d.ConsistencyLevel = DefaultConsistencyLevel
	}
	if d.Certificate == "" {
		d.Certificate = DefaultCertificate
	}
	if d.BatchSize == 0 {
		d.BatchSize = DefaultBatchSize
	}
	if d.BatchPending == 0 {
		d.BatchPending = DefaultBatchPending
	}
	if d.BatchTimeout == 0 {
		d.BatchTimeout = toml.Duration(DefaultBatchTimeout)
	}

	return &d
}
Exemplo n.º 12
0
func NewConfig() Config {
	return Config{
		Host:        "localhost",
		Port:        25,
		IdleTimeout: toml.Duration(time.Second * 30),
	}
}
Exemplo n.º 13
0
// NewConfig returns the default configuration for tsdb.
func NewConfig() Config {
	return Config{
		Engine: DefaultEngine,

		WALLoggingEnabled: true,

		QueryLogEnabled: true,

		CacheMaxMemorySize:             DefaultCacheMaxMemorySize,
		CacheSnapshotMemorySize:        DefaultCacheSnapshotMemorySize,
		CacheSnapshotWriteColdDuration: toml.Duration(DefaultCacheSnapshotWriteColdDuration),
		CompactFullWriteColdDuration:   toml.Duration(DefaultCompactFullWriteColdDuration),

		DataLoggingEnabled: true,
	}
}
Exemplo n.º 14
0
func NewTestService(batchSize int, batchDuration time.Duration) *TestService {
	c := Config{
		BindAddress:   "127.0.0.1:0",
		Database:      "collectd_test",
		BatchSize:     batchSize,
		BatchDuration: toml.Duration(batchDuration),
	}

	s := &TestService{
		Config:     c,
		Service:    NewService(c),
		MetaClient: &internal.MetaClientMock{},
	}

	s.MetaClient.CreateDatabaseFn = func(name string) (*meta.DatabaseInfo, error) {
		return nil, nil
	}

	s.Service.PointsWriter = s
	s.Service.MetaClient = s.MetaClient

	// Set the collectd types using test string.
	if err := s.Service.SetTypes(typesDBText); err != nil {
		panic(err)
	}

	if testing.Verbose() {
		s.Service.WithLogger(zap.New(
			zap.NewTextEncoder(),
			zap.Output(os.Stderr),
		))
	}

	return s
}
Exemplo n.º 15
0
// NewConfig returns a new instance of Config with defaults.
func NewConfig() Config {
	return Config{
		LogEnabled:  true,
		Enabled:     true,
		RunInterval: toml.Duration(DefaultRunInterval),
	}
}
Exemplo n.º 16
0
// WithDefaults takes the given config and returns a new config with any required
// default values set.
func (c *Config) WithDefaults() *Config {
	d := *c
	if d.Database == "" {
		d.Database = DefaultDatabase
	}
	if d.BatchSize == 0 {
		d.BatchSize = DefaultBatchSize
	}
	if d.BatchPending == 0 {
		d.BatchPending = DefaultBatchPending
	}
	if d.BatchTimeout == 0 {
		d.BatchTimeout = toml.Duration(DefaultBatchTimeout)
	}
	if d.Precision == "" {
		d.Precision = DefaultPrecision
	}
	if d.ReadBuffer == 0 {
		d.ReadBuffer = DefaultReadBuffer
	}
	if d.UDPPayloadSize == 0 {
		d.UDPPayloadSize = DefaultUDPPayloadSize
	}
	return &d
}
Exemplo n.º 17
0
// NewConfig returns an instance of Config with defaults.
func NewConfig() Config {
	return Config{
		StoreEnabled:  true,
		StoreDatabase: DefaultStoreDatabase,
		StoreInterval: toml.Duration(DefaultStoreInterval),
	}
}
Exemplo n.º 18
0
// Ensure the shard writer returns an error when we can't get a connection.
func TestShardWriter_Write_PoolMax(t *testing.T) {
	ts := newTestWriteService(writeShardSlow)
	s := cluster.NewService(cluster.Config{
		ShardWriterTimeout: toml.Duration(100 * time.Millisecond),
	})
	s.Listener = ts.muxln
	s.TSDBStore = &ts.TSDBStore
	if err := s.Open(); err != nil {
		t.Fatal(err)
	}
	defer s.Close()
	defer ts.Close()

	w := cluster.NewShardWriter(100*time.Millisecond, 1)
	w.MetaClient = &metaClient{host: ts.ln.Addr().String()}
	now := time.Now()

	shardID := uint64(1)
	ownerID := uint64(2)
	var points []models.Point
	points = append(points, models.MustNewPoint(
		"cpu", models.Tags{"host": "server01"}, map[string]interface{}{"value": int64(100)}, now,
	))

	go w.WriteShard(shardID, ownerID, points)
	time.Sleep(time.Millisecond)
	if err := w.WriteShard(shardID, ownerID, points); err == nil || err.Error() != "timed out waiting for free connection" {
		t.Fatalf("unexpected error: %v", err)
	}
}
Exemplo n.º 19
0
// NewConfig builds a new configuration with default values.
func NewConfig() *Config {
	return &Config{
		RetentionAutoCreate: true,
		LeaseDuration:       toml.Duration(DefaultLeaseDuration),
		LoggingEnabled:      DefaultLoggingEnabled,
	}
}
Exemplo n.º 20
0
// WithDefaults takes the given config and returns a new config with any required
// default values set.
func (c *Config) WithDefaults() *Config {
	d := *c
	if d.BindAddress == "" {
		d.BindAddress = DefaultBindAddress
	}
	if d.Database == "" {
		d.Database = DefaultDatabase
	}
	if d.Protocol == "" {
		d.Protocol = DefaultProtocol
	}
	if d.BatchSize == 0 {
		d.BatchSize = DefaultBatchSize
	}
	if d.BatchPending == 0 {
		d.BatchPending = DefaultBatchPending
	}
	if d.BatchTimeout == 0 {
		d.BatchTimeout = toml.Duration(DefaultBatchTimeout)
	}
	if d.ConsistencyLevel == "" {
		d.ConsistencyLevel = DefaultConsistencyLevel
	}
	if d.Separator == "" {
		d.Separator = DefaultSeparator
	}
	if d.UDPReadBuffer == 0 {
		d.UDPReadBuffer = DefaultUDPReadBuffer
	}
	return &d
}
Exemplo n.º 21
0
// NewConfig returns the default configuration for tsdb.
func NewConfig() Config {
	return Config{
		Engine: DefaultEngine,

		QueryLogEnabled: true,

		CacheMaxMemorySize:             DefaultCacheMaxMemorySize,
		CacheSnapshotMemorySize:        DefaultCacheSnapshotMemorySize,
		CacheSnapshotWriteColdDuration: toml.Duration(DefaultCacheSnapshotWriteColdDuration),
		CompactFullWriteColdDuration:   toml.Duration(DefaultCompactFullWriteColdDuration),

		MaxSeriesPerDatabase: DefaultMaxSeriesPerDatabase,
		MaxValuesPerTag:      DefaultMaxValuesPerTag,

		TraceLoggingEnabled: false,
	}
}
Exemplo n.º 22
0
func newConfig() *meta.Config {
	cfg := meta.NewConfig()
	cfg.BindAddress = "127.0.0.1:0"
	cfg.HTTPBindAddress = "127.0.0.1:0"
	cfg.Dir = testTempDir(2)
	cfg.LeaseDuration = toml.Duration(1 * time.Second)
	return cfg
}
Exemplo n.º 23
0
func Test_Service_UDP(t *testing.T) {
	t.Parallel()

	now := time.Now().UTC().Round(time.Second)

	config := Config{}
	config.Database = "graphitedb"
	config.BatchSize = 0 // No batching.
	config.BatchTimeout = toml.Duration(time.Second)
	config.BindAddress = ":10000"
	config.Protocol = "udp"

	service := NewTestService(&config)

	// Allow test to wait until points are written.
	var wg sync.WaitGroup
	wg.Add(1)

	service.WritePointsFn = func(database, retentionPolicy string, consistencyLevel models.ConsistencyLevel, points []models.Point) error {
		defer wg.Done()

		pt, _ := models.NewPoint(
			"cpu",
			models.NewTags(map[string]string{}),
			map[string]interface{}{"value": 23.456},
			time.Unix(now.Unix(), 0))
		if database != "graphitedb" {
			t.Fatalf("unexpected database: %s", database)
		} else if retentionPolicy != "" {
			t.Fatalf("unexpected retention policy: %s", retentionPolicy)
		} else if points[0].String() != pt.String() {
			t.Fatalf("unexpected points: %#v", points[0].String())
		}
		return nil
	}

	if err := service.Service.Open(); err != nil {
		t.Fatalf("failed to open Graphite service: %s", err.Error())
	}

	// Connect to the graphite endpoint we just spun up
	_, port, _ := net.SplitHostPort(service.Service.Addr().String())
	conn, err := net.Dial("udp", "127.0.0.1:"+port)
	if err != nil {
		t.Fatal(err)
	}
	data := []byte(`cpu 23.456 `)
	data = append(data, []byte(fmt.Sprintf("%d", now.Unix()))...)
	data = append(data, '\n')
	_, err = conn.Write(data)
	if err != nil {
		t.Fatal(err)
	}

	wg.Wait()
	conn.Close()
}
Exemplo n.º 24
0
func NewConfig() Config {
	return Config{
		Host:        "localhost",
		Port:        25,
		Username:    "",
		Password:    "",
		IdleTimeout: toml.Duration(time.Second * 30),
	}
}
Exemplo n.º 25
0
func NewConfig() Config {
	return Config{
		Enabled: true,
		// Cannot initialize slice
		// See: https://github.com/BurntSushi/toml/pull/68
		//URLs:          []string{"http://localhost:8086"},
		Username:      "",
		Password:      "",
		Subscriptions: make(map[string][]string),
		ExcludedSubscriptions: map[string][]string{
			stats.DefaultDatabse: []string{stats.DefaultRetentionPolicy},
		},
		UDPBuffer:                udp.DefaultBuffer,
		StartUpTimeout:           toml.Duration(DefaultStartUpTimeout),
		SubscriptionProtocol:     DefaultSubscriptionProtocol,
		SubscriptionSyncInterval: toml.Duration(DefaultSubscriptionSyncInterval),
	}
}
Exemplo n.º 26
0
// NewConfig returns a new instance of a subscriber config.
func NewConfig() Config {
	return Config{
		Enabled:            true,
		HTTPTimeout:        toml.Duration(DefaultHTTPTimeout),
		InsecureSkipVerify: false,
		CaCerts:            "",
		WriteConcurrency:   DefaultWriteConcurrency,
		WriteBufferSize:    DefaultWriteBufferSize,
	}
}
Exemplo n.º 27
0
// NewConfig returns a new instance of Config with defaults.
func NewConfig() Config {
	return Config{
		BindAddress:     DefaultBindAddress,
		Database:        DefaultDatabase,
		RetentionPolicy: DefaultRetentionPolicy,
		BatchSize:       DefaultBatchSize,
		BatchPending:    DefaultBatchPending,
		BatchTimeout:    toml.Duration(DefaultBatchTimeout),
	}
}
Exemplo n.º 28
0
// NewConfig returns a new instance of Config with defaults.
func NewConfig() Config {
	return Config{
		BindAddress:      DefaultBindAddress,
		Database:         DefaultDatabase,
		Protocol:         DefaultProtocol,
		BatchSize:        DefaultBatchSize,
		BatchPending:     DefaultBatchPending,
		BatchTimeout:     toml.Duration(DefaultBatchTimeout),
		ConsistencyLevel: DefaultConsistencyLevel,
		Separator:        DefaultSeparator,
	}
}
Exemplo n.º 29
0
func TestConfig_Encode(t *testing.T) {
	var c run.Config
	c.Coordinator.WriteTimeout = itoml.Duration(time.Minute)
	buf := new(bytes.Buffer)
	if err := toml.NewEncoder(buf).Encode(&c); err != nil {
		t.Fatal("Failed to encode: ", err)
	}
	got, search := buf.String(), `write-timeout = "1m0s"`
	if !strings.Contains(got, search) {
		t.Fatalf("Encoding config failed.\nfailed to find %s in:\n%s\n", search, got)
	}
}
Exemplo n.º 30
0
// NewConfig returns the default config with temporary paths.
func NewConfig() *run.Config {
	c := run.NewConfig()
	c.ReportingDisabled = true
	c.Cluster.ShardWriterTimeout = toml.Duration(30 * time.Second)
	c.Cluster.WriteTimeout = toml.Duration(30 * time.Second)
	c.Meta.Dir = MustTempFile()
	c.Meta.BindAddress = "127.0.0.1:0"
	c.Meta.HTTPBindAddress = "127.0.0.1:0"
	c.Meta.HeartbeatTimeout = toml.Duration(50 * time.Millisecond)
	c.Meta.ElectionTimeout = toml.Duration(50 * time.Millisecond)
	c.Meta.LeaderLeaseTimeout = toml.Duration(50 * time.Millisecond)
	c.Meta.CommitTimeout = toml.Duration(5 * time.Millisecond)

	if !testing.Verbose() {
		c.Meta.LoggingEnabled = false
	}

	c.Data.Dir = MustTempFile()
	c.Data.WALDir = MustTempFile()
	c.Data.WALLoggingEnabled = false

	c.HintedHandoff.Dir = MustTempFile()

	c.HTTPD.Enabled = true
	c.HTTPD.BindAddress = "127.0.0.1:0"
	c.HTTPD.LogEnabled = testing.Verbose()

	c.Monitor.StoreEnabled = false

	return c
}