コード例 #1
0
        public async Task <List <ProcessorRuntimeStatus> > GetDetailedStatus([FromUri] string ProcessorName)
        {
            string[] validationErrors = Processor.ValidateProcessName(ProcessorName);
            if (null != validationErrors)
            {
                Utils.ThrowHttpError(validationErrors);
            }

            Processor processor;

            using (ITransaction tx = this.Svc.StateManager.CreateTransaction())
            {
                // do we have it?
                ConditionalValue <Processor> cResults = await this.Svc.ProcessorStateStore.TryGetValueAsync(tx, ProcessorName);

                if (!cResults.HasValue)
                {
                    Utils.ThrowHttpError(string.Format("Processor with the name {0} does not exist", ProcessorName));
                }

                processor = cResults.Value;
            }

            ProcessorOperationHandlerFactory factory          = new ProcessorOperationHandlerFactory();
            ProcessorOperationHandlerBase    operationHandler = factory.CreateHandler(
                this.Svc,
                new ProcessorOperation()
            {
                OperationType = ProcessorOperationType.RuntimeStatusCheck, ProcessorName = ProcessorName
            });

            List <ProcessorRuntimeStatus> runtimeStatus = new List <ProcessorRuntimeStatus>();

            Task <HttpResponseMessage>[] tasks = await operationHandler.ExecuteOperation <Task <HttpResponseMessage>[]>(null);

            await Task.WhenAll(tasks);

            foreach (Task <HttpResponseMessage> completedTask in tasks)
            {
                HttpResponseMessage httpResponse = completedTask.Result;
                if (!httpResponse.IsSuccessStatusCode)
                {
                    Utils.ThrowHttpError("error aggregating status from processor partitions");
                }

                runtimeStatus.Add(JsonConvert.DeserializeObject <ProcessorRuntimeStatus>(await httpResponse.Content.ReadAsStringAsync()));
            }
            return(runtimeStatus);
        }
コード例 #2
0
        public async Task<List<ProcessorRuntimeStatus>> GetDetailedStatus([FromUri] string ProcessorName)
        {
            string[] validationErrors = Processor.ValidateProcessName(ProcessorName);
            if (null != validationErrors)
            {
                Utils.ThrowHttpError(validationErrors);
            }

            Processor processor;
            using (ITransaction tx = this.Svc.StateManager.CreateTransaction())
            {
                // do we have it? 
                ConditionalResult<Processor> cResults = await this.Svc.ProcessorStateStore.TryGetValueAsync(tx, ProcessorName);
                if (!cResults.HasValue)
                {
                    Utils.ThrowHttpError(string.Format("Processor with the name {0} does not exist", ProcessorName));
                }

                processor = cResults.Value;
            }

            ProcessorOperationHandlerFactory factory = new ProcessorOperationHandlerFactory();
            ProcessorOperationHandlerBase operationHandler = factory.CreateHandler(
                this.Svc,
                new ProcessorOperation() {OperationType = ProcessorOperationType.RuntimeStatusCheck, ProcessorName = ProcessorName});

            List<ProcessorRuntimeStatus> runtimeStatus = new List<ProcessorRuntimeStatus>();
            Task<HttpResponseMessage>[] tasks = await operationHandler.ExecuteOperation<Task<HttpResponseMessage>[]>(null);

            await Task.WhenAll(tasks);

            foreach (Task<HttpResponseMessage> completedTask in tasks)
            {
                HttpResponseMessage httpResponse = completedTask.Result;
                if (!httpResponse.IsSuccessStatusCode)
                {
                    Utils.ThrowHttpError("error aggregating status from processor partitions");
                }

                runtimeStatus.Add(JsonConvert.DeserializeObject<ProcessorRuntimeStatus>(await httpResponse.Content.ReadAsStringAsync()));
            }
            return runtimeStatus;
        }