001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 */ 019package org.apache.reef.vortex.api; 020 021import org.apache.reef.annotations.Unstable; 022import org.apache.reef.annotations.audience.ClientSide; 023import org.apache.reef.annotations.audience.Public; 024import org.apache.reef.io.serialization.Codec; 025 026import java.io.Serializable; 027import java.util.List; 028 029/** 030 * Typed user function for Local Aggregation. Implement your functions using this interface. 031 * TODO[REEF-504]: Clean up Serializable in Vortex. 032 * TODO[REEF-1003]: Use reflection instead of serialization when launching VortexFunction. 033 * 034 * @param <TOutput> output type of the aggregation function and the functions to-be-aggregated. 035 */ 036@Public 037@ClientSide 038@Unstable 039public interface VortexAggregateFunction<TOutput> extends Serializable { 040 041 /** 042 * Runs a custom local aggregation function on Tasklets assigned to a VortexWorker. 043 * @param taskletOutputs the list of outputs from Tasklets on a Worker. 044 * @return the aggregated output of Tasklets. 045 * @throws Exception 046 */ 047 TOutput call(final List<TOutput> taskletOutputs) throws VortexAggregateException; 048 049 /** 050 * Users must define codec for the AggregationOutput. 051 * {@link org.apache.reef.vortex.util.VoidCodec} can be used if the aggregation output is 052 * empty, and {@link org.apache.reef.io.serialization.SerializableCodec} can be used for ({@link Serializable} 053 * aggregation output. 054 * Custom aggregation output Codec can also be supplied. 055 * @return Codec used to serialize/deserialize the output. 056 */ 057 Codec<TOutput> getOutputCodec(); 058}