Пример #1
0
 public ServerGroupModel(ServerGroup group)
 {
     this.GroupId              = group.GroupId;
     this.GroupName            = group.GroupName;
     this.AzureBackupEnabled   = group.AzureBackupEnabled;
     this.BackupServerCount    = group.BackupServerCount;
     this.ProtectionGroupCount = group.ProtectionGroupCount;
     this.VirtualMachineCount  = group.VirtualMachineCount;
 }
Пример #2
0
    protected void ServerGroupIndexChanged(object sender, EventArgs e)
    {
        ServerGroup group = ServerGroupDropDownList.SelectedServerGroup;

        if (group != null)
        {
            ServerDropDownList.CreateServerList(group);
        }
    }
Пример #3
0
        private IChannel InitServerChannel()
        {
            IChannel channel = NewChannelFactory();

            channel.Pipeline.AddLast("ServerAcceptor", new ServerChannelAcceptor(WorkGroup, this.SetPipeline, this.ChannelConfig));

            ServerGroup.Next().Register(channel);

            return(channel);
        }
        public Object GetServerInfo(ServerGroup group)
        {
            Object oSvcInfo = null;

            if (group == ServerGroup.Admin)
            {
            }

            return(oSvcInfo);
        }
Пример #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="resourceToPost"></param>
        /// <returns></returns>
        public Task <ServerGroup> CreateServerGroupAsync(ServerGroup resourceToPost)
        {
            if (resourceToPost == null)
            {
                throw new ArgumentNullException("resourceToPost");
            }

            var requestUrl = this.CreateRequestUri(VmBackupClient.ServerGroups);

            return(this.restClient.PostResourceAsync <ServerGroup, VmBackupErrorResource>(resourceToPost, requestUrl)
                   .HandleException <ServerGroup>(this.HandleAggregateException));
        }
Пример #6
0
        public int Save(ServerGroup @group)
        {
            var query = new SqlInsert(ServerMailGroupTable.TABLE_NAME, true)
                        .InColumnValue(ServerMailGroupTable.Columns.Id, group.Id)
                        .InColumnValue(ServerMailGroupTable.Columns.Tenant, group.Tenant)
                        .InColumnValue(ServerMailGroupTable.Columns.Address, group.Address)
                        .InColumnValue(ServerMailGroupTable.Columns.AddressId, group.AddressId)
                        .InColumnValue(ServerMailGroupTable.Columns.DateCreated, group.DateCreated)
                        .Identity(0, 0, true);

            return(Db.ExecuteScalar <int>(query));
        }
Пример #7
0
 public static ServerGroup CreateServerGroup(SqlDataReader sqlDataReader)
 {
     if (sqlDataReader.Read())
     {
         ServerGroup group = GenerateServerGroup(sqlDataReader);
         return(group);
     }
     else
     {
         return(null);
     }
 }
Пример #8
0
 public void CreateServerList(ServerGroup serverGroup, GameServer.ServerType serverType)
 {
     this.Items.Clear();
     foreach (GameServer server in serverGroup.List)
     {
         if (server.Type == serverType)
         {
             ListItem item = new ListItem(server.Name, server.Id.ToString());
             this.Items.Add(item);
         }
     }
 }
Пример #9
0
        private static ServerGroup GenerateServerGroup(SqlDataReader sqlDataReader)
        {
            ServerGroup group = new ServerGroup();

            group.GroupId              = (Guid)sqlDataReader["GroupId"];
            group.GroupName            = (string)sqlDataReader["GroupName"];
            group.AzureBackupEnabled   = (bool)sqlDataReader["AzureBackupEnabled"];
            group.BackupServerCount    = (int)sqlDataReader["BackupServerCount"];
            group.ProtectionGroupCount = (int)sqlDataReader["ProtectionGroupCount"];
            group.VirtualMachineCount  = (int)sqlDataReader["VirtualMachineCount"];

            return(group);
        }
Пример #10
0
 public ServerGroup GetForServer(ServerName serverName)
 {
     lock (locker)
     {
         ServerGroup sg;
         if (!serverNameToServerGroupMap.TryGetValue(serverName, out sg))
         {
             sg = ServerGroup.CreateServerScoped(serverName);
             serverNameToServerGroupMap.Add(serverName, sg);
         }
         return(sg);
     }
 }
