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 
23 import org.apache.hadoop.hbase.classification.InterfaceAudience;
24 import org.apache.hadoop.hbase.errorhandling.ForeignException;
25 
26 /**
27  * This is the notification interface for Procedures that encapsulates message passing from
28  * members to a coordinator.  Each of these calls should send a message to the coordinator.
29  */
30 @InterfaceAudience.Private
31 public interface ProcedureMemberRpcs extends Closeable {
32 
33   /**
34    * Initialize and start any threads or connections the member needs.
35    */
start(final String memberName, final ProcedureMember member)36   void start(final String memberName, final ProcedureMember member);
37 
38   /**
39    * Each subprocedure is being executed on a member.  This is the identifier for the member.
40    * @return the member name
41    */
getMemberName()42   String getMemberName();
43 
44   /**
45    * Notify the coordinator that we aborted the specified {@link Subprocedure}
46    *
47    * @param sub the {@link Subprocedure} we are aborting
48    * @param cause the reason why the member's subprocedure aborted
49    * @throws IOException thrown when the rpcs can't reach the other members of the procedure (and
50    *  thus can't recover).
51    */
sendMemberAborted(Subprocedure sub, ForeignException cause)52   void sendMemberAborted(Subprocedure sub, ForeignException cause) throws IOException;
53 
54   /**
55    * Notify the coordinator that the specified {@link Subprocedure} has acquired the locally required
56    * barrier condition.
57    *
58    * @param sub the specified {@link Subprocedure}
59    * @throws IOException if we can't reach the coordinator
60    */
sendMemberAcquired(Subprocedure sub)61   void sendMemberAcquired(Subprocedure sub) throws IOException;
62 
63   /**
64    * Notify the coordinator that the specified {@link Subprocedure} has completed the work that
65    * needed to be done under the global barrier.
66    *
67    * @param sub the specified {@link Subprocedure}
68    * @param data the data the member returns to the coordinator along with the notification
69    * @throws IOException if we can't reach the coordinator
70    */
sendMemberCompleted(Subprocedure sub, byte[] data)71   void sendMemberCompleted(Subprocedure sub, byte[] data) throws IOException;
72 }
73