-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add partition ring to kafka ingest path
- Loading branch information
Showing
5 changed files
with
227 additions
and
53 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
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,47 @@ | ||
package partitionring | ||
|
||
import ( | ||
"flag" | ||
"time" | ||
|
||
"github.com/grafana/dskit/kv" | ||
"github.com/grafana/dskit/ring" | ||
) | ||
|
||
type PartitionRingConfig struct { | ||
KVStore kv.Config `yaml:"kvstore" doc:"description=The key-value store used to share the hash ring across multiple instances. This option needs be set on ingesters, distributors, queriers, and rulers when running in microservices mode."` | ||
|
||
// MinOwnersCount maps to ring.PartitionInstanceLifecyclerConfig's WaitOwnersCountOnPending. | ||
MinOwnersCount int `yaml:"min_partition_owners_count"` | ||
|
||
// MinOwnersDuration maps to ring.PartitionInstanceLifecyclerConfig's WaitOwnersDurationOnPending. | ||
MinOwnersDuration time.Duration `yaml:"min_partition_owners_duration"` | ||
|
||
// DeleteInactivePartitionAfter maps to ring.PartitionInstanceLifecyclerConfig's DeleteInactivePartitionAfterDuration. | ||
DeleteInactivePartitionAfter time.Duration `yaml:"delete_inactive_partition_after"` | ||
|
||
// lifecyclerPollingInterval is the lifecycler polling interval. This setting is used to lower it in tests. | ||
lifecyclerPollingInterval time.Duration | ||
} | ||
|
||
// RegisterFlags adds the flags required to config this to the given FlagSet | ||
func (cfg *PartitionRingConfig) RegisterFlags(f *flag.FlagSet) { | ||
// Ring flags | ||
cfg.KVStore.Store = "memberlist" // Override default value. | ||
cfg.KVStore.RegisterFlagsWithPrefix("ingester.partition-ring.", "collectors/", f) | ||
|
||
f.IntVar(&cfg.MinOwnersCount, "ingester.partition-ring.min-partition-owners-count", 1, "Minimum number of owners to wait before a PENDING partition gets switched to ACTIVE.") | ||
f.DurationVar(&cfg.MinOwnersDuration, "ingester.partition-ring.min-partition-owners-duration", 10*time.Second, "How long the minimum number of owners are enforced before a PENDING partition gets switched to ACTIVE.") | ||
f.DurationVar(&cfg.DeleteInactivePartitionAfter, "ingester.partition-ring.delete-inactive-partition-after", 13*time.Hour, "How long to wait before an INACTIVE partition is eligible for deletion. The partition is deleted only if it has been in INACTIVE state for at least the configured duration and it has no owners registered. A value of 0 disables partitions deletion.") | ||
} | ||
|
||
func (cfg *PartitionRingConfig) ToLifecyclerConfig(partitionID int32, instanceID string) ring.PartitionInstanceLifecyclerConfig { | ||
return ring.PartitionInstanceLifecyclerConfig{ | ||
PartitionID: partitionID, | ||
InstanceID: instanceID, | ||
WaitOwnersCountOnPending: cfg.MinOwnersCount, | ||
WaitOwnersDurationOnPending: cfg.MinOwnersDuration, | ||
DeleteInactivePartitionAfterDuration: cfg.DeleteInactivePartitionAfter, | ||
PollingInterval: cfg.lifecyclerPollingInterval, | ||
} | ||
} |
Oops, something went wrong.