Java 类org.apache.spark.api.java.function.Function0 实例源码

项目:Apache-Spark-2x-for-Java-Developers    文件:WordCountRecoverableEx.java   
public static void main(String[] args) throws Exception {
    System.setProperty("hadoop.home.dir", "E:\\hadoop");

    final String ip = "10.0.75.1";
    final int port = Integer.parseInt("9000");
    final String checkpointDirectory = "E:\\hadoop\\checkpoint";
    // Function to create JavaStreamingContext without any output operations
    // (used to detect the new context)
    Function0<JavaStreamingContext> createContextFunc = new Function0<JavaStreamingContext>() {
        @Override
        public JavaStreamingContext call() {
            return createContext(ip, port, checkpointDirectory);
        }
    };

    JavaStreamingContext ssc = JavaStreamingContext.getOrCreate(checkpointDirectory, createContextFunc);
    ssc.start();
    ssc.awaitTermination();
}
项目:LaS-VPE-Platform    文件:RobustExecutor.java   
/**
 * Create a RobustExecutor specifying the retrying behaviour.
 * The executor retries immediately after failure,
 * and may retry up to 2 times (totally executing 3 times).
 * Note that be careful when simplifying the lambda expression for the function here,
 * you may not get the correct function type as expected, resulting in null return value.
 *
 * @param onceFunction function to be executed each time.
 */
public RobustExecutor(Function0<R> onceFunction) {
    this((Function<T, R>) ignored -> onceFunction.call());
}