Exemple #1
0
func NewManager(sources []source_api.Source, sinkManager sinks.ExternalSinkManager, res, bufferDuration time.Duration, useModel bool, modelRes time.Duration, align bool) (Manager, error) {
	// TimeStore constructor passed to the cluster implementation.
	tsConstructor := func() store.TimeStore {
		// TODO(afein): determine default analogy of cache duration to Timestore durations.
		return store.NewGCStore(store.NewCMAStore(), 5*bufferDuration)
	}
	var newCluster model.Cluster = nil
	if useModel {
		newCluster = model.NewCluster(tsConstructor, modelRes)
	}
	firstSync := time.Now()
	if align {
		firstSync = firstSync.Truncate(res).Add(res)
	}
	return &realManager{
		sources:     sources,
		sinkManager: sinkManager,
		cache:       cache.NewCache(bufferDuration),
		model:       newCluster,
		lastSync:    firstSync,
		resolution:  res,
		align:       align,
		decoder:     sink_api.NewDecoder(),
	}, nil
}
Exemple #2
0
func NewCache(bufferDuration, gcDuration time.Duration) Cache {
	rc := &realCache{
		pods:           make(map[string]*podElement),
		nodes:          make(map[string]*nodeElement),
		events:         store.NewGCStore(store.NewTimeStore(), bufferDuration),
		eventUIDs:      make(map[string]struct{}),
		bufferDuration: bufferDuration,
	}
	go util.Until(rc.runGC, gcDuration, util.NeverStop)
	return rc
}
Exemple #3
0
// TestNewInfoType tests both flows of the InfoType constructor.
func TestNewInfoType(t *testing.T) {
	var (
		metrics = make(map[string]*store.TimeStore)
		labels  = make(map[string]string)
	)
	new_store := store.NewGCStore(store.NewTimeStore(), time.Hour)
	metrics["test"] = &new_store
	labels["name"] = "test"
	assert := assert.New(t)

	// Invocation with no parameters
	new_infotype := newInfoType(nil, nil)
	assert.Empty(new_infotype.Metrics)
	assert.Empty(new_infotype.Labels)

	// Invocation with both parameters
	new_infotype = newInfoType(metrics, labels)
	assert.Equal(new_infotype.Metrics, metrics)
	assert.Equal(new_infotype.Labels, labels)
}
Exemple #4
0
// newTimeStore returns a new GCStore.
// Meant to be passed to newRealCluster.
func newTimeStore() store.TimeStore {
	return store.NewGCStore(store.NewTimeStore(), time.Hour)
}
Exemple #5
0
func (rc *realCache) newContainerElement() *containerElement {
	return &containerElement{
		metrics: store.NewGCStore(store.NewTimeStore(), rc.bufferDuration),
	}
}