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