/// <summary>Move from the existing state to a new state</summary> /// <param name="context">HA context</param> /// <param name="s">new state</param> /// <exception cref="Org.Apache.Hadoop.HA.ServiceFailedException">on failure to transition to new state. /// </exception> public virtual void SetState(HAContext context, Org.Apache.Hadoop.Hdfs.Server.Namenode.HA.HAState s) { if (this == s) { // Aleady in the new state return; } throw new ServiceFailedException("Transtion from state " + this + " to " + s + " is not allowed." ); }
/// <summary>Internal method to transition the state of a given namenode to a new state. /// </summary> /// <param name="nn">Namenode</param> /// <param name="s">new state</param> /// <exception cref="Org.Apache.Hadoop.HA.ServiceFailedException">on failure to transition to new state. /// </exception> protected internal void SetStateInternal(HAContext context, Org.Apache.Hadoop.Hdfs.Server.Namenode.HA.HAState s) { PrepareToExitState(context); s.PrepareToEnterState(context); context.WriteLock(); try { ExitState(context); context.SetState(s); s.EnterState(context); s.UpdateLastHATransitionTime(); } finally { context.WriteUnlock(); } }