Пример #1
0
func (fdb *fdbSlice) Statistics() (StorageStatistics, error) {
	var sts StorageStatistics

	sz, err := common.FileSize(fdb.currfile)
	if err != nil {
		return sts, err
	}

	// Compute approximate fragmentation percentage
	// Since we keep multiple index snapshots after compaction, it is not
	// trivial to compute fragmentation as ration of data size to disk size.
	// Hence we compute approximate fragmentation by adding overhead data size
	// caused by extra snapshots.
	extraSnapDataSize := platform.LoadInt64(&fdb.extraSnapDataSize)

	fdb.statFdLock.Lock()
	sts.DataSize = int64(fdb.statFd.EstimateSpaceUsed()) + extraSnapDataSize
	fdb.statFdLock.Unlock()

	sts.DiskSize = sz
	sts.ExtraSnapDataSize = extraSnapDataSize

	sts.GetBytes = platform.LoadInt64(&fdb.get_bytes)
	sts.InsertBytes = platform.LoadInt64(&fdb.insert_bytes)
	sts.DeleteBytes = platform.LoadInt64(&fdb.delete_bytes)

	return sts, nil
}
Пример #2
0
//allocNode tries to get node from freelist, otherwise allocates a new node and returns
func (q *atomicMutationQueue) allocNode(vbucket Vbucket, appch StopChannel) *node {

	//get node from freelist
	n := q.popFreeList(vbucket)
	if n != nil {
		return n
	} else {
		currLen := platform.LoadInt64(&q.size[vbucket])
		if currLen < q.maxLen {
			//allocate new node and return
			return &node{}
		}
	}

	//every ALLOC_POLL_INTERVAL milliseconds, check for free nodes
	ticker := time.NewTicker(time.Millisecond * ALLOC_POLL_INTERVAL)

	var totalWait int
	for {
		select {
		case <-ticker.C:
			totalWait += ALLOC_POLL_INTERVAL
			n = q.popFreeList(vbucket)
			if n != nil {
				return n
			}
			if totalWait > 5000 {
				logging.Warnf("Indexer::MutationQueue Waiting for Node "+
					"Alloc for %v Milliseconds Vbucket %v", totalWait, vbucket)
			}

		case <-q.stopch[vbucket]:
			return nil

		case <-appch:
			//caller no longer wants to wait
			//allocate new node and return
			return &node{}

		}
	}

	return nil

}
Пример #3
0
//GetSize returns the size of the vbucket queue
func (q *atomicMutationQueue) GetSize(vbucket Vbucket) int64 {
	return platform.LoadInt64(&q.size[vbucket])
}
Пример #4
0
func (s *Server) Statistics() ServerStats {
	return ServerStats{
		Connections: platform.LoadInt64(&s.nConnections),
	}
}
Пример #5
0
func (v Int64Val) Value() int64 {
	value := platform.LoadInt64(v.val)
	return value
}
Пример #6
0
func (v Int64Val) MarshalJSON() ([]byte, error) {
	value := platform.LoadInt64(v.val)
	return []byte(fmt.Sprint(value)), nil
}