Example #1
0
 void ttclient_OnCmdServerStatistics(ServerStatistics serverstatistics)
 {
     totalTextBox.Text     = String.Format("{0}/{1} KBytes", serverstatistics.nTotalBytesRX / 1024, serverstatistics.nTotalBytesTX / 1024);
     voiceTextBox.Text     = String.Format("{0}/{1} KBytes", serverstatistics.nVoiceBytesRX / 1024, serverstatistics.nVoiceBytesTX / 1024);
     videoTextBox.Text     = String.Format("{0}/{1} KBytes", serverstatistics.nVideoCaptureBytesRX / 1024, serverstatistics.nVideoCaptureBytesTX / 1024);
     mediafileTextBox.Text = String.Format("{0}/{1} KBytes", serverstatistics.nMediaFileBytesRX / 1024, serverstatistics.nMediaFileBytesTX / 1024);
 }
 /// <summary>
 /// Returns statistics about the usage of the VoltDB database.
 /// </summary>
 /// <param name="component">The specific statistics component to query the system for.</param>
 /// <param name="isInterval">Whether the returned statistics should be aggregated since the time the cluster
 /// was started of since the last interval call.</param>
 /// <returns>Statistics information table set.</returns>
 public Response <Table[]> Statistics(ServerStatistics component, bool isInterval)
 {
     return(this.Executor.Execute <Table[]>(
                Timeout.Infinite
                , "@Statistics"
                , component.ToString().ToUpper()
                , isInterval ? 1 : 0
                ));
 }
Example #3
0
        static void Main(string[] args)
        {
            Console.WriteLine("Server is starting");

            var serverStats = new ServerStatistics();

            using (var server = new Server(serverStats))
            {
                Console.WriteLine("Server is started");

                server.Listen().Wait();
            }

            Console.WriteLine("Server closed");
        }
Example #4
0
 public ServerStatistics GetServerStats(string endpoint)
 {
     try
     {
         using (var database = new LiteDatabase(Program.databasePath))
         {
             var matchesCollection = database.GetCollection <Match>("matches");
             matchesCollection.EnsureIndex(x => x.Endpoint);
             return(ServerStatistics.GetServerStats(matchesCollection, endpoint));
         }
     }
     catch (Exception exc)
     {
         Program.log.Error(exc, "An error occured for HTTP GET GetServerStats");
         throw exc;
     }
 }
Example #5
0
        void checkIsNearWithRetry(IRemoteCache <string, string> cache, string key)
        {
            ServerStatistics stats0 = cache.Stats();
            ServerStatistics stats1 = null;

            for (var i = 0; i < 10; i++)
            {
                cache.Get(key);
                stats1 = cache.Stats();
                if (stats0.GetIntStatistic("nearHits") + 1 == stats1.GetIntStatistic("nearHits"))
                {
                    break;
                }
                System.Threading.Thread.Sleep(200);
            }
            Assert.AreEqual(stats0.GetIntStatistic("nearHits") + 1, stats1.GetIntStatistic("nearHits"));
        }
Example #6
0
        private bool exitFlag_;  // true to close workThread_

        public StatisticsHandler(Config config, Action <ulong, ulong, ulong, ulong, List <Mode.ServerStatistics> > update)
        {
            config_     = config;
            enabled_    = config.enableStatistics;
            UpdateUI    = false;
            updateFunc_ = update;
            logPath_    = Utils.GetPath($"{Global.StatisticLogDirectory}\\");
            Statistic   = new List <Mode.ServerStatistics>();
            exitFlag_   = false;

            DeleteExpiredLog();
            foreach (var server in config.vmess)
            {
                var statistic = new ServerStatistics(server.remarks, server.address, server.port, server.path, 0, 0, 0, 0);
                Statistic.Add(statistic);
            }

            loadFromFile();

            outputBuilder_ = new StringBuilder();

            var fullPath = Utils.GetPath(cliName_);

            if (!File.Exists(fullPath))
            {
                connector_ = null;
                return;
            }

            // .\v2ctl.exe api --server="127.0.0.1:port" StatsService.QueryStats "reset:true"
            args_ = string.Format("api --server=\"127.0.0.1:{0}\" StatsService.QueryStats \"reset:true\"", Global.InboundAPIPort);

            connector_ = new Process();
            connector_.StartInfo.FileName  = fullPath;
            connector_.StartInfo.Arguments = args_;
            connector_.StartInfo.RedirectStandardOutput = true;
            connector_.StartInfo.UseShellExecute        = false;
            connector_.StartInfo.CreateNoWindow         = true;


            workThread_ = new Thread(new ThreadStart(run));
            workThread_.Start();
        }