Пример #11
0
        protected ServerGroup ToServerGroup(object[] r)
        {
            var group = new ServerGroup
            {
                Id          = Convert.ToInt32(r[0]),
                Tenant      = Convert.ToInt32(r[1]),
                AddressId   = Convert.ToInt32(r[2]),
                Address     = Convert.ToString(r[3]),
                DateCreated = Convert.ToDateTime(r[4])
            };

            return(group);
        }
Пример #12
0
        public void ResolveServerGroupTest()
        {
            AppInstance.RegisterTypeAlias <ServerGroup>();
            var targetType = TypeExtension.GetMapType("ServerGroup");

            Assert.IsNotNull(targetType);
            Assert.AreEqual(typeof(ServerGroup), targetType);

            var configXmlTemplete = @"<configuration xmlns:c='http://m2sa.net/Schema/Config'>
                    <serverGroup groupName='@groupName' c:type='serverGroup'>
                        <servers>
                          <server serverName='@serverName0' serverIP='@serverIP0' servicePort='@servicePort0'/>
                          <server serverName='@serverName1' serverIP='@serverIP1' servicePort='@servicePort1'/>
                        </servers>
                    </serverGroup></configuration>";

            var groupName = TestHelper.RandomizeString("group-");

            var serverName0  = TestHelper.RandomizeString("server-");
            var serverIP0    = TestHelper.RandomizeString("ip-");
            var servicePort0 = TestHelper.RandomizeInt();

            var serverName1  = TestHelper.RandomizeString("server-");
            var serverIP1    = TestHelper.RandomizeString("ip-");
            var servicePort1 = TestHelper.RandomizeInt();

            var configInfo = configXmlTemplete.Replace("@groupName", groupName);

            configInfo = configInfo.Replace("@serverName0", serverName0).Replace("@serverIP0", serverIP0).Replace("@servicePort0", servicePort0.ToString());
            configInfo = configInfo.Replace("@serverName1", serverName1).Replace("@serverIP1", serverIP1).Replace("@servicePort1", servicePort1.ToString());

            var configXml = new XmlDocument();

            configXml.LoadXml(configInfo);
            var node = configXml.SelectSingleNode("/configuration/serverGroup");

            var serverGroup = new ServerGroup();

            serverGroup.Initialize(new ConfigNode(node));

            Assert.AreEqual(groupName, serverGroup.GroupName);
            Assert.AreEqual(2, serverGroup.Servers.Count);

            Assert.AreEqual(serverName0, serverGroup.Servers[0].ServerName);
            Assert.AreEqual(serverIP0, serverGroup.Servers[0].ServerIP);
            Assert.AreEqual(servicePort0, serverGroup.Servers[0].ServicePort);

            Assert.AreEqual(serverName1, serverGroup.Servers[1].ServerName);
            Assert.AreEqual(serverIP1, serverGroup.Servers[1].ServerIP);
            Assert.AreEqual(servicePort1, serverGroup.Servers[1].ServicePort);
        }
Пример #13
0
        async Task FindLatestDumpForServerGroup(ServerGroup serverGroup)
        {
            var beginDate = Time.Get.LocalNowOffset;

            var maxBackDate = Time.Get.LocalNow - MaxDaysBack;

            SkillDumpInfo[] dumps = new SkillDumpInfo[0];
            if (skillDumpsDirectory.Exists)
            {
                dumps = skillDumpsDirectory.GetFiles().Select(ConvertFileInfoToSkillDumpInfo)
                        .Where(info => info != null && info.Stamp > maxBackDate)
                        .OrderByDescending(info => info.Stamp)
                        .ToArray();
            }

            SkillDump foundDump = null;

            foreach (var dumpInfo in dumps)
            {
                var server = await character.TryGetHistoricServerAtLogStampAsync(dumpInfo.Stamp).ConfigureAwait(false);

                if (server != null)
                {
                    if (server.ServerGroup == serverGroup)
                    {
                        foundDump = new RealSkillDump(serverGroup, dumpInfo, logger);
                        break;
                    }
                }
                else
                {
                    logger.Log(LogLevel.Info,
                               "Could not identify server for skill dump: " + dumpInfo.FileInfo.FullName,
                               this,
                               null);
                }
            }

            if (foundDump != null)
            {
                latestSkillDumps[serverGroup] = foundDump;
            }
            else
            {
                // if nothing found, place a stub to prevent another file search
                latestSkillDumps[serverGroup] = new StubSkillDump(serverGroup);
            }

            lastRebuild = beginDate;
        }
