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