Example #7
0
 public void Add(int code, long time, Servers.ServerAgent server)
 {
     Statistics.Add(code, time);
     if (server != null)
     {
         if (!Servers.TryGetValue(server.UriKey, out ServerStatistics s))
         {
             lock (Servers)
             {
                 if (!Servers.TryGetValue(server.UriKey, out s))
                 {
                     s = new ServerStatistics(server.UriKey);
                     s.Statistics.Url = this.Statistics.Url;
                     Servers[s.Host]  = s;
                 }
             }
         }
         s.Add(code, time);
     }
 }
Example #8
0
        private bool exitFlag_;  // true to close workThread_

        public StatisticsHandler(Mode.Config config, Action <ulong, ulong, ulong, ulong, List <Mode.ServerStatistics> > update)
        {
            try
            {
                if (Environment.Is64BitOperatingSystem)
                {
                    FileManager.UncompressFile(Utils.GetPath("grpc_csharp_ext.x64.dll"), Resources.grpc_csharp_ext_x64_dll);
                }
                else
                {
                    FileManager.UncompressFile(Utils.GetPath("grpc_csharp_ext.x86.dll"), Resources.grpc_csharp_ext_x86_dll);
                }
            }
            catch (IOException ex)
            {
                Utils.SaveLog(ex.Message, ex);
            }

            config_     = config;
            enabled_    = config.enableStatistics;
            UpdateUI    = false;
            updateFunc_ = update;
            logPath_    = Utils.GetPath(Global.StatisticLogDirectory);
            Statistic   = new List <Mode.ServerStatistics>();
            exitFlag_   = false;

            DeleteExpiredLog();
            foreach (var server in config.vmess)
            {
                var statistic = new ServerStatistics(server.remarks, server.address, server.port, server.path, server.requestHost, 0, 0, 0, 0);
                Statistic.Add(statistic);
            }

            LoadFromFile();

            GrpcInit();

            workThread_ = new Thread(new ThreadStart(Run));
            workThread_.IsBackground = true;
            workThread_.Start();
        }
        public bool Start(FileRequestControllerConfiguration <TAccount> configuration, ServerStatistics <TAccount> statistics)
        {
            FilesEnabled                        = configuration.FilesEnabled;
            FilesBaseUri                        = configuration.FilesBaseUri;
            FilesLocation                       = configuration.FilesLocation;
            FaviconPath                         = configuration.FaviconPath;
            FilesNeedAuthorization              = configuration.FilesNeedAuthorization;
            FileSections                        = configuration.FileSections;
            FilesPreprocessingEnabled           = configuration.FilesPreprocessingEnabled;
            ExistingFilesPreprocessingFrequency = configuration.ExistingFilesPreprocessingFrequency;
            _filesAuthorizer                    = configuration.FilesAuthorizer;
            _statistics                         = statistics;

            if (!IoHelper.HasWriteAccessToDirectory(FilesLocation))
            {
                LogMessage(LogLevel.Warning, $"Cannot use file folder {FilesLocation} : no write access");
                return(false);
            }

            if (!InitializeFileSections())
            {
                LogMessage(LogLevel.Warning, "Failed to initialize file sections");
                return(false);
            }

            if (FilesPreprocessingEnabled && FilesEnabled)
            {
                FilePreprocessController.Start(configuration.FilesPreprocessorThreads,
                                               configuration.FilesCompressionEnabled);
                if (ExistingFilesPreprocessingFrequency > 0)
                {
                    PreprocessExistingFiles();
                    _preprocessTimer          = new Timer(1000 * ExistingFilesPreprocessingFrequency);
                    _preprocessTimer.Elapsed += (sender, args) => PreprocessExistingFiles();
                    _preprocessTimer.Start();
                }
            }

            _started = true;
            return(true);
        }
