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.wake.remote;
020
021import org.apache.reef.tang.annotations.DefaultImplementation;
022import org.apache.reef.wake.EventHandler;
023import org.apache.reef.wake.Stage;
024import org.apache.reef.wake.remote.impl.DefaultRemoteManagerImplementation;
025
026/**
027 * Represents all remote connections to and from one process to another.
028 */
029@DefaultImplementation(DefaultRemoteManagerImplementation.class)
030public interface RemoteManager extends Stage {
031
032  /**
033   * Returns an event handler that can be used to send messages of type T to the
034   * given destination.
035   *
036   * @param <T> type of message
037   * @param destinationIdentifier a destination identifier
038   * @param messageType           a message class type
039   * @return an event handler
040   */
041  <T> EventHandler<T> getHandler(final RemoteIdentifier destinationIdentifier, final Class<? extends T> messageType);
042
043  /**
044   * Registers the given EventHandler to be invoked when messages of Type T
045   * arrive from sourceIdentifier.
046   * <p>
047   * Calling this method twice overrides the initial registration.
048   *
049   * @param <T> type of event
050   * @param <U> type of message
051   * @param sourceIdentifier a source identifier
052   * @param messageType      a message class type
053   * @param theHandler       the event handler
054   * @return the subscription that can be used to unsubscribe later
055   */
056  <T, U extends T> AutoCloseable registerHandler(final RemoteIdentifier sourceIdentifier,
057                                                 final Class<U> messageType,
058                                                 final EventHandler<T> theHandler);
059
060  /**
061   * Registers the given EventHandler to be called for the given message type
062   * from any source.
063   * <p>
064   * If there is an EventHandler registered for this EventType
065   *
066   * @param <T> a type of remote message of event
067   * @param <U> a type of message
068   * @param messageType a message class type
069   * @param theHandler  the event handler
070   * @return the subscription that can be used to unsubscribe later
071   */
072  <T, U extends T> AutoCloseable registerHandler(final Class<U> messageType,
073                                                 final EventHandler<RemoteMessage<T>> theHandler);
074
075  /**
076   * Access the Identifier of this.
077   *
078   * @return the Identifier of this.
079   */
080  RemoteIdentifier getMyIdentifier();
081}