コード例 #1
0
 /// <summary>
 /// 验证实体options的数据有效性
 /// </summary>
 private void Validate()
 {
     this.AppId      = AppId.Trim();
     this.MetaServer = MetaServer.Trim().TrimEnd('/');
     this.Cluster    = Cluster.Trim();
     this.DeployIp   = string.IsNullOrWhiteSpace(DeployIp) ? GetHostIp() : DeployIp.Trim();
     this.Namespaces = Namespaces.Select(m => m.Trim()).Distinct().ToArray();
 }
コード例 #2
0
ファイル: CommonUtils.cs プロジェクト: ctripcorp/chystrix.net
        static CommonUtils()
        {
            CommandExecutionEvents     = (CommandExecutionEventEnum[])Enum.GetValues(typeof(CommandExecutionEventEnum));
            CoreCommandExecutionEvents = new CommandExecutionEventEnum[]
            {
                CommandExecutionEventEnum.Success, CommandExecutionEventEnum.Failed, CommandExecutionEventEnum.Timeout, CommandExecutionEventEnum.ShortCircuited,
                CommandExecutionEventEnum.Rejected, CommandExecutionEventEnum.BadRequest
            };
            ValuableCommandExecutionEvents = new CommandExecutionEventEnum[]
            {
                CommandExecutionEventEnum.Success, CommandExecutionEventEnum.Failed, CommandExecutionEventEnum.Timeout, CommandExecutionEventEnum.ShortCircuited
            };
            CoreFailedCommandExecutionEvents = new CommandExecutionEventEnum[]
            {
                CommandExecutionEventEnum.Failed, CommandExecutionEventEnum.Timeout, CommandExecutionEventEnum.ShortCircuited,
                CommandExecutionEventEnum.Rejected, CommandExecutionEventEnum.BadRequest
            };

            AppId = ConfigurationManager.AppSettings["AppId"];
            if (string.IsNullOrWhiteSpace(AppId))
            {
                AppId = null;
            }
            else
            {
                AppId = AppId.Trim();
            }

            Log = ComponentFactory.CreateLog(typeof(CommonUtils));

            try
            {
                HostIP = Dns.GetHostAddresses(Dns.GetHostName())
                         .Where(c => c.AddressFamily == AddressFamily.InterNetwork)
                         .Select(c => c.ToString()).FirstOrDefault();
            }
            catch (Exception ex)
            {
                Log.Log(LogLevelEnum.Fatal, "Failed to get host IP.", ex);
            }
        }
コード例 #3
0
        static ServiceUtils()
        {
            MobileWriteBackExtensionKeys = new List <string>()
            {
                ServiceUtils.MobileAuthTokenExtensionKey
            };

            AppId = ConfigurationManager.AppSettings["AppId"];
            if (string.IsNullOrWhiteSpace(AppId))
            {
                AppId = null;
            }
            else
            {
                AppId = AppId.Trim();
            }

            AntServiceStackVersion = typeof(ServiceUtils).Assembly.GetName().Version.ToString();
            SOA2VersionCatName     = SOA2VersionCatKeyPrefix + AntServiceStackVersion;

            HostIP      = HostUtility.IPv4;
            MachineName = HostUtility.Name;
        }
コード例 #4
0
 static CommonUtils()
 {
     CommandExecutionEvents = (CommandExecutionEventEnum[])System.Enum.GetValues(typeof(CommandExecutionEventEnum));
     CommandExecutionEventEnum[] enumArray = new CommandExecutionEventEnum[6];
     enumArray[1] = CommandExecutionEventEnum.Failed;
     enumArray[2] = CommandExecutionEventEnum.Timeout;
     enumArray[3] = CommandExecutionEventEnum.ShortCircuited;
     enumArray[4] = CommandExecutionEventEnum.Rejected;
     enumArray[5] = CommandExecutionEventEnum.BadRequest;
     CoreCommandExecutionEvents = enumArray;
     CommandExecutionEventEnum[] enumArray2 = new CommandExecutionEventEnum[4];
     enumArray2[1] = CommandExecutionEventEnum.Failed;
     enumArray2[2] = CommandExecutionEventEnum.Timeout;
     enumArray2[3] = CommandExecutionEventEnum.ShortCircuited;
     ValuableCommandExecutionEvents   = enumArray2;
     CoreFailedCommandExecutionEvents = new CommandExecutionEventEnum[] { CommandExecutionEventEnum.Failed, CommandExecutionEventEnum.Timeout, CommandExecutionEventEnum.ShortCircuited, CommandExecutionEventEnum.Rejected, CommandExecutionEventEnum.BadRequest };
     AppId = ConfigurationManager.AppSettings["AppId"];
     if (string.IsNullOrWhiteSpace(AppId))
     {
         AppId = null;
     }
     else
     {
         AppId = AppId.Trim();
     }
     Log = ComponentFactory.CreateLog(typeof(CommonUtils));
     try
     {
         HostIP = (from c in Dns.GetHostAddresses(Dns.GetHostName())
                   where c.AddressFamily == AddressFamily.InterNetwork
                   select c.ToString()).FirstOrDefault <string>();
     }
     catch (Exception exception)
     {
         Log.Log(LogLevelEnum.Fatal, "Failed to get host IP.", exception);
     }
 }