Example #10
0
        public RavenServer(RavenConfiguration configuration)
        {
            JsonDeserializationValidator.Validate();

            Configuration = configuration ?? throw new ArgumentNullException(nameof(configuration));
            if (Configuration.Initialized == false)
            {
                throw new InvalidOperationException("Configuration must be initialized");
            }

            Statistics = new ServerStatistics();

            AdminScripts = new ScriptRunnerCache(null, Configuration)
            {
                EnableClr = true
            };

            ServerStore = new ServerStore(Configuration, this);
            Metrics     = new MetricCounters();

            _tcpLogger = LoggingSource.Instance.GetLogger <RavenServer>("<TcpServer>");
        }
Example #11
0
        private bool exitFlag_;  // true to close workThread_

        public StatisticsHandler(Mode.Config config, Action <ulong, ulong, ulong, ulong, List <Mode.ServerStatistics> > update)
        {
            config_     = config;
            enabled_    = config.enableStatistics;
            UpdateUI    = false;
            updateFunc_ = update;
            logPath_    = Utils.GetPath(Global.StatisticLogDirectory);
            Statistic   = new List <Mode.ServerStatistics>();
            exitFlag_   = false;

            DeleteExpiredLog();
            foreach (var server in config.vmess)
            {
                var statistic = new ServerStatistics(server.remarks, server.address, server.port, server.path, server.requestHost, 0, 0, 0, 0);
                Statistic.Add(statistic);
            }

            LoadFromFile();

            GrpcInit();

            workThread_ = new Thread(new ThreadStart(Run));
            workThread_.Start();
        }
Example #12
0
        public void LoadFromFile()
        {
            try
            {
                string result = Utils.LoadResource(Utils.GetPath(Global.StatisticLogOverall));
                if (!Utils.IsNullOrEmpty(result))
                {
                    //转成Json
                    serverStatistics_ = Utils.FromJson <ServerStatistics>(result);
                }

                if (serverStatistics_ == null)
                {
                    serverStatistics_ = new ServerStatistics();
                }
                if (serverStatistics_.server == null)
                {
                    serverStatistics_.server = new List <ServerStatItem>();
                }

                long ticks = DateTime.Now.Date.Ticks;
                foreach (ServerStatItem item in serverStatistics_.server)
                {
                    if (item.dateNow != ticks)
                    {
                        item.todayUp   = 0;
                        item.todayDown = 0;
                        item.dateNow   = ticks;
                    }
                }
            }
            catch (Exception ex)
            {
                Utils.SaveLog(ex.Message, ex);
            }
        }
Example #13
0
 public ServerUpTimeGlobal(ServerStatistics statistics)
     : base(SnmpOids.Server.UpTimeGlobal, appendRoot: false)
 {
     _statistics = statistics;
 }
 public ServerInfoController(ServerStatistics statistics)
 {
     _statistics = statistics;
 }
 public ServerLastRequestTime(ServerStatistics statistics)
     : base(SnmpOids.Server.LastRequestTime)
 {
     _statistics = statistics;
 }
Example #16
0
 public ServerUpTimeGlobal(ServerStatistics statistics)
     : base(SnmpOids.Server.UpTimeGlobal)
 {
     _startUpTime = statistics.StartUpTime;
 }
Example #17
0
 protected AdvancedClusterClient(string[] replicaAddresses) : base(replicaAddresses)
 {
     replicaStatistics = new ServerStatistics();
 }
