Esempio n. 1
0
 internal virtual void AbortBatch()
 {
     lock (this)
     {
         if (this.batchingProvider != null)
         {
             this.batchingProvider.Abort(new SubscrException("requests batch aborted"));
             this.batchingProvider = null;
         }
     }
 }
 internal virtual void AbortBatch()
 {
     lock (this)
     {
         if (this.batchingProvider != null)
         {
             this.batchingProvider.Abort(new SubscrException("requests batch aborted"));
             this.batchingProvider = null;
         }
     }
 }
 internal virtual void StartBatch(string controlUrl)
 {
     lock (this)
     {
         if (this.batchingProvider != null)
         {
             this.batchingProvider.Abort(new SubscrException("requests batch discarded"));
         }
         this.batchingProvider = new BatchingHttpProvider(controlUrl, this.limit);
     }
 }
Esempio n. 4
0
 internal virtual void CloseBatch()
 {
     BatchingHttpProvider batchingProvider;
     lock (this)
     {
         batchingProvider = this.batchingProvider;
         this.batchingProvider = null;
     }
     if (batchingProvider != null)
     {
         DoAsyncPost(batchingProvider);
     }
 }
        internal virtual void CloseBatch()
        {
            BatchingHttpProvider batchingProvider;

            lock (this)
            {
                batchingProvider      = this.batchingProvider;
                this.batchingProvider = null;
            }
            if (batchingProvider != null)
            {
                DoAsyncPost(batchingProvider);
            }
        }
 public void SetReader(BatchingHttpProvider.MyReader answer)
 {
     lock (this)
     {
         this.answer = answer;
         answer.Master = this;
         Monitor.Pulse(this);
     }
 }
Esempio n. 7
0
 internal virtual StreamReader GetAnswer(string controlUrl, IDictionary parameters, BatchMonitor batch)
 {
     BatchingHttpProvider batchToClose = null;
     BatchingHttpProvider.BufferedReaderMonitor monitor = null;
     bool flag = false;
     lock (batch)
     {
         lock (this)
         {
             if (!batch.Filled)
             {
                 batch.UseOne();
                 if (this.batchingProvider != null)
                 {
                     protLogger.Info("Batching control request");
                     if (protLogger.IsDebugEnabled)
                     {
                         protLogger.Debug("Control params: " + CollectionsSupport.ToString(parameters));
                     }
                     monitor = this.batchingProvider.AddCall(parameters);
                     if (monitor != null)
                     {
                         if (batch.Filled)
                         {
                             batchToClose = this.batchingProvider;
                             this.batchingProvider = null;
                         }
                     }
                     else if (this.batchingProvider.Empty)
                     {
                         protLogger.Info("Batching failed; trying without batch");
                         if (batch.Filled)
                         {
                             this.batchingProvider = null;
                         }
                     }
                     else
                     {
                         protLogger.Info("Batching failed; trying a new batch");
                         batchToClose = this.batchingProvider;
                         batch.Expand(1);
                         this.batchingProvider = new BatchingHttpProvider(controlUrl, this.limit);
                         flag = true;
                     }
                 }
             }
             else if (this.batchingProvider != null)
             {
                 this.batchingProvider.Abort(new SubscrException("wrong requests batch"));
                 this.batchingProvider = null;
             }
         }
     }
     if (batchToClose != null)
     {
         DoAsyncPost(batchToClose);
     }
     if (monitor != null)
     {
         return monitor.GetReader();
     }
     if (flag)
     {
         return this.GetAnswer(controlUrl, parameters, batch);
     }
     return this.GetNotBatchedAnswer(controlUrl, parameters);
 }
Esempio n. 8
0
 private static void DoAsyncPost(BatchingHttpProvider batchToClose)
 {
     new AnonymousClassThread(batchToClose).Start();
 }
Esempio n. 9
0
 public AnonymousClassThread(BatchingHttpProvider batchToClose)
 {
     this.batchToClose = batchToClose;
 }
Esempio n. 10
0
 internal virtual void StartBatch(string controlUrl)
 {
     lock (this)
     {
         if (this.batchingProvider != null)
         {
             this.batchingProvider.Abort(new SubscrException("requests batch discarded"));
         }
         this.batchingProvider = new BatchingHttpProvider(controlUrl, this.limit);
     }
 }
        internal virtual StreamReader GetAnswer(string controlUrl, Hashtable parameters, BatchMonitor batch)
        {
            BatchingHttpProvider batchToClose = null;

            BatchingHttpProvider.BufferedReaderMonitor monitor = null;
            bool flag = false;

            lock (batch)
            {
                lock (this)
                {
                    if (!batch.Filled)
                    {
                        batch.UseOne();
                        if (this.batchingProvider != null)
                        {
                            protLogger.Info("Batching control request");
                            if (protLogger.IsDebugEnabled)
                            {
                                protLogger.Debug("Control params: " + CollectionsSupport.ToString(parameters));
                            }
                            monitor = this.batchingProvider.AddCall(parameters);
                            if (monitor != null)
                            {
                                if (batch.Filled)
                                {
                                    batchToClose          = this.batchingProvider;
                                    this.batchingProvider = null;
                                }
                            }
                            else if (this.batchingProvider.Empty)
                            {
                                protLogger.Info("Batching failed; trying without batch");
                                if (batch.Filled)
                                {
                                    this.batchingProvider = null;
                                }
                            }
                            else
                            {
                                protLogger.Info("Batching failed; trying a new batch");
                                batchToClose = this.batchingProvider;
                                batch.Expand(1);
                                this.batchingProvider = new BatchingHttpProvider(controlUrl, this.limit);
                                flag = true;
                            }
                        }
                    }
                    else if (this.batchingProvider != null)
                    {
                        this.batchingProvider.Abort(new SubscrException("wrong requests batch"));
                        this.batchingProvider = null;
                    }
                }
            }
            if (batchToClose != null)
            {
                DoAsyncPost(batchToClose);
            }
            if (monitor != null)
            {
                return(monitor.GetReader());
            }
            if (flag)
            {
                return(this.GetAnswer(controlUrl, parameters, batch));
            }
            return(this.GetNotBatchedAnswer(controlUrl, parameters));
        }
 private static void DoAsyncPost(BatchingHttpProvider batchToClose)
 {
     new AnonymousClassThread(batchToClose).Start();
 }
 public AnonymousClassThread(BatchingHttpProvider batchToClose)
 {
     this.batchToClose = batchToClose;
 }