1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
package org.apache.giraph.factories; |
19 | |
|
20 | |
import org.apache.giraph.conf.GiraphConfiguration; |
21 | |
import org.apache.giraph.conf.GiraphConstants; |
22 | |
import org.apache.giraph.conf.ImmutableClassesGiraphConfiguration; |
23 | |
import org.apache.giraph.graph.Computation; |
24 | |
import org.apache.giraph.utils.ReflectionUtils; |
25 | |
import org.apache.hadoop.io.Writable; |
26 | |
import org.apache.hadoop.io.WritableComparable; |
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | 0 | public class DefaultComputationFactory<I extends WritableComparable, |
36 | |
V extends Writable, E extends Writable> |
37 | |
implements ComputationFactory<I, V, E, Writable, Writable> { |
38 | |
@Override |
39 | |
public void initialize(ImmutableClassesGiraphConfiguration<I, V, E> conf) { |
40 | |
|
41 | 0 | } |
42 | |
|
43 | |
@Override |
44 | |
public Computation<I, V, E, Writable, Writable> createComputation( |
45 | |
ImmutableClassesGiraphConfiguration<I, V, E> conf) { |
46 | 0 | Class<? extends Computation> klass = conf.getComputationClass(); |
47 | 0 | return ReflectionUtils.newInstance(klass, conf); |
48 | |
} |
49 | |
|
50 | |
@Override |
51 | |
public void checkConfiguration( |
52 | |
ImmutableClassesGiraphConfiguration<I, V, E> conf) { |
53 | 0 | if (conf.getComputationClass() == null) { |
54 | 0 | throw new IllegalArgumentException("checkConfiguration: Null " + |
55 | 0 | GiraphConstants.COMPUTATION_CLASS.getKey()); |
56 | |
} |
57 | 0 | } |
58 | |
|
59 | |
@Override |
60 | |
public String computationName(GiraphConfiguration conf) { |
61 | 0 | return conf.getComputationClass().getSimpleName(); |
62 | |
} |
63 | |
} |