Exemple #1
0
        /// <summary>Initiate a graceful failover by talking to the target node's ZKFC.</summary>
        /// <remarks>
        /// Initiate a graceful failover by talking to the target node's ZKFC.
        /// This sends an RPC to the ZKFC, which coordinates the failover.
        /// </remarks>
        /// <param name="toNode">the node to fail to</param>
        /// <returns>status code (0 for success)</returns>
        /// <exception cref="System.IO.IOException">if failover does not succeed</exception>
        private int GracefulFailoverThroughZKFCs(HAServiceTarget toNode)
        {
            int          timeout = FailoverController.GetRpcTimeoutToNewActive(GetConf());
            ZKFCProtocol proxy   = toNode.GetZKFCProxy(GetConf(), timeout);

            try
            {
                proxy.GracefulFailover();
                @out.WriteLine("Failover to " + toNode + " successful");
            }
            catch (ServiceFailedException sfe)
            {
                errOut.WriteLine("Failover failed: " + sfe.GetLocalizedMessage());
                return(-1);
            }
            return(0);
        }
Exemple #2
0
 /// <exception cref="Org.Apache.Hadoop.HA.ServiceFailedException"/>
 private void BecomeActive()
 {
     lock (this)
     {
         Log.Info("Trying to make " + localTarget + " active...");
         try
         {
             HAServiceProtocolHelper.TransitionToActive(localTarget.GetProxy(conf, FailoverController
                                                                             .GetRpcTimeoutToNewActive(conf)), CreateReqInfo());
             string msg = "Successfully transitioned " + localTarget + " to active state";
             Log.Info(msg);
             serviceState = HAServiceProtocol.HAServiceState.Active;
             RecordActiveAttempt(new ZKFailoverController.ActiveAttemptRecord(true, msg));
         }
         catch (Exception t)
         {
             string msg = "Couldn't make " + localTarget + " active";
             Log.Fatal(msg, t);
             RecordActiveAttempt(new ZKFailoverController.ActiveAttemptRecord(false, msg + "\n"
                                                                              + StringUtils.StringifyException(t)));
             if (t is ServiceFailedException)
             {
                 throw (ServiceFailedException)t;
             }
             else
             {
                 throw new ServiceFailedException("Couldn't transition to active", t);
             }
         }
     }
 }