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.classification.InterfaceAudience;
25  import org.apache.hadoop.classification.InterfaceStability;
26  import org.apache.hadoop.hbase.errorhandling.ForeignException;
27  
28  /**
29   * RPCs for the coordinator to run a barriered procedure with subprocedures executed at
30   * distributed members.
31   * @see ProcedureCoordinator
32   */
33  @InterfaceAudience.Public
34  @InterfaceStability.Evolving
35  public interface ProcedureCoordinatorRpcs extends Closeable {
36  
37    /**
38     * Initialize and start threads necessary to connect an implementation's rpc mechanisms.
39     * @param listener
40     * @return true if succeed, false if encountered initialization errors.
41     */
42    public boolean start(final ProcedureCoordinator listener);
43  
44    /**
45     * Notify the members that the coordinator has aborted the procedure and that it should release
46     * barrier resources.
47     *
48     * @param procName name of the procedure that was aborted
49     * @param cause the reason why the procedure needs to be aborted
50     * @throws IOException if the rpcs can't reach the other members of the procedure (and can't
51     *           recover).
52     */
53    public void sendAbortToMembers(Procedure procName, ForeignException cause) throws IOException;
54  
55    /**
56     * Notify the members to acquire barrier for the procedure
57     *
58     * @param procName name of the procedure to start
59     * @param info information that should be passed to all members
60     * @param members names of the members requested to reach the acquired phase
61     * @throws IllegalArgumentException if the procedure was already marked as failed
62     * @throws IOException if we can't reach the remote notification mechanism
63     */
64    public void sendGlobalBarrierAcquire(Procedure procName, byte[] info, List<String> members)
65        throws IOException, IllegalArgumentException;
66  
67    /**
68     * Notify members that all members have acquired their parts of the barrier and that they can
69     * now execute under the global barrier.
70     *
71     * Must come after calling {@link #sendGlobalBarrierAcquire(Procedure, byte[], List)}
72     *
73     * @param procName name of the procedure to start
74     * @param members members to tell we have reached in-barrier phase
75     * @throws IOException if we can't reach the remote notification mechanism
76     */
77    public void sendGlobalBarrierReached(Procedure procName, List<String> members) throws IOException;
78  
79    /**
80     * Notify Members to reset the distributed state for procedure
81     * @param procName name of the procedure to reset
82     * @throws IOException if the remote notification mechanism cannot be reached
83     */
84    public void resetMembers(Procedure procName) throws IOException;
85  }