Пример #14
0
        private ServerGroup NavigateToServerGroup(RegisteredServersStore store, string relativePath, bool alreadyParent = true)
        {
            if (string.IsNullOrEmpty(relativePath))
            {
                return(store.DatabaseEngineServerGroup);
            }

            // Get key chain from URN
            Urn         urn      = new Urn(relativePath);
            SfcKeyChain keyChain = alreadyParent ? new SfcKeyChain(urn, store as ISfcDomain) : new SfcKeyChain(urn, store as ISfcDomain).Parent;

            ServerGroup parentGroup = GetNodeFromKeyChain(keyChain, store.DatabaseEngineServerGroup);

            return(parentGroup);
        }
Пример #15
0
        static async Task Main(string[] args)
        {
            var customer = await new Customer("ABC-1234", "ACME").Save();
            var group    = new ServerGroup("Hadoop Servers");
            var server   = new Server("Kafka Server");
            var cpu      = new Resource("CPU");
            var memory   = new Resource("Memory");

            server.Resources.Add(cpu);
            server.Resources.Add(memory);
            group.Servers.Add(server);
            customer.ServerGroups.Add(group);
            //await customer.Save();
            await customer.Delete();
        }
Пример #16
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         if (!WebUtil.CheckPrivilege(WebConfig.FunctionUpdateServerUploadHistory, OpType.READ, Session))
         {
             Response.Redirect(WebConfig.PageNotEnoughPrivilege, true);
         }
         ServerGroup group = ServerGroupDropDownList.SelectedServerGroup;
         if (group != null)
         {
             ServerDropDownList.CreateServerList(group);
         }
     }
 }
Пример #17
0
 public RealSkillDump(ServerGroup serverGroup, [NotNull] SkillDumpInfo dumpInfo,
                      [NotNull] IWurmApiLogger logger)
     : base(serverGroup)
 {
     if (dumpInfo == null)
     {
         throw new ArgumentNullException(nameof(dumpInfo));
     }
     if (logger == null)
     {
         throw new ArgumentNullException(nameof(logger));
     }
     this.dumpInfo = dumpInfo;
     this.logger   = logger;
     skillLevels   = ParseDump();
 }
Пример #18
0
        private void DeserializeGroups(Configuration config, IList datas)
        {
            foreach (IDictionary data in datas)
            {
                ServerGroup    group      = new ServerGroup();
                Type           groupType  = group.GetType();
                PropertyInfo[] properties = groupType.GetProperties(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);

                foreach (PropertyInfo property in properties)
                {
                    WritePropertyValue(group, property, data);
                }

                config.Groups.Add(group);
            }
        }
Пример #19
0
        async Task <SkillInfo> TryGetSkillFromDumps(string skillName, ServerGroup serverGroup)
        {
            SkillInfo skill = null;
            var       dump  = await skillDumps.GetSkillDumpAsync(serverGroup).ConfigureAwait(false);

            var skillinfo = dump?.TryGetSkillLevel(skillName);

            if (skillinfo != null)
            {
                skill = new SkillInfo(skillName, skillinfo.Value, dump.Stamp, null)
                {
                    Server = await character.TryGetHistoricServerAtLogStampAsync(dump.Stamp)
                };
            }
            return(skill);
        }
