This project has retired. For details please refer to its Attic page.
Source code
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.io.network.group.api.operators;
020
021import org.apache.reef.exception.evaluator.NetworkException;
022import org.apache.reef.io.network.group.impl.operators.GatherReceiver;
023import org.apache.reef.io.network.group.impl.operators.GatherSender;
024import org.apache.reef.tang.annotations.DefaultImplementation;
025import org.apache.reef.wake.Identifier;
026
027import java.util.List;
028
029/**
030 * MPI Gather Operator.
031 * <p>
032 * This is an operator where the root is a receiver and there are multiple senders.
033 * The root or receiver gathers all the elements sent by the senders in a List.
034 */
035public interface Gather {
036
037  /**
038   * Senders or non-roots.
039   */
040  @DefaultImplementation(GatherSender.class)
041  interface Sender<T> extends GroupCommOperator {
042
043    /**
044     * Send the element to the root/receiver.
045     */
046    void send(T element) throws InterruptedException, NetworkException;
047  }
048
049  /**
050   * Receiver or Root.
051   */
052  @DefaultImplementation(GatherReceiver.class)
053  interface Receiver<T> extends GroupCommOperator {
054
055    /**
056     * Receive the elements sent by the senders in default order.
057     *
058     * @return elements sent by senders as a List in default order
059     */
060    List<T> receive() throws InterruptedException, NetworkException;
061
062    /**
063     * Receive the elements sent by the senders in specified order.
064     *
065     * @return elements sent by senders as a List in specified order
066     */
067    List<T> receive(List<? extends Identifier> order) throws InterruptedException, NetworkException;
068  }
069}