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 | |
---|
19 | package org.apache.hadoop.mapred.pipes; |
---|
20 | |
---|
21 | import java.io.IOException; |
---|
22 | import org.apache.hadoop.io.Writable; |
---|
23 | import org.apache.hadoop.io.WritableComparable; |
---|
24 | |
---|
25 | /** |
---|
26 | * The interface for the messages that can come up from the child. All of these |
---|
27 | * calls are asynchronous and return before the message has been processed. |
---|
28 | */ |
---|
29 | interface UpwardProtocol<K extends WritableComparable, V extends Writable> { |
---|
30 | /** |
---|
31 | * Output a record from the child. |
---|
32 | * @param key the record's key |
---|
33 | * @param value the record's value |
---|
34 | * @throws IOException |
---|
35 | */ |
---|
36 | void output(K key, V value) throws IOException; |
---|
37 | |
---|
38 | /** |
---|
39 | * Map functions where the application has defined a partition function |
---|
40 | * output records along with their partition. |
---|
41 | * @param reduce the reduce to send this record to |
---|
42 | * @param key the record's key |
---|
43 | * @param value the record's value |
---|
44 | * @throws IOException |
---|
45 | */ |
---|
46 | void partitionedOutput(int reduce, K key, |
---|
47 | V value) throws IOException; |
---|
48 | |
---|
49 | /** |
---|
50 | * Update the task's status message |
---|
51 | * @param msg the string to display to the user |
---|
52 | * @throws IOException |
---|
53 | */ |
---|
54 | void status(String msg) throws IOException; |
---|
55 | |
---|
56 | /** |
---|
57 | * Report making progress (and the current progress) |
---|
58 | * @param progress the current progress (0.0 to 1.0) |
---|
59 | * @throws IOException |
---|
60 | */ |
---|
61 | void progress(float progress) throws IOException; |
---|
62 | |
---|
63 | /** |
---|
64 | * Report that the application has finished processing all inputs |
---|
65 | * successfully. |
---|
66 | * @throws IOException |
---|
67 | */ |
---|
68 | void done() throws IOException; |
---|
69 | |
---|
70 | /** |
---|
71 | * Report that the application or more likely communication failed. |
---|
72 | * @param e |
---|
73 | */ |
---|
74 | void failed(Throwable e); |
---|
75 | |
---|
76 | /** |
---|
77 | * Register a counter with the given id and group/name. |
---|
78 | * @param group counter group |
---|
79 | * @param name counter name |
---|
80 | * @throws IOException |
---|
81 | */ |
---|
82 | void registerCounter(int id, String group, String name) throws IOException; |
---|
83 | |
---|
84 | /** |
---|
85 | * Increment the value of a registered counter. |
---|
86 | * @param id counter id of the registered counter |
---|
87 | * @param amount increment for the counter value |
---|
88 | * @throws IOException |
---|
89 | */ |
---|
90 | void incrementCounter(int id, long amount) throws IOException; |
---|
91 | } |
---|