Пример #20
0
 public async Task HandleAddServerGroupRequest(AddServerGroupParams addServerGroupParams, RequestContext <bool> requestContext)
 {
     Logger.Write(TraceEventType.Verbose, "HandleAddServerGroupRequest");
     try
     {
         CmsTask = Task.Run(async() =>
         {
             try
             {
                 ServerConnection serverConn = ValidateAndCreateConnection(addServerGroupParams.ParentOwnerUri);
                 if (serverConn != null)
                 {
                     ServerGroup parentGroup;
                     RegisteredServersStore store = new RegisteredServersStore(serverConn);
                     // It's a CMS server
                     if (string.IsNullOrEmpty(addServerGroupParams.RelativePath))
                     {
                         parentGroup = store.DatabaseEngineServerGroup;
                     }
                     else
                     {
                         parentGroup = NavigateToServerGroup(store, addServerGroupParams.RelativePath);
                     }
                     // Add the new group (intentionally not cheching existence to reuse the exception message)
                     ServerGroup serverGroup = new ServerGroup(parentGroup, addServerGroupParams.GroupName)
                     {
                         Description = addServerGroupParams.GroupDescription
                     };
                     serverGroup.Create();
                     await requestContext.SendResult(true);
                 }
                 else
                 {
                     await requestContext.SendResult(false);
                 }
             }
             catch (Exception e)
             {
                 await requestContext.SendError(e);
             }
         });
     }
     catch (Exception e)
     {
         await requestContext.SendError(e);
     }
 }
Пример #21
0
    private string GetGroupFullName(ServerGroup group, string groupPath)
    {
        FSEyeObject groupParent = group.SecurityObject.Parent;

        while (groupParent.Parent != null)
        {
            ServerGroup parentGroup = TheAdminServer.GameServerManager.GetGameServerGroup(groupParent.Id);
            if (parentGroup == null)
            {
                break;
            }
            groupPath   = parentGroup.Name + "/" + groupPath;
            groupParent = parentGroup.SecurityObject.Parent;
        }

        return(groupPath);
    }
Пример #22
0
 private ServerGroup GetNodeFromKeyChain(SfcKeyChain keyChain, ServerGroup rootServerGroup)
 {
     if (keyChain == rootServerGroup.KeyChain)
     {
         return(rootServerGroup);
     }
     if (keyChain != rootServerGroup.KeyChain)
     {
         var parent = GetNodeFromKeyChain(keyChain.Parent, rootServerGroup);
         if (parent != null && parent is ServerGroup)
         {
             var server = (parent as ServerGroup).ServerGroups.FirstOrDefault(x => x.KeyChain == keyChain);
             return(server);
         }
     }
     return(null);
 }
Пример #23
0
    private void AddServerGroup(ServerGroup group, string cabinetName)
    {
        if (group == null)
        {
            return;
        }

        if (group.GroupType == ServerGroup.Type.Server)
        {
            if (group.Cabinet != string.Empty)
            {
                if (cabinetName != string.Empty && cabinetName == group.Cabinet)
                {
                    ListBoxCabinet.Items.Add(new ListItem(group.Name, group.Id.ToString()));
                }
            }
            else
            {
                ListBoxGroup.Items.Add(new ListItem(group.Name, group.Id.ToString()));
            }
        }
        else
        {
            foreach (ServerGroup childGroup in group.List)
            {
                if (childGroup.GroupType == ServerGroup.Type.Server)
                {
                    if (childGroup.Cabinet != string.Empty)
                    {
                        if (cabinetName != string.Empty && cabinetName == childGroup.Cabinet)
                        {
                            ListBoxCabinet.Items.Add(new ListItem(childGroup.Name, childGroup.Id.ToString()));
                        }
                    }
                    else
                    {
                        ListBoxGroup.Items.Add(new ListItem(childGroup.Name, childGroup.Id.ToString()));
                    }
                }
                else
                {
                    AddServerGroup(childGroup, cabinetName);
                }
            }
        }
    }
Пример #24
0
 private void GetServerInGroup(ServerGroup group, IList <GameServer> serverList)
 {
     if (group.GroupType == ServerGroup.Type.Group)
     {
         foreach (ServerGroup servergroup in group.List)
         {
             GetServerInGroup(servergroup, serverList);
         }
     }
     else if (group.GroupType == ServerGroup.Type.Server)
     {
         foreach (GameServer server in group.List)
         {
             serverList.Add(server);
         }
     }
 }
