The Runner framework provides a unified command-line interface for executing graph algorithms with configurable inputs and outputs. It serves as the main entry point for the flink-gelly-examples library and coordinates algorithm execution through a consistent parameter-driven approach.
The primary entry point for command-line execution of graph algorithms.
/**
* Main class that executes Flink graph processing drivers
* Coordinates input sources, algorithms, and output formatters
*/
public class Runner {
/**
* Command-line entry point for executing graph algorithms
* @param args Command-line arguments specifying algorithm, input, and output
* @throws Exception if execution fails or parameters are invalid
*/
public static void main(String[] args) throws Exception;
}Usage Pattern:
flink run flink-gelly-examples_2.10-1.3.3.jar \
--algorithm <algorithm_name> [algorithm_options] \
--input <input_name> [input_options] \
--output <output_name> [output_options]Available Commands:
flink run flink-gelly-examples_2.10-1.3.3.jar (no parameters)flink run flink-gelly-examples_2.10-1.3.3.jar --algorithm <name>The Runner maintains registries of available algorithms and input sources through parameterized factories.
/**
* Factory for creating parameterized instances by name
* Provides iteration over available implementations
*/
private static class ParameterizedFactory<T extends Parameterized>
implements Iterable<T> {
/**
* Add a class to the factory registry
* @param cls Class extending T to register
* @return this factory for method chaining
*/
public ParameterizedFactory<T> addClass(Class<? extends T> cls);
/**
* Get an instance by name
* @param name String matching getName() of registered class
* @return Instance of the named class or null if not found
*/
public T get(String name);
}The Runner framework supports the following graph algorithms:
Usage Examples:
# Run PageRank with damping factor 0.9 and 20 iterations
flink run flink-gelly-examples_2.10-1.3.3.jar \
--algorithm PageRank \
--dampingFactor 0.9 \
--iterationConvergence "20;0.001" \
--input CompleteGraph --vertex_count 1000 \
--output print
# Run Connected Components on CSV data
flink run flink-gelly-examples_2.10-1.3.3.jar \
--algorithm ConnectedComponents \
--input CSV --input_filename edges.csv --type long \
--output csv --output_filename components.csvThe Runner framework supports various graph input sources:
Usage Examples:
# Use R-MAT generator with 2^12 vertices and edge factor 8
--input RMatGraph --scale 12 --edge_factor 8 --seed 12345
# Use CSV input with string keys and custom delimiters
--input CSV --input_filename graph.txt --type string \
--input_field_delimiter ";" --comment_prefix "//"
# Use 3D grid graph with wrapped endpoints
--input GridGraph --dim0 "10:true" --dim1 "10:false" --dim2 "5:true"The Runner framework supports multiple output formats depending on algorithm capabilities:
Output Examples:
# CSV output with custom delimiters
--output csv --output_filename results.csv \
--output_line_delimiter "\n" --output_field_delimiter ","
# Console output
--output print
# Hash verification
--output hashThe Runner provides comprehensive error handling and usage help:
/**
* List available algorithms with descriptions
* @return Formatted string listing all registered algorithms
*/
private static String getAlgorithmsListing();
/**
* Display usage for a specific algorithm including compatible inputs and outputs
* @param algorithmName Name of the algorithm to show usage for
* @return Formatted usage string with all options
*/
private static String getAlgorithmUsage(String algorithmName);Error Conditions:
ProgramParametrizationExceptionProgramParametrizationExceptionProgramParametrizationExceptionProgramParametrizationExceptionHelp Usage:
# List all available algorithms
flink run flink-gelly-examples_2.10-1.3.3.jar
# Show help for specific algorithm
flink run flink-gelly-examples_2.10-1.3.3.jar --algorithm PageRank
# Invalid parameters show usage automatically
flink run flink-gelly-examples_2.10-1.3.3.jar --algorithm InvalidAlgorithm// Core execution interfaces
interface Driver<K, VV, EV> extends Parameterized {
String getShortDescription();
String getLongDescription();
void plan(Graph<K, VV, EV> graph) throws Exception;
}
interface Input<K, VV, EV> extends Parameterized {
String getIdentity();
Graph<K, VV, EV> create(ExecutionEnvironment env) throws Exception;
}
// Output format interfaces
interface CSV {
void writeCSV(String filename, String lineDelimiter, String fieldDelimiter) throws Exception;
}
interface Print {
void print(String executionName) throws Exception;
}
interface Hash {
void hash(String executionName) throws Exception;
}
// Parameter parsing and validation
class ParameterTool {
public static ParameterTool fromArgs(String[] args);
public String get(String key);
public String getRequired(String key) throws RuntimeException;
public boolean has(String key);
}
class ProgramParametrizationException extends Exception {
public ProgramParametrizationException(String message);
}