// ------------------------------------------------------------
// NewCollection returns a new, unstarted Collection instance.
193268
func NewCollection(options CollectionOptions) (
	Collection, error) {
	histograms := make(ghistogram.Histograms)
	histograms["ExecuteBatchBytes"] =
		ghistogram.NewNamedHistogram("ExecuteBatchBytes", 10, 4, 4)
	histograms["ExecuteBatchOpsCount"] =
		ghistogram.NewNamedHistogram("ExecuteBatchOpsCount", 10, 4, 4)
	histograms["ExecuteBatchUsecs"] =
		ghistogram.NewNamedHistogram("ExecuteBatchUsecs", 10, 4, 4)
	histograms["MergerUsecs"] =
		ghistogram.NewNamedHistogram("MergerUsecs", 10, 4, 4)
	histograms["MutationKeyBytes"] =
		ghistogram.NewNamedHistogram("MutationKeyBytes", 10, 4, 4)
	histograms["MutationValBytes"] =
		ghistogram.NewNamedHistogram("MutationValBytes", 10, 4, 4)

	c := &collection{
		options:            &options,
		stopCh:             make(chan struct{}),
		pingMergerCh:       make(chan ping, 10),
		doneMergerCh:       make(chan struct{}),
		donePersisterCh:    make(chan struct{}),
		lowerLevelSnapshot: NewSnapshotWrapper(options.LowerLevelInit, nil),
		stats:              &CollectionStats{},
		histograms:         histograms,
	}

	c.stackDirtyTopCond = sync.NewCond(&c.m)
	c.stackDirtyBaseCond = sync.NewCond(&c.m)

	return c, nil
}
913333
func (s *Store) CreateCollection(name string, compare gtreap.Compare) *Collection {
	s.assertNotReadOnly()

	s.collLock.Lock()
	defer s.collLock.Unlock()

	// Try to get the existing Collection again now that we hold the write lock.
	if _, ok := s.colls[name]; ok {
		panic(fmt.Errorf("collection %q already exists", name))
	}

	// Create a new read/write Collection.
	coll := &Collection{
		name:     name,
		rootLock: &sync.RWMutex{},
	}
	coll.setRoot(gtreap.NewTreap(compare))

	if s.colls == nil {
		s.colls = make(map[string]*Collection)
	}
	s.colls[name] = coll
	s.collNames = s.insertCollectionName(name)
	return coll
}
935892
func NewInterruptsCollector() (Collector, error) {
	return &interruptsCollector{
		desc: typedDesc{prometheus.NewDesc(
			namespace+"_interrupts_total",
			"Interrupt details.",
			interruptLabelNames, nil,
		), prometheus.CounterValue},
	}, nil
}
109012
func newVertexCollection(name string, g *graph) (Collection, error) {
	if name == "" {
		return nil, WithStack(InvalidArgumentError{Message: "name is empty"})
	}
	if g == nil {
		return nil, WithStack(InvalidArgumentError{Message: "g is nil"})
	}
	return &vertexCollection{
		name: name,
		g:    g,
		conn: g.db.conn,
	}, nil
}
568658
func NewRunitCollector() (Collector, error) {
	var (
		subsystem   = "service"
		constLabels = prometheus.Labels{"supervisor": "runit"}
		labelNames  = []string{"service"}
	)

	return &runitCollector{
		state: typedDesc{prometheus.NewDesc(
			prometheus.BuildFQName(namespace, subsystem, "state"),
			"State of runit service.",
			labelNames, constLabels,
		), prometheus.GaugeValue},
		stateDesired: typedDesc{prometheus.NewDesc(
			prometheus.BuildFQName(namespace, subsystem, "desired_state"),
			"Desired state of runit service.",
			labelNames, constLabels,
		), prometheus.GaugeValue},
		stateNormal: typedDesc{prometheus.NewDesc(
			prometheus.BuildFQName(namespace, subsystem, "normal_state"),
			"Normal state of runit service.",
			labelNames, constLabels,
		), prometheus.GaugeValue},
		stateTimestamp: typedDesc{prometheus.NewDesc(
			prometheus.BuildFQName(namespace, subsystem, "state_last_change_timestamp_seconds"),
			"Unix timestamp of the last runit service state change.",
			labelNames, constLabels,
		), prometheus.GaugeValue},
	}, nil
}
1246013
func NewBondingCollector() (Collector, error) {
	return &bondingCollector{
		slaves: typedDesc{prometheus.NewDesc(
			prometheus.BuildFQName(namespace, "bonding", "slaves"),
			"Number of configured slaves per bonding interface.",
			[]string{"master"}, nil,
		), prometheus.GaugeValue},
		active: typedDesc{prometheus.NewDesc(
			prometheus.BuildFQName(namespace, "bonding", "active"),
			"Number of active slaves per bonding interface.",
			[]string{"master"}, nil,
		), prometheus.GaugeValue},
	}, nil
}
70747
func NewCollectClassNamesFromSubtreeArgs(nodeID NodeID) *CollectClassNamesFromSubtreeArgs {
	args := new(CollectClassNamesFromSubtreeArgs)
	args.NodeID = nodeID
	return args
}
1206069
func (c *FakeMutatingWebhookConfigurations) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error {
	action := testing.NewRootDeleteCollectionAction(mutatingwebhookconfigurationsResource, listOptions)

	_, err := c.Fake.Invokes(action, &v1beta1.MutatingWebhookConfigurationList{})
	return err
}
302847
func (c *FakeRuntimeClasses) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error {
	action := testing.NewRootDeleteCollectionAction(runtimeclassesResource, listOptions)

	_, err := c.Fake.Invokes(action, &v1beta1.RuntimeClassList{})
	return err
}
1046727
func NewRecordCollectionManager(s *mgo.Session) *RecordCollectionManager {
	return &RecordCollectionManager{
		manager: newCollectionManager(s, common.DefaultDBName, common.RecordCollectionName),
	}
}
709726
func New(storageConfig config.Storage) error {
	// create handler based on the storage config
	switch handlerName(storageConfig.Handler) {
	case mongodbHandler:
		handler = mongo.NewHandler(storageConfig)
	default:
		return errors.New("Invalid storage handler `" + storageConfig.Handler + "`")
	}
	// prepare handler
	return handler.Prepare()
}
1174640
func NewCollector() Collector {
	return &collectorImpl{
		Flows:                 map[string]*collector.FlowRecord{},
		Users:                 map[string]*collector.UserRecord{},
		ProcessedUsers:        map[string]bool{},
		DatapathPacketReports: []*collector.PacketReport{},
	}
}
112419
func (p *Collector) Create(ctx context.Context) (*Collector, error) {
	req := types.CreatePropertyCollector{
		This: p.Reference(),
	}

	res, err := methods.CreatePropertyCollector(ctx, p.roundTripper, &req)
	if err != nil {
		return nil, err
	}

	newp := Collector{
		roundTripper: p.roundTripper,
		reference:    res.Returnval,
	}

	return &newp, nil
}
393907
func GetCollection(session *mgo.Session, collectionName string) *mgo.Collection {
	return session.DB(DB_NAME).C(collectionName)
}
1128982
func NewOrgController(get pezdispenser.MongoCollectionGetter, authClient AuthRequestCreator) Controller {
	return &orgController{
		store:      get.Collection,
		authClient: authClient,
	}
}
1108475
func newIndex(id string, indexTypeString string, col *collection) (Index, error) {
	if id == "" {
		return nil, WithStack(InvalidArgumentError{Message: "id is empty"})
	}
	parts := strings.Split(id, "/")
	if len(parts) != 2 {
		return nil, WithStack(InvalidArgumentError{Message: "id must be `collection/name`"})
	}
	if col == nil {
		return nil, WithStack(InvalidArgumentError{Message: "col is nil"})
	}
	indexType, err := indexStringToType(indexTypeString)
	if err != nil {
		return nil, WithStack(err)
	}
	return &index{
		id:        id,
		indexType: indexType,
		col:       col,
		db:        col.db,
		conn:      col.conn,
	}, nil
}
1014970
func NewCollector(store *store.MemoryStore) *Collector {
	return &Collector{
		store:    store,
		stopChan: make(chan struct{}),
		doneChan: make(chan struct{}),
	}
}