Пример #25
0
    TreeNode CreateServerGroupNode(ServerGroup group)
    {
        if (group != null)
        {
            if (group.List.Count == 0)
            {
                return(null);
            }
            TreeNode node = new TreeNode();
            node.Text  = group.Name;
            node.Value = group.Id.ToString();

            if (group.GroupType == ServerGroup.Type.Group)
            {
                foreach (ServerGroup childGroup in group.List)
                {
                    TreeNode childNode = CreateServerGroupNode(childGroup);
                    if (childNode != null)
                    {
                        node.ChildNodes.Add(childNode);
                    }
                }
            }
            else if (group.GroupType == ServerGroup.Type.Server)
            {
                node.NavigateUrl = "~/GameServer/ServerList.aspx?serverGroupId=" + node.Value;
                node.Value       = "g" + group.Id.ToString();

                // 显示group和下面的server
                //foreach (GameServer childServer in group.List)
                //{
                //    TreeNode childNode = new TreeNode();
                //    childNode.Text = childServer.Name;
                //    childNode.Value = 's' + childServer.Id.ToString();
                //    if (childNode != null)
                //    {
                //        node.ChildNodes.Add(childNode);
                //    }
                //}
            }

            return(node);
        }

        return(null);
    }
Пример #26
0
        void UpdatePlayerCount(int playerCount, ServerGroup thisGroup)
        {
            if (_playerCountQueue.Count >= PlayerCountQueueLength)
            {
                _playerCountQueue.Dequeue();
            }

            if (_server.GameServiceState != GameServer.ServiceState.Stopping)
            {
                _server.GameServiceState = GameServer.ServiceState.Running;
                if (_server.PID <= 0)
                {
                    string[] para = new string[1] {
                        _server.Id.ToString()
                    };
                    _server.DoPlugInAction(SecurityManager.SystemAutomationId, E2gServerPID.PlugInGuid, E2gServerPID.actionKey, para);
                }
            }

            //TODO 调试用
            //playerCount = s_random.Next(2000);

            DateTime now = DateTime.Now;

            PlayerCountInfo info = new PlayerCountInfo();

            info.Count = playerCount;
            info.Time  = now;
            _playerCountQueue.Enqueue(info);

            if (_lastPlayerCountStatisticHour != now.Hour)
            {
                DoPlayerCountStatistic(now);
            }

            _startingForgive = true;
            _lastPing        = now;

            //记录历史最高人数
            if (playerCount > thisGroup.MaxPlayer)
            {
                thisGroup.MaxPlayer = playerCount;
                thisGroup.SetGroupMaxPlays(playerCount);
            }
        }
Пример #27
0
    protected void ButtonDeleteServerGroup_Click(object sender, EventArgs e)
    {
        //需要在GameServerManager上有Write的权限
        if (!WebUtil.CheckPrivilege(TheAdminServer.GameServerManager.SecurityObject, OpType.WRITE, Session))
        {
            LabelOpMsg.Text    = StringDef.NotEnoughPrivilege;
            LabelOpMsg.Visible = true;
            return;
        }

        try
        {
            object selectedObj = GetSelectedObject();
            if (selectedObj != null && selectedObj.GetType() == typeof(ServerGroup))
            {
                ServerGroup group           = selectedObj as ServerGroup;
                string      serverGroupName = group.Name;

                //此段代码为额外的检验代码
                //防止客户端意外传回错误数据导致误删除
                if (group.List.Count != 0)
                {
                    LabelOpMsg.Text    = StringDef.OperationFail + StringDef.Colon + "服务器组 " + serverGroupName + " 不为空,不允许删除操作";
                    LabelOpMsg.Visible = true;
                    return;
                }

                TheAdminServer.GameServerManager.DeleteServerGroup(group.Id);
                ServerGroupDropDownList.Refresh();
                CreateServerGroupTree();

                LabelSuccess.Text    = StringDef.OperationSucceed + StringDef.Colon + "服务器组 " + serverGroupName + " 删除成功";
                LabelSuccess.Visible = true;
            }
        }
        catch (Exception ex)
        {
            LabelOpMsg.Text    = StringDef.OperationFail + StringDef.Colon + ex.Message;
            LabelOpMsg.Visible = true;
            return;
        }
    }
