Esempio n. 1
0
        /// <summary>
        ///     Processes the record.
        /// </summary>
        protected override void ProcessRecord()
        {
            if (Force || ShouldContinue(
                    "Are you sure you want to reset this RabbitMq node? Removes the node from any cluster it belongs to, removes all data from the management database, such as configured users and vhosts, and deletes all persistent messages.",
                    "Confirm"))
            {
                WriteVerbose("Reset request confirmed");
            }
            else
            {
                WriteVerbose("Reset aborted");
                return;
            }

            WriteVerbose($"Resetting {Environment.MachineName}");

            var client = new RabbitMqBatCtlClient();

            WriteVerbose("Stopping RabbitMq application");
            client.SoftStop();

            try
            {
                WriteVerbose($"Resetting");
                client.Reset();
            }
            finally
            {
                WriteVerbose("Starting RabbitMq application");
                client.SoftStart();
            }
        }
        /// <summary>
        ///     Processes the record.
        /// </summary>
        protected override void ProcessRecord()
        {
            var client = new RabbitMqBatCtlClient();

            WriteVerbose("Stopping RabbitMq");

            if (StopErlangNode)
            {
                WriteVerbose("Stopping RabbitMq and Erlang node");
                client.HardStop();
            }
            else
            {
                WriteVerbose("Stopping RabbitMq but leaving Erlang node running");
                client.SoftStop();
            }
        }
Esempio n. 3
0
        /// <summary>
        ///     Processes the record.
        /// </summary>
        protected override void ProcessRecord()
        {
            int[] allPorts  = { 4369, 25672, 44002 };
            int[] livePorts = { 44002 };

            if (FirewallConfigured || ShouldContinue(
                    $"Do you have private/domain firewall ports {string.Join(", ", allPorts)} open on this and the other RabbitMq node?",
                    "Firewall"))
            {
                WriteVerbose("Firewall/network access marked as configured");
            }
            else
            {
                throw new ApplicationException("Network access not configured");
            }

            using (var tcpClient = new TcpClient())
            {
                livePorts.ToList().ForEach(p =>
                {
                    try
                    {
                        WriteVerbose($"Validating connection to {StrictHostname} on port {p}");

                        tcpClient.Connect(StrictHostname, p);

                        tcpClient.Close();
                    }
                    catch (Exception ex)
                    {
                        throw new Exception($"Failed to connect to {StrictHostname} on port {p}", ex);
                    }
                });
            }

            if (CookieSet || ShouldContinue(
                    "Have you set the Erlang cookie to match the one on the node your are joining? See Set-ErlangCookieFileCommand for details",
                    "Cluster cookie"))
            {
                WriteVerbose("Erlang cookie set the same between this and target node");
            }
            else
            {
                throw new ApplicationException("Erlang cookie not set for cluster");
            }

            WriteVerbose($"Clustering {Environment.MachineName} to {StrictHostname}");

            var client = new RabbitMqBatCtlClient();

            WriteVerbose("Stopping RabbitMq application");
            client.SoftStop();

            try
            {
                WriteVerbose($"Joining {StrictHostname}");
                client.JoinCluster(StrictHostname);
            }
            finally
            {
                WriteVerbose("Starting RabbitMq application");
                client.SoftStart();
            }
        }