예제 #1
0
        /// <exception cref="System.IO.IOException"/>
        /// <exception cref="Org.Apache.Hadoop.HA.ServiceFailedException"/>
        private int GetServiceState(CommandLine cmd)
        {
            string[] argv = cmd.GetArgs();
            if (argv.Length != 1)
            {
                errOut.WriteLine("getServiceState: incorrect number of arguments");
                PrintUsage(errOut, "-getServiceState");
                return(-1);
            }
            HAServiceProtocol proto = ResolveTarget(argv[0]).GetProxy(GetConf(), rpcTimeoutForChecks
                                                                      );

            @out.WriteLine(proto.GetServiceStatus().GetState());
            return(0);
        }
예제 #2
0
        /// <summary>Checks whether other target node is active or not</summary>
        /// <param name="targetNodeToActivate"/>
        /// <returns>
        /// true if other target node is active or some other exception
        /// occurred and forceActive was set otherwise false
        /// </returns>
        /// <exception cref="System.IO.IOException"/>
        private bool IsOtherTargetNodeActive(string targetNodeToActivate, bool forceActive
                                             )
        {
            ICollection <string> targetIds = GetTargetIds(targetNodeToActivate);

            targetIds.Remove(targetNodeToActivate);
            foreach (string targetId in targetIds)
            {
                HAServiceTarget target = ResolveTarget(targetId);
                if (!CheckManualStateManagementOK(target))
                {
                    return(true);
                }
                try
                {
                    HAServiceProtocol proto = target.GetProxy(GetConf(), 5000);
                    if (proto.GetServiceStatus().GetState() == HAServiceProtocol.HAServiceState.Active)
                    {
                        errOut.WriteLine("transitionToActive: Node " + targetId + " is already active");
                        PrintUsage(errOut, "-transitionToActive");
                        return(true);
                    }
                }
                catch (Exception e)
                {
                    //If forceActive switch is false then return true
                    if (!forceActive)
                    {
                        errOut.WriteLine("Unexpected error occurred  " + e.Message);
                        PrintUsage(errOut, "-transitionToActive");
                        return(true);
                    }
                }
            }
            return(false);
        }