예제 #1
0
 internal CqlRowSet(OutputSchemaChange output, Session session)
 {
     if (output.TraceID != null)
     {
         _queryTrace = new QueryTrace(output.TraceID.Value, session);
     }
 }
예제 #2
0
 internal CqlRowSet(OutputRows rawrows, Session session, bool ownRows = true)
 {
     this._rawrows = rawrows;
     this._ownRows = ownRows;
     if (rawrows.TraceID != null)
         _queryTrace = new QueryTrace(rawrows.TraceID.Value, session);
 }
예제 #3
0
        private Task <QueryTrace> GetQueryTrace(QueryTrace trace, HashedWheelTimer timer, int attempt)
        {
            if (attempt >= TraceMaxAttempts)
            {
                return(TaskHelper.FromException <QueryTrace>(
                           new TraceRetrievalException(string.Format("Unable to retrieve complete query trace after {0} tries", TraceMaxAttempts))));
            }
            var sessionQuery  = string.Format(SelectTraceSessions, trace.TraceId);
            var fetchAndAdapt = Cc
                                .QueryAsync(sessionQuery)
                                .ContinueSync(rs =>
            {
                var sessionRow = rs.FirstOrDefault();
                if (sessionRow == null || sessionRow.IsNull("duration"))
                {
                    return(null);
                }
                trace.RequestType    = sessionRow.GetValue <string>("request");
                trace.DurationMicros = sessionRow.GetValue <int>("duration");
                trace.Coordinator    = sessionRow.GetValue <IPAddress>("coordinator");
                trace.Parameters     = sessionRow.GetValue <IDictionary <string, string> >("parameters");
                trace.StartedAt      = sessionRow.GetValue <DateTimeOffset>("started_at").ToFileTime();
                if (sessionRow.GetColumn("client") != null)
                {
                    //client column was not present in previous
                    trace.ClientAddress = sessionRow.GetValue <IPAddress>("client");
                }
                return(trace);
            });

            return(fetchAndAdapt.Then(loadedTrace =>
            {
                if (loadedTrace == null)
                {
                    //Trace session was not loaded
                    return TaskHelper
                    .ScheduleExecution(() => GetQueryTrace(trace, timer, attempt + 1), timer, TraceAttemptDelay)
                    .Unwrap();
                }
                var eventsQuery = string.Format(SelectTraceEvents, trace.TraceId);
                return Cc
                .QueryAsync(eventsQuery)
                .ContinueSync(rs =>
                {
                    var events = rs
                                 .Select(row => new QueryTrace.Event(
                                             row.GetValue <string>("activity"),
                                             row.GetValue <TimeUuid>("event_id").GetDate(),
                                             row.GetValue <IPAddress>("source"),
                                             row.GetValue <int?>("source_elapsed") ?? 0,
                                             row.GetValue <string>("thread")))
                                 .ToList();
                    loadedTrace.Events = events;
                    return loadedTrace;
                });
            }));
        }
예제 #4
0
 internal CqlRowSet(OutputRows rawrows, Session session, bool ownRows = true)
 {
     this._rawrows = rawrows;
     this._ownRows = ownRows;
     if (rawrows != null && rawrows.TraceID != null)
     {
         _queryTrace = new QueryTrace(rawrows.TraceID.Value, session);
     }
 }
예제 #5
0
 internal CqlRowSet(OutputSchemaChange output, Session session)
 {
     if (output.TraceID != null)
         _queryTrace = new QueryTrace(output.TraceID.Value, session);
 }
예제 #6
0
 internal void SetQueryTrace(QueryTrace queryTrace)
 {
     QueryTrace = queryTrace;
 }
예제 #7
0
 /// <summary>
 /// Gets the query trace.
 /// </summary>
 /// <param name="trace">The query trace that contains the id, which properties are going to be populated.</param>
 /// <returns></returns>
 internal Task <QueryTrace> GetQueryTraceAsync(QueryTrace trace)
 {
     return(_schemaParser.GetQueryTrace(trace, Configuration.Timer));
 }
예제 #8
0
 internal Task <QueryTrace> GetQueryTrace(QueryTrace trace, HashedWheelTimer timer)
 {
     return(GetQueryTrace(trace, timer, 0));
 }
예제 #9
0
 /// <summary>
 /// Gets the trace information for the query execution without blocking.
 /// </summary>
 public Task <QueryTrace> GetQueryTraceAsync()
 {
     return(QueryTrace.LoadAsync());
 }
예제 #10
0
 internal void SetQueryTrace(QueryTrace queryTrace)
 {
     QueryTrace = queryTrace;
 }
예제 #11
0
 /// <summary>
 /// Gets the query trace.
 /// </summary>
 /// <param name="trace">The query trace that contains the id, which properties are going to be populated.</param>
 /// <returns></returns>
 internal Task<QueryTrace> GetQueryTraceAsync(QueryTrace trace)
 {
     return _schemaParser.GetQueryTrace(trace, Configuration.Timer);
 }
예제 #12
0
 public Task <QueryTrace> GetQueryTraceAsync(QueryTrace trace, HashedWheelTimer timer)
 {
     return(GetQueryTraceAsync(trace, timer, 0));
 }