Example #1
0
        /// <summary>
        /// Bring broker online
        /// </summary>
        internal void Online()
        {
            // Check if management command should be redirected to another HpcBroker on the same node (needed
            // for failover BN)
            if (!ShouldRedirectManagementCommand())
            {
                if (!this.IsOnline)
                {
                    this.brokerManager.Close();
                    // Force the broker mananger to intialize when the service is online
                    this.brokerManager = new BrokerManager(true, this.context);
                }

                // If not handle command in this instance
                // Allow new sessions
                this.AllowNewSession = true;

                // Cleanup up previous timer. Need lock in case user cancels offline timer callback is in progress
                lock (this.instanceLock)
                {
                    if (this.CheckOfflineState != null)
                    {
                        this.CheckOfflineState.Dispose();
                        this.CheckOfflineState = null;
                    }
                }
            }
            else
            {
                // If command should be redirected, redirect online synchronously
                RedirectManagementCommand(delegate(BrokerManagementClient client) { client.Online(); });
            }

            this.isOnline = true;
        }
Example #2
0
        public BrokerLauncher(bool managementOperationsOnly, ITelepathyContext context)
        {
            this.context = context;

            // Initializes the job object
            this.job = new JobObject();

            // Assign broker launcher process to the job object
            this.job.Assign(Process.GetCurrentProcess());

            // If this instance of HpcBroker service should handle mgmt and app operations
            if (!managementOperationsOnly)
            {
                // Force the broker mananger to intialize when the service is online
                this.brokerManager = new BrokerManager(this.IsOnline, context);
            }
        }
Example #3
0
        /// <summary>
        /// Dispose the broker launcher
        /// </summary>
        /// <param name="disposing">indicating whether it's disposing</param>
        private void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (this.brokerManager != null)
                {
                    // BrokerManager.Dispose() will not throw exceptions
                    this.brokerManager.Close();
                    this.brokerManager = null;
                }

                if (this.CheckOfflineState != null)
                {
                    this.CheckOfflineState.Dispose();
                    this.CheckOfflineState = null;
                }
            }
        }
Example #4
0
        /// <summary>
        /// Timer callback for local graceful offline check
        /// </summary>
        /// <param name="finishEvent"></param>
        private void CheckOfflineStateCallback(object finishEvent)
        {
            lock (this.instanceLock)
            {
                if (this.CheckOfflineState != null)
                {
                    bool isOffline = false;

                    if (!ShouldRedirectManagementCommand())
                    {
                        isOffline = this.brokerManager.BrokerCount == 0;

                        if (isOffline)
                        {
                            this.brokerManager.Close();
                            this.brokerManager = new BrokerManager(false, this.context);
                        }
                    }
                    else
                    {
                        if (!RedirectManagementCommand(delegate(BrokerManagementClient client) { isOffline = client.IsOffline(); }))
                        {
                            // If connection to another local HpcBroker instance failed, assume its offline on this node
                            isOffline = true;
                        }
                    }

                    if (isOffline)
                    {
                        // Close timer once all brokers ended
                        this.CheckOfflineState.Dispose();
                        this.CheckOfflineState = null;

                        // Signal that offline complete
                        this.isOnline = false;

                        ((AutoResetEvent)finishEvent).Set();
                    }
                }
            }
        }