View Javadoc

1   /**
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *     http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  package org.apache.hadoop.hbase.procedure;
19  
20  import java.io.Closeable;
21  import java.io.IOException;
22  import java.util.List;
23  
24  import org.apache.hadoop.hbase.classification.InterfaceAudience;
25  import org.apache.hadoop.hbase.errorhandling.ForeignException;
26  
27  /**
28   * RPCs for the coordinator to run a barriered procedure with subprocedures executed at
29   * distributed members.
30   * @see ProcedureCoordinator
31   */
32  @InterfaceAudience.Private
33  public interface ProcedureCoordinatorRpcs extends Closeable {
34  
35    /**
36     * Initialize and start threads necessary to connect an implementation's rpc mechanisms.
37     * @param listener
38     * @return true if succeed, false if encountered initialization errors.
39     */
40    boolean start(final ProcedureCoordinator listener);
41  
42    /**
43     * Notify the members that the coordinator has aborted the procedure and that it should release
44     * barrier resources.
45     *
46     * @param procName name of the procedure that was aborted
47     * @param cause the reason why the procedure needs to be aborted
48     * @throws IOException if the rpcs can't reach the other members of the procedure (and can't
49     *           recover).
50     */
51    void sendAbortToMembers(Procedure procName, ForeignException cause) throws IOException;
52  
53    /**
54     * Notify the members to acquire barrier for the procedure
55     *
56     * @param procName name of the procedure to start
57     * @param info information that should be passed to all members
58     * @param members names of the members requested to reach the acquired phase
59     * @throws IllegalArgumentException if the procedure was already marked as failed
60     * @throws IOException if we can't reach the remote notification mechanism
61     */
62    void sendGlobalBarrierAcquire(Procedure procName, byte[] info, List<String> members)
63        throws IOException, IllegalArgumentException;
64  
65    /**
66     * Notify members that all members have acquired their parts of the barrier and that they can
67     * now execute under the global barrier.
68     *
69     * Must come after calling {@link #sendGlobalBarrierAcquire(Procedure, byte[], List)}
70     *
71     * @param procName name of the procedure to start
72     * @param members members to tell we have reached in-barrier phase
73     * @throws IOException if we can't reach the remote notification mechanism
74     */
75    void sendGlobalBarrierReached(Procedure procName, List<String> members) throws IOException;
76  
77    /**
78     * Notify Members to reset the distributed state for procedure
79     * @param procName name of the procedure to reset
80     * @throws IOException if the remote notification mechanism cannot be reached
81     */
82    void resetMembers(Procedure procName) throws IOException;
83  }