예제 #1
0
 public HttpClient(Configuration conf, IDictionary<string, string> parameters)
 {
     if ((conf == null) || (parameters == null))
     {
         throw new Exception("conf and params is must not null");
     }
     this.conf = conf;
     this.parameters = parameters;
     ServicePointManager.DefaultConnectionLimit = 0x80;
 }
예제 #2
0
 private void ControlThread(StreamMsgConsumeFactory msgConsumeFactory, ref bool bstop, Configuration conf, TopCometStreamRequest cometReq)
 {
     long ticks = 0L;
     while (!bstop)
     {
         if (this.allStop)
         {
             break;
         }
         try
         {
             if ("102".Equals(this.serverRespCode))
             {
                 this.logger.Info("Server is upgrade sleep " + conf.GetSleepTimeOfServerInUpgrade() + " seconds");
                 Thread.Sleep((int) (conf.GetSleepTimeOfServerInUpgrade() * 0x3e8));
                 this.StartConsumeThread(cometReq);
             }
             else if (("501".Equals(this.serverRespCode) || "103".Equals(this.serverRespCode)) || ("101".Equals(this.serverRespCode) || "500".Equals(this.serverRespCode)))
             {
                 this.StartConsumeThread(cometReq);
             }
             else
             {
                 if ("104".Equals(this.serverRespCode) || "105".Equals(this.serverRespCode))
                 {
                     if ((!"104".Equals(this.serverRespCode) || this.isReconnect) && !"105".Equals(this.serverRespCode))
                     {
                         goto Label_0117;
                     }
                 }
                 else
                 {
                     bstop = true;
                 }
                 break;
             }
         Label_0117:
             try
             {
                 Monitor.Enter(this.objLock);
                 ticks = DateTime.Now.Ticks;
                 Monitor.Wait(this.objLock, (int) (conf.GetHttpReconnectInterval() * 0x3e8));
                 if ((DateTime.Now.Ticks - ticks) >= ((conf.GetHttpReconnectInterval() * 0x3e8) * 0x2710))
                 {
                     this.serverRespCode = "500";
                     this.isReconnect = true;
                 }
             }
             catch (Exception exception)
             {
                 this.logger.Error(exception.Message);
             }
             finally
             {
                 Monitor.Exit(this.objLock);
             }
             continue;
         }
         catch (Exception exception2)
         {
             this.logger.Error("Occur some error,stop the stream consume" + exception2.Message);
             bstop = true;
             try
             {
                 Monitor.Enter(this.objLock);
                 Monitor.PulseAll(this.objLock);
             }
             finally
             {
                 Monitor.Exit(this.objLock);
             }
             continue;
         }
     }
     if (this.currentStreamImpl != null)
     {
         try
         {
             this.currentStreamImpl.Close();
         }
         catch (Exception)
         {
         }
     }
     this.logger.Info("Stop stream consume");
 }
예제 #3
0
 public TopCometStreamImpl(Configuration conf)
 {
     this.conf = conf;
 }