public void ProcessList() { this.milisec_idle_work = 0.0; this.milisec_cpu_work = 0.0; this.milisec_cpu_slowest = 0.0; this.totProcessCalls = 0.0; int count = this.lstTimers.Count; for (int index = 0; index < count; ++index) { CPU_Timer hshTimer = this.hshTimers[(object)(this.lstTimers[index] as string)] as CPU_Timer; this.milisec_idle_work += hshTimer.milisec_idle_work; this.milisec_cpu_work += hshTimer.milisec_cpu_work; if (hshTimer.milisec_cpu_slowest > this.milisec_cpu_slowest) { this.milisec_cpu_slowest = hshTimer.milisec_cpu_slowest; } hshTimer.milisec_cpu_slowest = 0.0; hshTimer.milisec_idle_work = 0.0; hshTimer.milisec_cpu_work = 0.0; } if (count <= 0) { return; } this.milisec_idle_work /= (double)count; this.milisec_cpu_work /= (double)count; }
public ServerThread(ref ServerNewConnInfo info, ref DataServer server, ref CPU_Timer cpuTimer, ref ConnectionMonitor con, ref StreamWriter stream, int max_packet_size, ref CtrlStation ctrl, ref CustomRecept recept, ref Translator translator, ref ArrayList lstClients) { this.i_ConnInfo = info; this.i_DataServer = server; this.i_monCpu = cpuTimer; this.i_monConnections = con; this.i_ctrl = ctrl; this.m_max_packet_size = max_packet_size; this.logStream = stream; this.var_recept = recept; this.var_translator = translator; this.var_lstClients = lstClients; this.StandByTimer = DateTime.Now; }
public void AddTimer(ref CPU_Timer timer, string tag) { this.lstTimers.Add((object)tag); this.hshTimers[(object)tag] = (object)timer; }
private void StartServer() { this.i_ctrl.tcpServerListener = new TcpListener(this.m_clientServerPort); this.i_ctrl.genericErrorMsg = ""; int num = 0; this.i_ctrl.bServerLoaded = true; while (!this.i_ctrl.bStopServer) { Thread.Sleep(1); Socket socket = (Socket)null; if (this.lstClients.Count < this.i_ctrl.maxThreads) { if (!this.MasterMode && !this.i_ctrl.ServingStandBy && !this.StandbyControlMode) { this.MasterMode = true; this.StandbyControlMode = true; this.createScheduler(); } if (!this.i_ctrl.bPauseTraffic) { try { this.i_ctrl.tcpServerListener.Start(); socket = this.i_ctrl.tcpServerListener.AcceptSocket(); } catch (SocketException ex) { ex.ToString(); } catch (IOException ex) { ex.ToString(); } catch (Exception ex) { ex.ToString(); } if (!this.i_ctrl.bStopServer) { if (!this.i_ctrl.bPauseTraffic) { ServerNewConnInfo info = new ServerNewConnInfo(); info.serverSocket = socket; try { info.path = this.m_var_path + "\\Log_" + DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString().PadLeft(2, '0') + DateTime.Now.Day.ToString().PadLeft(2, '0') + DateTime.Now.Hour.ToString().PadLeft(2, '0') + DateTime.Now.Minute.ToString().PadLeft(2, '0') + DateTime.Now.Second.ToString().PadLeft(2, '0') + "_" + (++num).ToString().PadLeft(7, '0') + ".txt.wrk"; info.logFile = !File.Exists(info.path) ? new FileStream(info.path, FileMode.Create, FileAccess.Write) : new FileStream(info.path, FileMode.Truncate, FileAccess.Write); info.logStream = new StreamWriter((Stream)info.logFile); info.logStream.AutoFlush = true; info.logStream.WriteLine(""); info.logStream.WriteLine("============================================"); info.logStream.WriteLine("# "); info.logStream.WriteLine("# Welcome to SyCraf Server Log. (Master Server)"); info.logStream.WriteLine("# " + DateTime.Now.ToString()); info.logStream.WriteLine("# "); info.logStream.WriteLine("============================================"); DataServer server = new DataServer(ref info.logStream, ref this.i_monDataLoad, ref new DB_Access(this.m_connectionString, ref this.lockArea, ref this.i_monCpu, ref this.i_ctrl, false) { failSafe_archive = this.m_fail_fs }); this.lstClients.Add((object)info); this.i_monConnections.NewConnection(); info.iPid = num; info.engine_version = this.m_engineVersion; info.db_machine = this.m_db_machine; info.schema = this.m_schema; info.master_server = this.m_master_server; info.master_server_port = this.m_master_server_port; CPU_Timer cpuTimer = new CPU_Timer(); this.i_monCpu.AddTimer(ref cpuTimer, Convert.ToString(info.iPid)); info.serverSockStream = new NetworkStream(info.serverSocket); info.serverThread = new ServerThread(ref info, ref server, ref cpuTimer, ref this.i_monConnections, ref info.logStream, this.m_max_packet_size, ref this.i_ctrl, ref this.recept, ref this.var_translator, ref this.lstClients); info.workThread = new Thread(new ThreadStart(info.serverThread.ServerLoop)); server.SetTransactionDispatcher(this.transactionDispatcher); info.workThread.Start(); } catch (Exception ex) { this.i_ctrl.bServerLoaded = false; this.i_ctrl.genericErrorMsg = ex.Message; this.i_ctrl.tcpServerListener.Stop(); this.i_ctrl.displayError(); socket.Close(); break; } } } else { break; } } } } this.TermServer(); }