Example #1
0
        public bool IsLessThan(AquariusServerVersion other)
        {
            if (IsDeveloperBuild() && !other.IsDeveloperBuild())
            {
                return(false);
            }

            if (!IsDeveloperBuild() && other.IsDeveloperBuild())
            {
                return(true);
            }

            for (var i = 0; i < _versionComponents.Length; ++i)
            {
                if (i >= other._versionComponents.Length)
                {
                    return(false);
                }

                if (_versionComponents[i] < other._versionComponents[i])
                {
                    return(true);
                }

                if (_versionComponents[i] > other._versionComponents[i])
                {
                    return(false);
                }
            }

            return(_versionComponents.Length < other._versionComponents.Length);
        }
Example #2
0
        private AquariusServerVersion DetectServerVersion(string hostname)
        {
            var versionBaseUri  = Root.EndPoint + "/apps/v1";
            var versionEndpoint = UriHelper.ResolveEndpoint(hostname, versionBaseUri);

            var attemptCount = 1;

            while (true)
            {
                var stopwatch = Stopwatch.StartNew();

                try
                {
                    using (var serviceClient = ServiceClientFactory(versionEndpoint))
                    {
                        return(AquariusServerVersion.Create(serviceClient.Get(new GetVersion()).ApiVersion));
                    }
                }
                catch (Exception exception)
                {
                    var message = string.Format(
                        "Unknown server version '{0}' after {1:F3} seconds. {2}",
                        hostname,
                        stopwatch.Elapsed.TotalSeconds,
                        exception.Message);

                    var isExpectedException =
                        exception is NotSupportedException ||
                        exception is WebException ||
                        exception is WebServiceException;

                    if (isExpectedException)
                    {
                        Log.Warn(message);
                    }
                    else
                    {
                        Log.Warn(message, exception);
                    }

                    var webException = exception as WebException;
                    if (webException != null && (webException.Status == WebExceptionStatus.Timeout) && (attemptCount < MaximumRetryCount))
                    {
                        Log.InfoFormat("Version probe attempt #{0} for '{1}'", attemptCount, hostname);
                        ++attemptCount;
                        continue;
                    }

                    return(null);
                }
            }
        }
Example #3
0
        public int Compare(AquariusServerVersion other)
        {
            if (IsLessThan(other))
            {
                return(-1);
            }

            if (other.IsLessThan(this))
            {
                return(1);
            }

            return(0);
        }
Example #4
0
        public void SetOverrides(string overridesValue)
        {
            if (string.IsNullOrEmpty(overridesValue))
            {
                return;
            }

            foreach (var text in overridesValue.Split(OverrideSeparators, StringSplitOptions.RemoveEmptyEntries))
            {
                var components = text.Split('=');
                if (components.Length != 2)
                {
                    continue;
                }

                var hostname = components[0].Trim();
                var version  = components[1].Trim();

                _overrideVersions[hostname] = AquariusServerVersion.Create(version);
            }
        }
Example #5
0
        private Authenticator(string hostname)
        {
            Client = new SdkServiceClient(PublishV2.ResolveEndpoint(hostname));

            ServerVersion = AquariusSystemDetector.Instance.GetAquariusServerVersion(hostname);
        }