Skip to content
This repository was archived by the owner on Aug 23, 2023. It is now read-only.

Commit

Permalink
consistency & diffability
Browse files Browse the repository at this point in the history
  • Loading branch information
Dieterbe committed Oct 16, 2018
1 parent 1553a5d commit 9561e0a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
19 changes: 10 additions & 9 deletions idx/bigtable/bigtable.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,17 @@ var (
// metric idx.bigtable.save.bytes-per-request is the number of bytes written to bigtable in each request.
statSaveBytesPerRequest = stats.NewMeter32("idx.bigtable.save.bytes-per-request", true)

Enabled bool
maxStale time.Duration
pruneInterval time.Duration
updateIdx bool
updateBigTableIdx bool
updateInterval time.Duration
updateInterval32 uint32

writeQueueSize int
writeConcurrency int
writeMaxFlushSize int

Enabled bool
bigtableInstance string
gcpProject string
tableName string
Expand All @@ -75,7 +76,7 @@ func ConfigSetup() {
btIdx.IntVar(&writeQueueSize, "write-queue-size", 100000, "Max number of metricDefs allowed to be unwritten to bigtable. Must be larger then write-max-flush-size")
btIdx.IntVar(&writeConcurrency, "write-concurrency", 5, "Number of writer threads to use")
btIdx.IntVar(&writeMaxFlushSize, "write-max-flush-size", 10000, "Max number of metricDefs in each batch write to bigtable")
btIdx.BoolVar(&updateIdx, "update-bigtable-index", true, "synchronize index changes to bigtable. not all your nodes need to do this.")
btIdx.BoolVar(&updateBigTableIdx, "update-bigtable-index", true, "synchronize index changes to bigtable. not all your nodes need to do this.")
btIdx.DurationVar(&updateInterval, "update-interval", time.Hour*3, "frequency at which we should update the metricDef lastUpdate field, use 0s for instant updates")
btIdx.DurationVar(&maxStale, "max-stale", 0, "clear series from the index if they have not been seen for this much time.")
btIdx.DurationVar(&pruneInterval, "prune-interval", time.Hour*3, "Interval at which the index should be checked for stale series.")
Expand Down Expand Up @@ -179,7 +180,7 @@ func New() *BigtableIdx {
tbl: client.Open(tableName),
shutdown: make(chan struct{}),
}
if updateIdx {
if updateBigTableIdx {
idx.writeQueue = make(chan writeReq, writeQueueSize-writeMaxFlushSize)
}
updateInterval32 = uint32(updateInterval.Nanoseconds() / int64(time.Second))
Expand All @@ -191,7 +192,7 @@ func (b *BigtableIdx) Init() error {
if err := b.MemoryIdx.Init(); err != nil {
return err
}
if updateIdx {
if updateBigTableIdx {
b.wg.Add(writeConcurrency)
for i := 0; i < writeConcurrency; i++ {
go b.processWriteQueue()
Expand All @@ -213,7 +214,7 @@ func (b *BigtableIdx) Init() error {
func (b *BigtableIdx) Stop() {
b.MemoryIdx.Stop()
close(b.shutdown)
if updateIdx {
if updateBigTableIdx {
close(b.writeQueue)
}
b.wg.Wait()
Expand All @@ -229,7 +230,7 @@ func (b *BigtableIdx) Update(point schema.MetricPoint, partition int32) (idx.Arc

archive, oldPartition, inMemory := b.MemoryIdx.Update(point, partition)

if !updateIdx {
if !updateBigTableIdx {
statUpdateDuration.Value(time.Since(pre))
return archive, oldPartition, inMemory
}
Expand Down Expand Up @@ -269,7 +270,7 @@ func (b *BigtableIdx) AddOrUpdate(mkey schema.MKey, data *schema.MetricData, par
if !inMemory {
stat = statAddDuration
}
if !updateIdx {
if !updateBigTableIdx {
stat.Value(time.Since(pre))
return archive, oldPartition, inMemory
}
Expand Down Expand Up @@ -491,7 +492,7 @@ func (b *BigtableIdx) Delete(orgId uint32, pattern string) ([]idx.Archive, error
if err != nil {
return defs, err
}
if updateIdx {
if updateBigTableIdx {
for _, def := range defs {
err = b.deleteDef(&def.MetricDefinition)
if err != nil {
Expand Down
16 changes: 9 additions & 7 deletions idx/cassandra/cassandra.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,15 @@ var (
statSaveSkipped = stats.NewCounter32("idx.cassandra.save.skipped")
errmetrics = cassandra.NewErrMetrics("idx.cassandra")

Enabled bool
Enabled bool
maxStale time.Duration
pruneInterval time.Duration
updateCassIdx bool
updateInterval time.Duration
updateInterval32 uint32

writeQueueSize int

ssl bool
auth bool
hostverification bool
Expand All @@ -63,13 +71,7 @@ var (
consistency string
timeout time.Duration
numConns int
writeQueueSize int
protoVer int
maxStale time.Duration
pruneInterval time.Duration
updateCassIdx bool
updateInterval time.Duration
updateInterval32 uint32
disableInitialHostLookup bool
)

Expand Down

0 comments on commit 9561e0a

Please sign in to comment.