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 package org.apache.giraph.factories; 19 20 import org.apache.giraph.conf.GiraphConfiguration; 21 import org.apache.giraph.conf.ImmutableClassesGiraphConfiguration; 22 import org.apache.giraph.graph.Computation; 23 import org.apache.hadoop.io.Writable; 24 import org.apache.hadoop.io.WritableComparable; 25 26 /** 27 * Factory for creating Computations 28 * 29 * @param <I> Vertex ID 30 * @param <V> Vertex Value 31 * @param <E> Edge Value 32 * @param <M1> Incoming Message Value 33 * @param <M2> Outgoing Message Value 34 */ 35 public interface ComputationFactory<I extends WritableComparable, 36 V extends Writable, E extends Writable, M1 extends Writable, 37 M2 extends Writable> { 38 /** 39 * One time initialization before compute calls. 40 * Guaranteed to be called from only one thread before computation begins. 41 * 42 * @param conf Configuration 43 */ 44 void initialize(ImmutableClassesGiraphConfiguration<I, V, E> conf); 45 46 /** 47 * Get Computation object 48 * 49 * @param conf Configuration 50 * @return Computation 51 */ 52 Computation<I, V, E, M1, M2> createComputation( 53 ImmutableClassesGiraphConfiguration<I, V, E> conf); 54 55 /** 56 * Check that the Configuration passed in is setup correctly to run a job. 57 * 58 * @param conf Configuration to check. 59 */ 60 void checkConfiguration( 61 ImmutableClassesGiraphConfiguration<I, V, E> conf); 62 63 /** 64 * Get name of this particular computation 65 * 66 * @param conf Configuration 67 * @return String name of computation 68 */ 69 String computationName(GiraphConfiguration conf); 70 }