001/*
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements.  See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership.  The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License.  You may obtain a copy of the License at
009 *
010 *     http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018package org.apache.hadoop.hbase.procedure;
019
020import java.io.Closeable;
021import java.io.IOException;
022import java.util.List;
023import org.apache.hadoop.hbase.errorhandling.ForeignException;
024import org.apache.yetus.audience.InterfaceAudience;
025
026/**
027 * RPCs for the coordinator to run a barriered procedure with subprocedures executed at distributed
028 * members.
029 * @see ProcedureCoordinator
030 */
031@InterfaceAudience.Private
032public interface ProcedureCoordinatorRpcs extends Closeable {
033
034  /**
035   * Initialize and start threads necessary to connect an implementation's rpc mechanisms.
036   * @return true if succeed, false if encountered initialization errors.
037   */
038  boolean start(final ProcedureCoordinator listener);
039
040  /**
041   * Notify the members that the coordinator has aborted the procedure and that it should release
042   * barrier resources.
043   * @param procName name of the procedure that was aborted
044   * @param cause    the reason why the procedure needs to be aborted
045   * @throws IOException if the rpcs can't reach the other members of the procedure (and can't
046   *                     recover).
047   */
048  void sendAbortToMembers(Procedure procName, ForeignException cause) throws IOException;
049
050  /**
051   * Notify the members to acquire barrier for the procedure
052   * @param procName name of the procedure to start
053   * @param info     information that should be passed to all members
054   * @param members  names of the members requested to reach the acquired phase
055   * @throws IllegalArgumentException if the procedure was already marked as failed
056   * @throws IOException              if we can't reach the remote notification mechanism
057   */
058  void sendGlobalBarrierAcquire(Procedure procName, byte[] info, List<String> members)
059    throws IOException, IllegalArgumentException;
060
061  /**
062   * Notify members that all members have acquired their parts of the barrier and that they can now
063   * execute under the global barrier. Must come after calling
064   * {@link #sendGlobalBarrierAcquire(Procedure, byte[], List)}
065   * @param procName name of the procedure to start
066   * @param members  members to tell we have reached in-barrier phase
067   * @throws IOException if we can't reach the remote notification mechanism
068   */
069  void sendGlobalBarrierReached(Procedure procName, List<String> members) throws IOException;
070
071  /**
072   * Notify Members to reset the distributed state for procedure
073   * @param procName name of the procedure to reset
074   * @throws IOException if the remote notification mechanism cannot be reached
075   */
076  void resetMembers(Procedure procName) throws IOException;
077}