Пример #28
0
        public static ObservableCollection <ServerGroup> GetServerGroups_All(int matchID)
        {
            if (!CheckDBConnection())
            {
                return(null);
            }
            SqlDataReader sr = null;
            ObservableCollection <ServerGroup> serverGroups = new ObservableCollection <ServerGroup>();

            try
            {
                SqlCommand sqlCmd = DVCommon.g_DataBaseCon.CreateCommand();
                sqlCmd.CommandType = CommandType.StoredProcedure;
                sqlCmd.CommandText = "Proc_JudgePoint_GetMatchServerGroup_All";
                sqlCmd.Parameters.Add("@MatchID", SqlDbType.Int).Value = matchID;
                sqlCmd.Parameters.Add("@LanguageCode", SqlDbType.NVarChar, 10).Value = "ENG";
                sr = sqlCmd.ExecuteReader();

                while (sr.Read())
                {
                    ServerGroup group = new ServerGroup();
                    group.GroupLongName  = (string)GetNoNullValue(sr, "ServerGroupLongName", "");
                    group.GroupShortName = (string)GetNoNullValue(sr, "ServerGroupShortName", "");
                    group.GroupID        = (int)GetNoNullValue(sr, "GroupID", -1);
                    group.Order          = (int)GetNoNullValue(sr, "Order", -1);
                    serverGroups.Add(group);
                }
                return(serverGroups);
            }
            catch (System.Exception ex)
            {
                AthleticsCommon.LastErrorMsg = "GetServerGroups():" + ex.Message;
                return(null);
            }
            finally
            {
                if (sr != null)
                {
                    sr.Close();
                }
            }
        }
Пример #29
0
        public Irc(IrcServer server)
        {
            this.server = server;
            ircMessages = new ObservableCollection <Message>();

            channelList        = new ServerGroup(new ObservableCollection <Channel>());
            channelList.Server = server.name;

            channelBuffers = new Dictionary <string, MessageCollection>(StringComparer.OrdinalIgnoreCase);
            channelStore   = new Dictionary <string, ChannelStore>(StringComparer.OrdinalIgnoreCase);

            IsAuthed = false;

            ConnCheck = new Connection();
            AddChannel("Server");

            ConnCheck.ConnectionChanged += async(connected) =>
                                           await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => ConnectionChanged(connected)
                                                                                                         );
        }
Пример #30
0
        public async Task <SkillInfo> TryGetCurrentSkillLevelAsync(string skillName, ServerGroup serverGroup, TimeSpan maxTimeToLookBackInLogs)
        {
            // note: semaphore(1,1) in this method ensures, that there are no races
            // be extra careful if loosening this constraint!

            try
            {
                await scanJobSemaphore.WaitAsync().ConfigureAwait(false);
                await ScanLogsHistory(maxTimeToLookBackInLogs).ConfigureAwait(false);

                var mapSkill  = TryGetSkillFromMap(skillName, serverGroup);
                var dumpSkill = await TryGetSkillFromDumps(skillName, serverGroup);

                return(ChooseLatestSkillOrNull(mapSkill, dumpSkill));
            }
            finally
            {
                scanJobSemaphore.Release();
            }
        }
Пример #31
0
		void UpdatePlayerCount(int playerCount,ServerGroup thisGroup)
		{
			if (_playerCountQueue.Count >= PlayerCountQueueLength)
				_playerCountQueue.Dequeue();

			if (_server.GameServiceState != GameServer.ServiceState.Stopping)
			{				
				_server.GameServiceState = GameServer.ServiceState.Running;
                if (_server.PID <= 0)
                {
                    string[] para = new string[1] { _server.Id.ToString() };
                    _server.DoPlugInAction(SecurityManager.SystemAutomationId, E2gServerPID.PlugInGuid, E2gServerPID.actionKey, para);
                }
			}

			//TODO 调试用
			//playerCount = s_random.Next(2000);

			DateTime now = DateTime.Now;

			PlayerCountInfo info = new PlayerCountInfo();
			info.Count = playerCount;
			info.Time = now;
			_playerCountQueue.Enqueue(info);
								
			if (_lastPlayerCountStatisticHour != now.Hour)
			{
				DoPlayerCountStatistic(now);
			}

			_startingForgive = true;
			_lastPing = now;

            //记录历史最高人数
            if (playerCount > thisGroup.MaxPlayer)
            {
                thisGroup.MaxPlayer = playerCount;
                thisGroup.SetGroupMaxPlays(playerCount);
            }
		}