/// <summary>
        /// This implementation should not leak into the core Queryable code.  It is dependent on the specific protocol
        /// used to communicate with the other partitions (HTTP over ReverseProxy), and should be hidden behind an interface.
        /// </summary>
        private static async Task <IEnumerable <JToken> > QueryPartitionAsync(Partition partition,
                                                                              StatefulServiceContext context, string collection, IEnumerable <KeyValuePair <string, string> > query, CancellationToken cancellationToken)
        {
            string endpoint = await StatefulServiceUtils.GetPartitionEndpointAsync(context, partition).ConfigureAwait(false);

            string content = await StatefulServiceUtils.QueryPartitionAsync(endpoint, partition.PartitionInformation.Id, collection, query).ConfigureAwait(false);

            var result = JsonConvert.DeserializeObject <ODataResult>(content);

            return(result.Value);
        }
Esempio n. 2
0
        private async Task ForwardQueryCollectionAsync(HttpContext httpContext, StatefulServiceContext serviceContext, IReliableStateManager stateManager, string collection, Guid partitionId)
        {
            // Forward the request to the correct partition.
            var    queryParameters = httpContext.Request.Query.Select(q => new KeyValuePair <string, string>(q.Key, q.Value));
            string endpoint        = await StatefulServiceUtils.GetPartitionEndpointAsync(serviceContext, partitionId).ConfigureAwait(false);

            string content = await StatefulServiceUtils.QueryPartitionAsync(endpoint, partitionId, collection, queryParameters);

            httpContext.Response.ContentType = "application/json";
            httpContext.Response.StatusCode  = (int)HttpStatusCode.OK;

            // Write the response.
            await httpContext.Response.WriteAsync(content).ConfigureAwait(false);
        }