Example #1
0
        private static string MakeUrl(InstanceInfo info, string relativeUrl, string explicitUrl, string secureExplicitUrl = null)
        {
            if (!string.IsNullOrEmpty(explicitUrl))
            {
                return(explicitUrl);
            }
            else if (!string.IsNullOrEmpty(relativeUrl) && info.IsUnsecurePortEnabled)
            {
                return("http://" + info.HostName + ":" + info.Port + relativeUrl);
            }

            if (!string.IsNullOrEmpty(secureExplicitUrl))
            {
                return(secureExplicitUrl);
            }
            else if (info.IsSecurePortEnabled)
            {
                return("https://" + info.HostName + ":" + info.SecurePort + relativeUrl);
            }

            return(string.Empty);
        }
Example #2
0
        internal static InstanceInfo FromJsonInstance(JsonInstanceInfo json)
        {
            var info = new InstanceInfo();

            if (json != null)
            {
                info._sid                          = json.Sid ?? "na";
                info.AppName                       = json.AppName;
                info.AppGroupName                  = json.AppGroupName;
                info.IpAddr                        = json.IpAddr;
                info.Port                          = (json.Port == null) ? 0 : json.Port.Port;
                info.IsUnsecurePortEnabled         = json.Port != null && json.Port.Enabled;
                info.SecurePort                    = (json.SecurePort == null) ? 0 : json.SecurePort.Port;
                info.IsSecurePortEnabled           = json.SecurePort != null && json.SecurePort.Enabled;
                info.HomePageUrl                   = json.HomePageUrl;
                info.StatusPageUrl                 = json.StatusPageUrl;
                info.HealthCheckUrl                = json.HealthCheckUrl;
                info.SecureHealthCheckUrl          = json.SecureHealthCheckUrl;
                info.VipAddress                    = json.VipAddress;
                info.SecureVipAddress              = json.SecureVipAddress;
                info.CountryId                     = json.CountryId;
                info.DataCenterInfo                = (json.DataCenterInfo == null) ? null : AppInfo.DataCenterInfo.FromJson(json.DataCenterInfo);
                info.HostName                      = json.HostName;
                info.Status                        = json.Status;
                info.OverriddenStatus              = json.OverriddenStatus;
                info.LeaseInfo                     = LeaseInfo.FromJson(json.LeaseInfo);
                info.IsCoordinatingDiscoveryServer = json.IsCoordinatingDiscoveryServer;
                info.LastUpdatedTimestamp          = DateTimeConversions.FromJavaMillis(json.LastUpdatedTimestamp).Ticks;
                info.LastDirtyTimestamp            = DateTimeConversions.FromJavaMillis(json.LastDirtyTimestamp).Ticks;
                info.Actiontype                    = json.Actiontype;
                info.AsgName                       = json.AsgName;
                info._metaData                     = GetMetaDataFromJson(json.Metadata);
                info.InstanceId                    = GetInstanceIdFromJson(json, info._metaData);
            }

            return(info);
        }
Example #3
0
        public override bool Equals(object obj)
        {
            if (this == obj)
            {
                return(true);
            }
            if (obj == null)
            {
                return(false);
            }

            InstanceInfo other = obj as InstanceInfo;

            if (other == null)
            {
                return(false);
            }
            if (other.InstanceId.Equals(this.InstanceId))
            {
                return(true);
            }

            return(false);
        }
Example #4
0
        internal static InstanceInfo FromJsonInstance(JsonInstanceInfo json)
        {
            InstanceInfo info = new InstanceInfo();

            if (json != null)
            {
                info._sid                           = (json.Sid == null) ? "na" : json.Sid;
                info._appName                       = json.AppName;
                info._appGroupName                  = json.AppGroupName;
                info._ipAddr                        = json.IpAddr;
                info._port                          = (json.Port == null) ? 0 : json.Port.Port;
                info._isUnsecurePortEnabled         = (json.Port == null) ? false : Boolean.Parse(json.Port.Enabled);
                info._securePort                    = (json.SecurePort == null) ? 0 : json.SecurePort.Port;
                info._isSecurePortEnabled           = (json.Port == null) ? false : Boolean.Parse(json.SecurePort.Enabled);
                info._homePageUrl                   = json.HomePageUrl;
                info._statusPageUrl                 = json.StatusPageUrl;
                info._healthCheckUrl                = json.HealthCheckUrl;
                info._secureHealthCheckUrl          = json.SecureHealthCheckUrl;
                info._vipAddress                    = json.VipAddress;
                info._secureVipAddress              = json.SecureVipAddress;
                info._countryId                     = json.CountryId;
                info._dataCenterInfo                = (json.DataCenterInfo == null) ? null : AppInfo.DataCenterInfo.FromJson(json.DataCenterInfo);
                info._hostName                      = json.HostName;
                info._status                        = json.Status;
                info._overRiddenStatus              = json.OverriddenStatus;
                info._leaseInfo                     = LeaseInfo.FromJson(json.LeaseInfo);
                info._isCoordinatingDiscoveryServer = json.IsCoordinatingDiscoveryServer;
                info._lastUpdatedTimestamp          = DateTimeConversions.FromJavaMillis(json.LastUpdatedTimestamp).Ticks;
                info._lastDirtyTimestamp            = DateTimeConversions.FromJavaMillis(json.LastDirtyTimestamp).Ticks;
                info._actionType                    = json.Actiontype;
                info._asgName                       = json.AsgName;
                info._metaData                      = GetMetaDataFromJson(json.Metadata);
                info._instanceId                    = GetInstanceIdFromJson(json, info._metaData);
            }
            return(info);
        }
Example #5
0
 internal void Remove(InstanceInfo info)
 {
     _instanceMap.TryRemove(info.InstanceId, out InstanceInfo removed);
 }
Example #6
0
 internal void Add(InstanceInfo info)
 {
     _instanceMap[info.InstanceId] = info;
 }