Example #18
0
        public void NearCacheWithFailoverTest()
        {
            var cache = remoteManager.GetCache <string, string>();

            cache.Clear();
            ServerStatistics stats0 = cache.Stats();

            cache.Put("key1", "value1");
            cache.Get("key1");
            var stats1 = cache.Stats();

            Assert.AreEqual(int.Parse(stats0.GetStatsMap()["nearHits"]), int.Parse(stats1.GetStatsMap()["nearHits"]));
            string retVal = cache.Get("key1");         // near hit

            Assert.AreEqual("value1", retVal);
            var stats2 = cache.Stats();

            Assert.AreEqual(int.Parse(stats1.GetStatsMap()["nearHits"]) + 1, int.Parse(stats2.GetStatsMap()["nearHits"]));
            ClusterTestSuite.server2.ShutDownHotrodServer();
            // After the shutdown the client failover on the 11222 server and reset the near cache
            // let's verify that the get operation goes remotes
            ServerStatistics stats3 = null;

            // .Stat operation could fail for a while because the cluster suspects a split brain
            // do some retries
            for (var i = 0; i < 10; ++i)
            {
                try
                {
                    stats3 = cache.Stats();
                    break;
                }
                catch (Exception)
                {
                    System.Threading.Thread.Sleep(1000);
                }
            }
            // Assert that .Stats eventually succeeded
            Assert.IsNotNull(stats3);

            // The failover event needs some time to be detected, retries are needed
            ServerStatistics stats4 = null;

            for (var i = 0; i < 10; ++i)
            {
                stats3 = cache.Stats();
                retVal = cache.Get("key1");         // remote hit
                Assert.AreEqual("value1", retVal);
                stats4 = cache.Stats();
                if (int.Parse(stats3.GetStatsMap()["nearHits"]) == int.Parse(stats4.GetStatsMap()["nearHits"]))
                {
                    break;
                }
                System.Threading.Thread.Sleep(1000);
            }
            Assert.AreEqual(int.Parse(stats3.GetStatsMap()["nearHits"]), int.Parse(stats4.GetStatsMap()["nearHits"]));
            // Now try that near cache is working again
            retVal = cache.Get("key1");         // near hit
            Assert.AreEqual("value1", retVal);
            ServerStatistics stats5 = cache.Stats();

            Assert.AreEqual(int.Parse(stats4.GetStatsMap()["nearHits"]) + 1, int.Parse(stats5.GetStatsMap()["nearHits"]));
        }
Example #19
0
        public static void stats(ConsoleSystem.Arg arg)
        {
            TextTable table = new TextTable();

            table.AddColumn("id");
            table.AddColumn("name");
            table.AddColumn("time");
            table.AddColumn("kills");
            table.AddColumn("deaths");
            table.AddColumn("suicides");
            table.AddColumn("player");
            table.AddColumn("building");
            table.AddColumn("entity");
            Action <ulong, string> action = (Action <ulong, string>)((id, name) =>
            {
                ServerStatistics.Storage storage = ServerStatistics.Get(id);
                string shortString = TimeSpan.FromSeconds((double)storage.Get("time")).ToShortString();
                string str1        = storage.Get("kill_player").ToString();
                string str2        = (storage.Get("deaths") - storage.Get("death_suicide")).ToString();
                string str3        = storage.Get("death_suicide").ToString();
                string str4        = storage.Get("hit_player_direct_los").ToString();
                string str5        = storage.Get("hit_player_indirect_los").ToString();
                string str6        = storage.Get("hit_building_direct_los").ToString();
                string str7        = storage.Get("hit_building_indirect_los").ToString();
                string str8        = storage.Get("hit_entity_direct_los").ToString();
                string str9        = storage.Get("hit_entity_indirect_los").ToString();
                table.AddRow(new string[9]
                {
                    id.ToString(),
                    name,
                    shortString,
                    str1,
                    str2,
                    str3,
                    str4 + " / " + str5,
                    str6 + " / " + str7,
                    str8 + " / " + str9
                });
            });
            ulong filterID = arg.GetUInt64(0, 0UL);

            if (filterID == 0UL)
            {
                string str1 = arg.GetString(0, "");
                foreach (BasePlayer activePlayer in BasePlayer.activePlayerList)
                {
                    try
                    {
                        if (activePlayer.IsValid())
                        {
                            string str2 = StringExtensions.QuoteSafe(activePlayer.GetSubName(32));
                            if (str1.Length > 0)
                            {
                                if (!StringEx.Contains(str2, str1, CompareOptions.IgnoreCase))
                                {
                                    continue;
                                }
                            }
                            action(activePlayer.userID, str2);
                        }
                    }
                    catch (Exception ex)
                    {
                        table.AddRow(new string[2]
                        {
                            activePlayer.UserIDString,
                            StringExtensions.QuoteSafe(ex.Message)
                        });
                    }
                }
            }
            else
            {
                string     str        = "N/A";
                BasePlayer basePlayer = BasePlayer.activePlayerList.Find((Predicate <BasePlayer>)(p => (long)p.userID == (long)filterID));
                if (Object.op_Implicit((Object)basePlayer))
                {
                    str = StringExtensions.QuoteSafe(basePlayer.GetSubName(32));
                }
                action(filterID, str);
            }
            arg.ReplyWith(((object)table).ToString());
        }
 public ServerLastAuthorizedNonClusterAdminRequestTime(ServerStatistics statistics)
     : base(SnmpOids.Server.LastAuthorizedNonClusterAdminRequestTime)
 {
     _statistics = statistics;
 }
