View Javadoc

1   /**
2    *
3    * Licensed to the Apache Software Foundation (ASF) under one
4    * or more contributor license agreements.  See the NOTICE file
5    * distributed with this work for additional information
6    * regarding copyright ownership.  The ASF licenses this file
7    * to you under the Apache License, Version 2.0 (the
8    * "License"); you may not use this file except in compliance
9    * with the License.  You may obtain a copy of the License at
10   *
11   *     http://www.apache.org/licenses/LICENSE-2.0
12   *
13   * Unless required by applicable law or agreed to in writing, software
14   * distributed under the License is distributed on an "AS IS" BASIS,
15   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   * See the License for the specific language governing permissions and
17   * limitations under the License.
18   */
19  package org.apache.hadoop.hbase.ipc;
20  
21  import java.io.IOException;
22  
23  import org.apache.hadoop.classification.InterfaceAudience;
24  
25  /**
26   * A call whose response can be delayed by the server.
27   */
28  @InterfaceAudience.Private
29  public interface Delayable {
30    /**
31     * Signal that the call response should be delayed, thus freeing the RPC
32     * server to handle different requests.
33     *
34     * @param delayReturnValue Controls whether the return value of the call
35     * should be set when ending the delay or right away.  There are cases when
36     * the return value can be set right away, even if the call is delayed.
37     */
38    void startDelay(boolean delayReturnValue);
39  
40    /**
41     * @return is the call delayed?
42     */
43    boolean isDelayed();
44  
45    /**
46     * @return is the return value delayed?
47     */
48    boolean isReturnValueDelayed();
49  
50    /**
51     * Signal that the  RPC server is now allowed to send the response.
52     * @param result The value to return to the caller.  If the corresponding
53     * delay response specified that the return value should
54     * not be delayed, this parameter must be null.
55     * @throws IOException
56     */
57    void endDelay(Object result) throws IOException;
58  
59    /**
60     * Signal the end of a delayed RPC, without specifying the return value.  Use
61     * this only if the return value was not delayed
62     * @throws IOException
63     */
64    void endDelay() throws IOException;
65  
66    /**
67     * End the call, throwing and exception to the caller.  This works regardless
68     * of the return value being delayed.
69     * @param t Object to throw to the client.
70     * @throws IOException
71     */
72    void endDelayThrowing(Throwable t) throws IOException;
73  }