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;
022
023import org.apache.yetus.audience.InterfaceAudience;
024import org.apache.hadoop.hbase.errorhandling.ForeignException;
025
026/**
027 * This is the notification interface for Procedures that encapsulates message passing from
028 * members to a coordinator.  Each of these calls should send a message to the coordinator.
029 */
030@InterfaceAudience.Private
031public interface ProcedureMemberRpcs extends Closeable {
032
033  /**
034   * Initialize and start any threads or connections the member needs.
035   */
036  void start(final String memberName, final ProcedureMember member);
037
038  /**
039   * Each subprocedure is being executed on a member.  This is the identifier for the member.
040   * @return the member name
041   */
042  String getMemberName();
043
044  /**
045   * Notify the coordinator that we aborted the specified {@link Subprocedure}
046   *
047   * @param sub the {@link Subprocedure} we are aborting
048   * @param cause the reason why the member's subprocedure aborted
049   * @throws IOException thrown when the rpcs can't reach the other members of the procedure (and
050   *  thus can't recover).
051   */
052  void sendMemberAborted(Subprocedure sub, ForeignException cause) throws IOException;
053
054  /**
055   * Notify the coordinator that the specified {@link Subprocedure} has acquired the locally required
056   * barrier condition.
057   *
058   * @param sub the specified {@link Subprocedure}
059   * @throws IOException if we can't reach the coordinator
060   */
061  void sendMemberAcquired(Subprocedure sub) throws IOException;
062
063  /**
064   * Notify the coordinator that the specified {@link Subprocedure} has completed the work that
065   * needed to be done under the global barrier.
066   *
067   * @param sub the specified {@link Subprocedure}
068   * @param data the data the member returns to the coordinator along with the notification
069   * @throws IOException if we can't reach the coordinator
070   */
071  void sendMemberCompleted(Subprocedure sub, byte[] data) throws IOException;
072}