View Javadoc

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.master;
20  
21  import org.apache.giraph.aggregators.Aggregator;
22  import org.apache.giraph.aggregators.AggregatorUsage;
23  import org.apache.hadoop.io.Writable;
24  
25  /**
26   * Master compute can access and change aggregators through this interface
27   */
28  public interface MasterAggregatorUsage extends AggregatorUsage {
29    /**
30     * Register an aggregator in preSuperstep() and/or preApplication(). This
31     * aggregator will have its value reset at the end of each super step.
32     *
33     * @param name of aggregator
34     * @param aggregatorClass Class type of the aggregator
35     * @param <A> Aggregator type
36     * @return True iff aggregator wasn't already registered
37     */
38    <A extends Writable> boolean registerAggregator(String name,
39        Class<? extends Aggregator<A>> aggregatorClass) throws
40        InstantiationException, IllegalAccessException;
41  
42    /**
43     * Register persistent aggregator in preSuperstep() and/or
44     * preApplication(). This aggregator will not reset value at the end of
45     * super step.
46     *
47     * @param name of aggregator
48     * @param aggregatorClass Class type of the aggregator
49     * @param <A> Aggregator type
50     * @return True iff aggregator wasn't already registered
51     */
52    <A extends Writable> boolean registerPersistentAggregator(String name,
53        Class<? extends Aggregator<A>> aggregatorClass) throws
54        InstantiationException, IllegalAccessException;
55  
56    /**
57     * Sets value of an aggregator.
58     *
59     * @param name Name of aggregator
60     * @param value Value to set
61     * @param <A> Aggregated value
62     */
63    <A extends Writable> void setAggregatedValue(String name, A value);
64  }