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.block_app.framework; 19 20 import java.util.List; 21 22 import org.apache.giraph.block_app.framework.block.Block; 23 import org.apache.giraph.conf.GiraphConfiguration; 24 import org.apache.hadoop.conf.Configuration; 25 26 /** 27 * Class describing a particular application. 28 * Everything except input and output should be fully encapsulated within 29 * this class. For any application, it should be enough to only specify 30 * particular BlockFactory. 31 * 32 * Given configuration, it creates a block that represents a full Giraph job. 33 * 34 * Recommended is to extend AbstractBlockFactory directly for most cases. 35 * 36 * @param <S> Execution stage type 37 */ 38 public interface BlockFactory<S> { 39 /** 40 * Based on provided configuration, updates it, such that all necessary 41 * properties are initialized. 42 */ 43 void initConfig(GiraphConfiguration conf); 44 45 /** 46 * Create a block (representing a full Giraph job), based on the given 47 * configuration. Configuration should be treated as immutable at this point. 48 * 49 * If there are issues in configuration, it is very cheap to throw 50 * from this method - as Giraph job will not even start. 51 * This function will be called two times - once before starting 52 * of the Giraph job, to fail early if anything is incorrectly configured. 53 * Second time will be on Master, which will return Block instance 54 * on which createIterator will be called once, which should return 55 * current application run. 56 * initConfig will be called only once, before starting Giraph job itself. 57 * Master will contain configuration already modified by initConfig. 58 */ 59 Block createBlock(GiraphConfiguration conf); 60 61 /** 62 * Create an empty instance of execution stage object. 63 * 64 * Can be used by application to be aware of what was executed before. 65 * Most common example is counting iterations, or for having a boolean whether 66 * some important event happened. 67 * 68 * Execution stage should be immutable object, with creating a new 69 * object when different value is needed. 70 */ 71 S createExecutionStage(GiraphConfiguration conf); 72 73 /** 74 * Get special GC Java options. If returns null, default options are used. 75 */ 76 List<String> getGcJavaOpts(Configuration conf); 77 78 /** 79 * Register outputs to use during the application (vs output at the end of 80 * the application), based on provided configuration. 81 */ 82 void registerOutputs(GiraphConfiguration conf); 83 }