public void Start()
        {
            if (lifecycle.Status != ServiceHostStatus.None)
            {
                throw new InvalidOperationException("invalid current status.");
            }
            if (Interlocked.CompareExchange(ref isInRunning, ActiveSentinel, NoneSentinel) != NoneSentinel)
            {
                throw new InvalidOperationException("activated");
            }

            try
            {
                lifecycle.NotifyObserver(Lifecycles.State.ServiceHost.Starting);
            }
            catch
            {
                Interlocked.Exchange(ref isInRunning, NoneSentinel);
                throw;
            }
        }
Beispiel #2
0
        private void MembershipCheckingUpdate()
        {
            try
            {
                if (!clusterMembershipService.Alive(membershipEntry))
                {
                    var membershipTable    = CreateMembershipTable();
                    var membershipSnapshot = clusterMembershipService.Register(membershipTable);
                    membershipManager.UpdateFromSnapshot(membershipSnapshot);
                    if (hostingLifecycle.Status <= ServiceHostStatus.Joining)
                    {
                        hostingLifecycle.NotifyObserver(Lifecycles.State.ServiceHost.Started);
                    }

                    isAlived = true;
                }
            }
            catch (Exception ex)
            {
                isAlived = false;
                //applicationLifecycle.NotifyObserver(ApplicationLifecycle.Starting);
                logger.Warn("{0}.{1} error:{2}", nameof(GatewayMembershipService), nameof(MembershipCheckingUpdate), ex);
            }
        }