Ejemplo n.º 1
0
        private void GetServerTime(object state)
        {
            Host host = state as Host;

            if (host?.Connection?.Session == null)
            {
                log.Error("Will not fetch server time: host or connection could not be resolved");
                return;
            }

            try
            {
                //Note we're using the get_servertime call which returns the UTC time
                var serverTime = Host.get_servertime(host.Connection.Session, host.opaque_ref);

                if (LicensedHost != null)
                {
                    //ServerTime is UTC
                    DateTime currentRefTime = serverTime;
                    LicenseExpiresExactlyIn = LicensedHost.LicenseExpiryUTC().Subtract(currentRefTime);

                    CurrentState = CalculateCurrentState();
                    Updated      = true;

                    TriggerStatusUpdatedEvent();
                }
            }
            catch (Exception e)
            {
                log.Error($"Failed to fetch server time for host {host.name_label}: ", e);
            }
        }
Ejemplo n.º 2
0
        private void SetMinimumLicenseValueHost(Pool pool)
        {
            LicensedHost = pool.Connection.Resolve(pool.master);

            if (LicensedHost == null)
            {
                return;
            }

            foreach (Host host in pool.Connection.Cache.Hosts)
            {
                if (host.LicenseExpiryUTC() < LicensedHost.LicenseExpiryUTC())
                {
                    LicensedHost = host;
                }
            }
        }