Example #21
0
 public PlayerStatistics(BasePlayer player)
 {
     this.steam  = new SteamStatistics(player);
     this.server = new ServerStatistics(player);
     this.combat = new CombatLog(player);
 }
Example #22
0
 public ServerUpTime(ServerStatistics statistics)
     : base(SnmpOids.Server.UpTime)
 {
     _statistics = statistics;
 }
 public void Init()
 {
     this.storage = ServerStatistics.Get(this.player.userID);
 }
Example #24
0
 public BaseServer()
 {
     ConsoleText = "";
     _logger     = HldslLogManager.GetLogManager().GetCurrentClassLogger();
     Statistics  = new ServerStatistics();
 }
Example #25
0
        public static void stats(Arg arg)
        {
            TextTable table = new TextTable();

            table.AddColumn("id");
            table.AddColumn("name");
            table.AddColumn("time");
            table.AddColumn("kills");
            table.AddColumn("deaths");
            table.AddColumn("suicides");
            table.AddColumn("player");
            table.AddColumn("building");
            table.AddColumn("entity");
            Action <ulong, string> action = delegate(ulong id, string name)
            {
                ServerStatistics.Storage storage = ServerStatistics.Get(id);
                string text2  = TimeSpanEx.ToShortString(TimeSpan.FromSeconds(storage.Get("time")));
                string text3  = storage.Get("kill_player").ToString();
                string text4  = (storage.Get("deaths") - storage.Get("death_suicide")).ToString();
                string text5  = storage.Get("death_suicide").ToString();
                string text6  = storage.Get("hit_player_direct_los").ToString();
                string text7  = storage.Get("hit_player_indirect_los").ToString();
                string text8  = storage.Get("hit_building_direct_los").ToString();
                string text9  = storage.Get("hit_building_indirect_los").ToString();
                string text10 = storage.Get("hit_entity_direct_los").ToString();
                string text11 = storage.Get("hit_entity_indirect_los").ToString();
                table.AddRow(id.ToString(), name, text2, text3, text4, text5, text6 + " / " + text7, text8 + " / " + text9, text10 + " / " + text11);
            };
            ulong uInt = arg.GetUInt64(0, 0uL);

            if (uInt == 0L)
            {
                string @string = arg.GetString(0);
                foreach (BasePlayer activePlayer in BasePlayer.activePlayerList)
                {
                    try
                    {
                        if (BaseEntityEx.IsValid(activePlayer))
                        {
                            string text = activePlayer.displayName.QuoteSafe();
                            if (@string.Length <= 0 || text.Contains(@string, CompareOptions.IgnoreCase))
                            {
                                action(activePlayer.userID, text);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        table.AddRow(activePlayer.UserIDString, ex.Message.QuoteSafe());
                    }
                }
            }
            else
            {
                string     arg2       = "N/A";
                BasePlayer basePlayer = BasePlayer.FindByID(uInt);
                if ((bool)basePlayer)
                {
                    arg2 = basePlayer.displayName.QuoteSafe();
                }
                action(uInt, arg2);
            }
            arg.ReplyWith(table.ToString());
        }
Example #26
0
        public void LoadFromFile()
        {
            if (!Directory.Exists(logPath_))
            {
                return;
            }

            // 总流量统计文件
            ///
            /// 文件结构
            /// LastUpdate [date] [time]
            /// UP [readable string] [amount]
            /// DOWN [readable string] [amount]
            /// 每行每个数据空格分隔

            try
            {
                Utils.SaveLog(logPath_ + Global.StatisticLogOverall);
                var overallPath = Path.Combine(logPath_, Global.StatisticLogOverall);
                if (File.Exists(overallPath))
                {
                    using (var overallReader = new StreamReader(overallPath))
                    {
                        while (!overallReader.EndOfStream)
                        {
                            var line = overallReader.ReadLine();
                            if (line.StartsWith("LastUpdate"))
                            {
                            }
                            else if (line.StartsWith("UP"))
                            {
                                var datas = line.Split(' ');
                                if (datas.Length < 3)
                                {
                                    return;
                                }
                                TotalUp = ulong.Parse(datas[2]);
                            }
                            else if (line.StartsWith("DOWN"))
                            {
                                var datas = line.Split(' ');
                                if (datas.Length < 3)
                                {
                                    return;
                                }
                                TotalDown = ulong.Parse(datas[2]);
                            }
                            else if (line.StartsWith("*"))
                            {
                                var datas = line.Split(' ');
                                if (datas.Length < 8)
                                {
                                    return;
                                }
                                var name      = datas[1];
                                var address   = datas[2];
                                var port      = int.Parse(datas[3]);
                                var path      = datas[4];
                                var host      = datas[5];
                                var totalUp   = ulong.Parse(datas[6]);
                                var totalDown = ulong.Parse(datas[7]);

                                var temp  = new ServerStatistics(name, address, port, path, host, 0, 0, 0, 0);
                                var index = Statistic.FindIndex(item => Utils.IsIdenticalServer(item, temp));
                                if (index != -1)
                                {
                                    Statistic[index].totalUp   = totalUp;
                                    Statistic[index].totalDown = totalDown;
                                }
                                else
                                {
                                    var s = new Mode.ServerStatistics(name, address, port, path, host, totalUp, totalDown, 0, 0);
                                    Statistic.Add(s);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Utils.SaveLog(ex.Message, ex);
            }

            try
            {
                Utils.SaveLog(logPath_ + $"{DateTime.Now.ToString("yyyy-MM-dd")}.txt");
                var dailyPath = Path.Combine(logPath_, $"{DateTime.Now.ToString("yyyy-MM-dd")}.txt");
                if (File.Exists(dailyPath))
                {
                    using (var dailyReader = new StreamReader(dailyPath))
                    {
                        while (!dailyReader.EndOfStream)
                        {
                            var line = dailyReader.ReadLine();
                            if (line.StartsWith("LastUpdate"))
                            {
                            }
                            else if (line.StartsWith("*"))
                            {
                                var datas = line.Split(' ');
                                if (datas.Length < 8)
                                {
                                    return;
                                }
                                var name      = datas[1];
                                var address   = datas[2];
                                var port      = int.Parse(datas[3]);
                                var path      = datas[4];
                                var host      = datas[5];
                                var todayUp   = ulong.Parse(datas[6]);
                                var todayDown = ulong.Parse(datas[7]);

                                var temp  = new ServerStatistics(name, address, port, path, host, 0, 0, 0, 0);
                                var index = Statistic.FindIndex(item => Utils.IsIdenticalServer(item, temp));
                                if (index != -1)
                                {
                                    Statistic[index].todayUp   = todayUp;
                                    Statistic[index].todayDown = todayDown;
                                }
                                else
                                {
                                    var s = new Mode.ServerStatistics(name, address, port, path, host, 0, 0, todayUp, todayDown);
                                    Statistic.Add(s);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Utils.SaveLog(ex.Message, ex);
            }
        }
        protected void TestStats(IRemoteCache <string, string> cache)
        {
            ServerStatistics stats = cache.Stats();

            Assert.NotNull(stats);
        }
Example #28
0
        public static void stats(ConsoleSystem.Arg arg)
        {
            TextTable textTable = new TextTable();

            textTable.AddColumn("id");
            textTable.AddColumn("name");
            textTable.AddColumn("time");
            textTable.AddColumn("kills");
            textTable.AddColumn("deaths");
            textTable.AddColumn("suicides");
            textTable.AddColumn("player");
            textTable.AddColumn("building");
            textTable.AddColumn("entity");
            Action <ulong, string> action = (ulong id, string name) => {
                ServerStatistics.Storage storage = ServerStatistics.Get(id);
                string shortString = TimeSpan.FromSeconds((double)storage.Get("time")).ToShortString();
                string str         = storage.Get("kill_player").ToString();
                string str1        = (storage.Get("deaths") - storage.Get("death_suicide")).ToString();
                string str2        = storage.Get("death_suicide").ToString();
                string str3        = storage.Get("hit_player_direct_los").ToString();
                string str4        = storage.Get("hit_player_indirect_los").ToString();
                string str5        = storage.Get("hit_building_direct_los").ToString();
                string str6        = storage.Get("hit_building_indirect_los").ToString();
                string str7        = storage.Get("hit_entity_direct_los").ToString();
                string str8        = storage.Get("hit_entity_indirect_los").ToString();
                textTable.AddRow(new string[] { id.ToString(), name, shortString, str, str1, str2, string.Concat(str3, " / ", str4), string.Concat(str5, " / ", str6), string.Concat(str7, " / ", str8) });
            };
            ulong num = arg.GetUInt64(0, (ulong)0);

            if (num != 0)
            {
                string     str9       = "N/A";
                BasePlayer basePlayer = BasePlayer.activePlayerList.Find((BasePlayer p) => p.userID == num);
                if (basePlayer)
                {
                    str9 = basePlayer.GetSubName(32).QuoteSafe();
                }
                action(num, str9);
            }
            else
            {
                string str10 = arg.GetString(0, "");
                foreach (BasePlayer basePlayer1 in BasePlayer.activePlayerList)
                {
                    try
                    {
                        if (basePlayer1.IsValid())
                        {
                            string str11 = basePlayer1.GetSubName(32).QuoteSafe();
                            if (str10.Length <= 0 || str11.Contains(str10, CompareOptions.IgnoreCase))
                            {
                                action(basePlayer1.userID, str11);
                            }
                        }
                    }
                    catch (Exception exception1)
                    {
                        Exception exception = exception1;
                        textTable.AddRow(new string[] { basePlayer1.UserIDString, exception.Message.QuoteSafe() });
                    }
                }
            }
            arg.ReplyWith(textTable.ToString());
        }
 /// <summary>
 /// Returns statistics about the usage of the VoltDB database.
 /// </summary>
 /// <param name="component">The specific statistics component to query the system for.</param>
 /// <param name="isInterval">Whether the returned statistics should be aggregated since the time the cluster
 /// was started of since the last interval call.</param>
 /// <returns>Statistics information table set.</returns>
 public Response<Table[]> Statistics(ServerStatistics component, bool isInterval)
 {
     return this.Executor.Execute<Table[]>(
                                            Timeout.Infinite
                                          , "@Statistics"
                                          , component.ToString().ToUpper()
                                          , isInterval ? 1 : 0
                                          );
 }
Example #30
0
        private static void Run()
        {
            ServicePointManager.DefaultConnectionLimit = 1000000;
            ServicePointManager.MaxServicePoints       = 1000000;

            Root.ServiceBusInstance = new ServiceBusImpl(Config.ServiceBus.MulticastMAC, Config.ServiceBus.MulticastIP, Config.ServiceBus.MulticastPort);

            ISerializer  serializerService = Root.ServiceBusInstance.AddLocalService <ISerializer>(new Serializer());
            IPeerManager peerManager       = Root.ServiceBusInstance.AddLocalService <IPeerManager>(new PeerManagerImpl());

            foreach (var key in Config.MessageProcessors.AllKeys)
            {
                var element = Config.MessageProcessors[key];

                string typeName = element.Value;
                Type   type     = Type.GetType(typeName);

                if (type != null)
                {
                    var wrapped = Activator.CreateInstance(type);
                    IMessageProcessor processor = (IMessageProcessor)wrapped;
                    Root.ServiceBusInstance.AddMessageProcessor(key, processor);
                }
            }

            IMessageProcessor peerManagerMP = Root.ServiceBusInstance.GetMessageProcessor(Program.PEER_MANAGER_MESSAGE_PROCESSOR_KEY);
            IMessageProcessor cachingMP     = Root.ServiceBusInstance.GetMessageProcessor(Program.CACHING_MESSAGE_PROCESSOR_KEY);

            Root.ServiceBusInstance.StartAsync(BusStarted, BusStopped);

            List <string> localServerIp = new List <string>();

            foreach (var nic in System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces())
            {
                if (nic.NetworkInterfaceType == System.Net.NetworkInformation.NetworkInterfaceType.Ethernet && nic.OperationalStatus == System.Net.NetworkInformation.OperationalStatus.Up)
                {
                    foreach (var address in nic.GetIPProperties().UnicastAddresses)
                    {
                        if (address.Address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
                        {
                            var ipAddress = address.Address.ToString();
                            localServerIp.Add(string.Format("http://{0}:{1}/", ipAddress, _config.HttpServer.Port));
                        }
                    }
                }
            }

            localServerIp.Add(string.Format("http://{0}:{1}/", "localhost", _config.HttpServer.Port));

            foreach (var address in localServerIp)
            {
                HealthTracing.TraceInformation(address);
            }

            var statistics = new ServerStatistics();

            string httpServerRoot = _config.HttpServer.RootDisk;

            if (httpServerRoot.StartsWith("\\"))
            {
                var uri         = new Uri(Assembly.GetExecutingAssembly().CodeBase);
                var relativeDir = Path.GetDirectoryName(uri.AbsolutePath);
                relativeDir = WebUtility.UrlDecode(relativeDir);

                httpServerRoot = relativeDir + httpServerRoot;
            }

            if (Directory.Exists(httpServerRoot) == false)
            {
                httpServerRoot = null; // which is fine because we might have a directoryless server.
            }

            IServer httpServer = new HttpServerImpl(httpServerRoot, localServerIp.ToArray());

            httpServer.StartAsync();

            int loopCount = 0;

            ServiceBusImpl typedSB = (ServiceBusImpl)Root.ServiceBusInstance;

            while (_running)
            {
                SendKeepAlive(serializerService, Program.PEER_MANAGER_MESSAGE_PROCESSOR_KEY);
                peerManager.Refresh();

                //HealthTracing.TraceInformation("Tasks:{0}{1}", Environment.NewLine, LPScheduler.Count);
                HealthTracing.TraceInformation("ServiceBus:{0}{1}", Environment.NewLine, Root.ServiceBusInstance.ToString());
                HealthTracing.TraceInformation(httpServer.ToString());

                foreach (var key in Root.ServiceBusInstance.MessageProcessors)
                {
                    try
                    {
                        HealthTracing.TraceInformation("Key={1}{0}{2}", Environment.NewLine, key, Root.ServiceBusInstance.GetMessageProcessor(key).ToString());
                    }
                    catch (Exception ex)
                    {
                    }
                }

                Thread.Sleep(5000);

                loopCount++;
            }

            httpServer.Stop();
        }