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;
023
024import org.apache.yetus.audience.InterfaceAudience;
025import org.apache.hadoop.hbase.errorhandling.ForeignException;
026
027/**
028 * RPCs for the coordinator to run a barriered procedure with subprocedures executed at
029 * distributed members.
030 * @see ProcedureCoordinator
031 */
032@InterfaceAudience.Private
033public interface ProcedureCoordinatorRpcs extends Closeable {
034
035  /**
036   * Initialize and start threads necessary to connect an implementation's rpc mechanisms.
037   * @param listener
038   * @return true if succeed, false if encountered initialization errors.
039   */
040  boolean start(final ProcedureCoordinator listener);
041
042  /**
043   * Notify the members that the coordinator has aborted the procedure and that it should release
044   * barrier resources.
045   *
046   * @param procName name of the procedure that was aborted
047   * @param cause the reason why the procedure needs to be aborted
048   * @throws IOException if the rpcs can't reach the other members of the procedure (and can't
049   *           recover).
050   */
051  void sendAbortToMembers(Procedure procName, ForeignException cause) throws IOException;
052
053  /**
054   * Notify the members to acquire barrier for the procedure
055   *
056   * @param procName name of the procedure to start
057   * @param info information that should be passed to all members
058   * @param members names of the members requested to reach the acquired phase
059   * @throws IllegalArgumentException if the procedure was already marked as failed
060   * @throws IOException if we can't reach the remote notification mechanism
061   */
062  void sendGlobalBarrierAcquire(Procedure procName, byte[] info, List<String> members)
063      throws IOException, IllegalArgumentException;
064
065  /**
066   * Notify members that all members have acquired their parts of the barrier and that they can
067   * now execute under the global barrier.
068   *
069   * Must come after calling {@link #sendGlobalBarrierAcquire(Procedure, byte[], List)}
070   *
071   * @param procName name of the procedure to start
072   * @param members members to tell we have reached in-barrier phase
073   * @throws IOException if we can't reach the remote notification mechanism
074   */
075  void sendGlobalBarrierReached(Procedure procName, List<String> members) throws IOException;
076
077  /**
078   * Notify Members to reset the distributed state for procedure
079   * @param procName name of the procedure to reset
080   * @throws IOException if the remote notification mechanism cannot be reached
081   */
082  void resetMembers(Procedure procName) throws IOException;
083}