Example #1
0
        internal static InstanceInfo FromInstanceConfig(IEurekaInstanceConfig instanceConfig)
        {
            InstanceInfo info = new InstanceInfo();

            info._leaseInfo  = LeaseInfo.FromConfig(instanceConfig);
            info._instanceId = instanceConfig.InstanceId;
            if (string.IsNullOrEmpty(info.InstanceId))
            {
                info._instanceId = instanceConfig.GetHostName(false);
            }

            string defaultAddress = instanceConfig.GetHostName(false);

            if (string.IsNullOrEmpty(defaultAddress))
            {
                defaultAddress = instanceConfig.IpAddress;
            }

            info._appName               = instanceConfig.AppName.ToUpperInvariant();
            info._appGroupName          = (instanceConfig.AppGroupName != null) ? instanceConfig.AppGroupName.ToUpperInvariant() : null;
            info._dataCenterInfo        = instanceConfig.DataCenterInfo;
            info._ipAddr                = instanceConfig.IpAddress;
            info._hostName              = defaultAddress;
            info._port                  = instanceConfig.NonSecurePort;
            info._isUnsecurePortEnabled = instanceConfig.IsNonSecurePortEnabled;
            info._securePort            = instanceConfig.SecurePort;
            info._isSecurePortEnabled   = instanceConfig.SecurePortEnabled;
            info._vipAddress            = instanceConfig.VirtualHostName;
            info._secureVipAddress      = instanceConfig.SecureVirtualHostName;
            info._homePageUrl           = MakeUrl(info, instanceConfig.HomePageUrlPath, instanceConfig.HomePageUrl);
            info._statusPageUrl         = MakeUrl(info, instanceConfig.StatusPageUrlPath, instanceConfig.StatusPageUrl);
            info._asgName               = instanceConfig.ASGName;
            info._healthCheckUrl        = MakeUrl(info, instanceConfig.HealthCheckUrlPath, instanceConfig.HealthCheckUrl, instanceConfig.SecureHealthCheckUrl);

            if (!instanceConfig.IsInstanceEnabledOnInit)
            {
                info._status = InstanceStatus.STARTING;
            }

            if (!string.IsNullOrEmpty(info._instanceId))
            {
                InstanceInfo me = ApplicationInfoManager.Instance.InstanceInfo;
                if (me != null)
                {
                    if (info._instanceId.Equals(me.InstanceId))
                    {
                        info._isCoordinatingDiscoveryServer = true;
                    }
                }
            }

            if (instanceConfig.MetadataMap != null && instanceConfig.MetadataMap.Count > 0)
            {
                info._metaData = new Dictionary <string, string>(instanceConfig.MetadataMap);
            }


            return(info);
        }
Example #2
0
        internal static LeaseInfo FromConfig(IEurekaInstanceConfig config)
        {
            LeaseInfo info = new LeaseInfo()
            {
                RenewalIntervalInSecs = config.LeaseRenewalIntervalInSeconds,
                DurationInSecs        = config.LeaseExpirationDurationInSeconds
            };

            return(info);
        }
Example #3
0
        internal static LeaseInfo FromJson(JsonLeaseInfo jinfo)
        {
            LeaseInfo info = new LeaseInfo();

            if (jinfo != null)
            {
                info.RenewalIntervalInSecs      = jinfo.RenewalIntervalInSecs;
                info.DurationInSecs             = jinfo.DurationInSecs;
                info.RegistrationTimestamp      = DateTimeConversions.FromJavaMillis(jinfo.RegistrationTimestamp).Ticks;
                info.LastRenewalTimestamp       = DateTimeConversions.FromJavaMillis(jinfo.LastRenewalTimestamp).Ticks;
                info.LastRenewalTimestampLegacy = DateTimeConversions.FromJavaMillis(jinfo.LastRenewalTimestampLegacy).Ticks;
                info.EvictionTimestamp          = DateTimeConversions.FromJavaMillis(jinfo.EvictionTimestamp).Ticks;
                info.ServiceUpTimestamp         = DateTimeConversions.FromJavaMillis(jinfo.ServiceUpTimestamp).Ticks;
            }
            return(info);
        }
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);
        }