Terminate this Coordination normally.
If this Coordination has been {@link #push() pushed} on the thread localCoordination stack of another thread, this method does nothing except throw a CoordinationException of type {@link CoordinationException#WRONG_THREAD}.
If this Coordination has been {@link #push() pushed} on the thread localCoordination stack of this thread but is not the {@link Coordinator#peek() current Coordination}, then the Coordinations on the thread local Coordination stack above this Coordination must be terminated and removed from the thread local Coordination stack before this Coordination is terminated. Each of these Coordinations, starting with the current Coordination, will be {@link #end() terminated normally}. If the termination throws a {@link CoordinationException}, then the next Coordination on the thread local Coordination stack will be {@link #fail(Throwable) terminated as a failure} with a failure cause ofthe thrown CoordinationException. At the end of this process, this Coordination will be the current Coordination and will have been terminated as a failure if any of the terminated Coordinations threw a CoordinationException
If this Coordination is the {@link Coordinator#peek() currentCoordination}, then it will be {@link Coordinator#pop() removed} from thethread local Coordination stack.
If this Coordination is already terminated, a CoordinationException is thrown. If this Coordination was terminated as a failure, the {@link #getFailure() failure cause} will be the cause of the thrownCoordinationException.
Otherwise, this Coordination is terminated normally and then all registered {@link #getParticipants() Participants} are{@link Participant#ended(Coordination) notified}. Participants should finalize any work associated with this Coordination. The successful return of this method indicates that the Coordination has terminated normally and all registered Participants have been notified of the normal termination.
It is possible that one of the Participants throws an exception during notification. If this happens, this Coordination is considered to have partially failed and this method must throw a CoordinationException of type {@link CoordinationException#PARTIALLY_ENDED} after all theregistered Participants have been notified.
@throws CoordinationException If this Coordination has failed, includingtimed out, or partially failed or this Coordination is on the thread local Coordination stack of another thread.
@throws SecurityException If the caller does not have{@code CoordinationPermission[INITIATE]} for this Coordination.