Example #1
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 #2
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);
            }
        }