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.giraph.comm.aggregators;
20
21 import java.io.IOException;
22
23 import org.apache.hadoop.io.Writable;
24
25 /**
26 * Aggregates worker aggregator requests and sends them off
27 */
28 public interface WorkerAggregatorRequestProcessor {
29 /**
30 * Sends worker reduced value to the owner of reducer
31 *
32 * @param name Name of the reducer
33 * @param reducedValue Reduced partial value
34 * @throws java.io.IOException
35 * @return True if reduced value will be sent, false if this worker is
36 * the owner of the reducer
37 */
38 boolean sendReducedValue(String name,
39 Writable reducedValue) throws IOException;
40
41 /**
42 * Flush aggregated values cache.
43 *
44 * @throws IOException
45 */
46 void flush() throws IOException;
47
48 /**
49 * Sends reduced values to the master. This worker is the owner of these
50 * reducers.
51 *
52 * @param data Serialized reduced values data
53 * @throws IOException
54 */
55 void sendReducedValuesToMaster(byte[] data) throws IOException;
56
57 /**
58 * Sends reduced values to all other workers
59 *
60 * @param reducedDataList Serialized reduced values data split into chunks
61 */
62 void distributeReducedValues(
63 Iterable<byte[]> reducedDataList) throws IOException;
64 }