forked from thanos-io/thanos
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: akanshat <[email protected]>
- Loading branch information
Showing
4 changed files
with
92 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// Copyright (c) The Thanos Authors. | ||
// Licensed under the Apache License 2.0. | ||
|
||
package cacheconfig | ||
|
||
import ( | ||
"regexp" | ||
"strings" | ||
"time" | ||
|
||
"github.com/thanos-io/thanos/pkg/block/metadata" | ||
"github.com/thanos-io/thanos/pkg/model" | ||
) | ||
|
||
// BucketCacheProvider is a type used to evaluate all bucket cache providers. | ||
type BucketCacheProvider string | ||
|
||
// CachingWithBackendConfig is a configuration of caching bucket used by Store component. | ||
type CachingWithBackendConfig struct { | ||
Type BucketCacheProvider `yaml:"type"` | ||
BackendConfig interface{} `yaml:"config"` | ||
|
||
// Basic unit used to cache chunks. | ||
ChunkSubrangeSize int64 `yaml:"chunk_subrange_size"` | ||
|
||
// Maximum number of GetRange requests issued by this bucket for single GetRange call. Zero or negative value = unlimited. | ||
MaxChunksGetRangeRequests int `yaml:"max_chunks_get_range_requests"` | ||
|
||
MetafileMaxSize model.Bytes `yaml:"metafile_max_size"` | ||
|
||
// TTLs for various cache items. | ||
ChunkObjectAttrsTTL time.Duration `yaml:"chunk_object_attrs_ttl"` | ||
ChunkSubrangeTTL time.Duration `yaml:"chunk_subrange_ttl"` | ||
|
||
// How long to cache result of Iter call in root directory. | ||
BlocksIterTTL time.Duration `yaml:"blocks_iter_ttl"` | ||
|
||
// Config for Exists and Get operations for metadata files. | ||
MetafileExistsTTL time.Duration `yaml:"metafile_exists_ttl"` | ||
MetafileDoesntExistTTL time.Duration `yaml:"metafile_doesnt_exist_ttl"` | ||
MetafileContentTTL time.Duration `yaml:"metafile_content_ttl"` | ||
} | ||
|
||
func (cfg *CachingWithBackendConfig) Defaults() { | ||
cfg.ChunkSubrangeSize = 16000 // Equal to max chunk size. | ||
cfg.ChunkObjectAttrsTTL = 24 * time.Hour | ||
cfg.ChunkSubrangeTTL = 24 * time.Hour | ||
cfg.MaxChunksGetRangeRequests = 3 | ||
cfg.BlocksIterTTL = 5 * time.Minute | ||
cfg.MetafileExistsTTL = 2 * time.Hour | ||
cfg.MetafileDoesntExistTTL = 15 * time.Minute | ||
cfg.MetafileContentTTL = 24 * time.Hour | ||
cfg.MetafileMaxSize = 1024 * 1024 // Equal to default MaxItemSize in memcached client. | ||
} | ||
|
||
var chunksMatcher = regexp.MustCompile(`^.*/chunks/\d+$`) | ||
|
||
func IsTSDBChunkFile(name string) bool { return chunksMatcher.MatchString(name) } | ||
|
||
func IsMetaFile(name string) bool { | ||
return strings.HasSuffix(name, "/"+metadata.MetaFilename) || strings.HasSuffix(name, "/"+metadata.DeletionMarkFilename) | ||
} | ||
|
||
func IsBlocksRootDir(name string) bool { return name == "" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters