func (b *requestLogKeyspace) Fetch(keys []string) ([]datastore.AnnotatedPair, []errors.Error) {
	var errs []errors.Error
	rv := make([]datastore.AnnotatedPair, 0, len(keys))

	accounting.RequestsForeach(func(id string, entry *accounting.RequestLogEntry) {
		item := value.NewAnnotatedValue(map[string]interface{}{
			"RequestId":   id,
			"ElapsedTime": entry.ElapsedTime,
			"ServiceTime": entry.ServiceTime,
			"ResultCount": entry.ResultCount,
			"ResultSize":  entry.ResultSize,
			"ErrorCount":  entry.ErrorCount,
			"SortCount":   entry.SortCount,
			"Time":        entry.Time.String(),
		})
		if entry.Statement != "" {
			item.SetField("Statement", entry.Statement)
		}
		if entry.PreparedName != "" {
			item.SetField("PreparedName", entry.PreparedName)
			item.SetField("PreparedText", entry.PreparedText)
		}
		item.SetAttachment("meta", map[string]interface{}{
			"id": id,
		})
		rv = append(rv, datastore.AnnotatedPair{
			Key:   id,
			Value: item,
		})
	})
	return rv, errs
}
Пример #2
0
func doCompletedRequests(endpoint *HttpEndpoint, w http.ResponseWriter, req *http.Request) (interface{}, errors.Error) {
	numRequests := accounting.RequestsCount()

	requests := make([]map[string]interface{}, numRequests)
	i := 0

	snapshot := func(requestId string, request *accounting.RequestLogEntry) {

		// FIXME quick hack to avoid overruns
		if i >= numRequests {
			return
		}
		requests[i] = map[string]interface{}{}
		requests[i]["requestId"] = request.RequestId
		if request.Statement != "" {
			requests[i]["statement"] = request.Statement
		}
		if request.PreparedName != "" {
			requests[i]["preparedName"] = request.PreparedName
			requests[i]["preparedText"] = request.PreparedText
		}
		requests[i]["requestTime"] = request.Time
		requests[i]["elapsedTime"] = request.ElapsedTime
		requests[i]["serviceTime"] = request.ServiceTime
		requests[i]["resultCount"] = request.ResultCount
		requests[i]["resultSize"] = request.ResultSize
		requests[i]["errorCount"] = request.ErrorCount
		requests[i]["sortCount"] = request.SortCount

		// FIXME more stats
		i++
	}
	accounting.RequestsForeach(snapshot)
	return requests, nil
}
func (pi *requestLogIndex) ScanEntries(requestId string, limit int64, cons datastore.ScanConsistency,
	vector timestamp.Vector, conn *datastore.IndexConnection) {
	defer close(conn.EntryChannel())
	accounting.RequestsForeach(func(id string, entry *accounting.RequestLogEntry) {
		indexEntry := datastore.IndexEntry{PrimaryKey: id}
		conn.EntryChannel() <- &indexEntry
	})
}