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.remote.address.LocalAddressProvider; 024import org.apache.reef.wake.remote.impl.DefaultRemoteManagerFactory; 025import org.apache.reef.wake.remote.ports.TcpPortProvider; 026 027/** 028 * Injectable Factory for RemoteManager instances. 029 * <p/> 030 * Use when direct injection of the RemoteManager is impossible. 031 */ 032@DefaultImplementation(DefaultRemoteManagerFactory.class) 033public interface RemoteManagerFactory { 034 035 /** 036 * @param name the name of used by the returned RemoteManager to determine the address to bind to. to instantiate. 037 * @return a new instance of RemoteManager with all parameters but the given one injected via Tang. 038 */ 039 RemoteManager getInstance(final String name); 040 041 /** 042 * @param name the name of the returned RemoteManager to instantiate. 043 * @param codec the codec to use to decode the messages sent to / by this RemoteManager. 044 * @param errorHandler the error handler invoked for exceptions by the returned RemoteManager. 045 * @param <T> the message type sent / received by the returned RemoteManager. 046 * @return a new instance of RemoteManager with all parameters but the given one injected via Tang. 047 */ 048 <T> RemoteManager getInstance(final String name, 049 final Codec<T> codec, 050 final EventHandler<Throwable> errorHandler); 051 052 /** 053 * @param name the name of the returned RemoteManager to instantiate. 054 * @param listeningPort the port on which the returned RemoteManager listens. 055 * @param codec the codec to use to decode the messages sent to / by this RemoteManager. 056 * @param errorHandler the error handler invoked for exceptions by the returned RemoteManager. 057 * @param <T> the message type sent / received by the returned RemoteManager. 058 * @return a new instance of RemoteManager with all parameters but the given one injected via Tang. 059 */ 060 <T> RemoteManager getInstance(final String name, 061 final int listeningPort, 062 final Codec<T> codec, 063 final EventHandler<Throwable> errorHandler); 064 065 /** 066 * The old constructor of DefaultRemoteManagerImplementation. Avoid if you can. 067 * 068 * @param name the name of the returned RemoteManager to instantiate. 069 * @param hostAddress the address the returned RemoteManager binds to. 070 * @param listeningPort the port on which the returned RemoteManager listens. 071 * @param codec the codec to use to decode the messages sent to / by this RemoteManager. 072 * @param errorHandler the error handler invoked for exceptions by the returned RemoteManager. 073 * @param orderingGuarantee whether or not the returned RemoteManager should guarantee message orders. 074 * @param numberOfTries the number of retries before the returned RemoteManager declares sending a failure. 075 * @param retryTimeout the time (in ms) after which the returned RemoteManager considers a sending attempt 076 * failed. 077 * @param <T> the message type sent / received by the returned RemoteManager. 078 * @return a new instance of RemoteManager with all parameters but the given one injected via Tang. 079 */ 080 <T> RemoteManager getInstance(final String name, 081 final String hostAddress, 082 final int listeningPort, 083 final Codec<T> codec, 084 final EventHandler<Throwable> errorHandler, 085 final boolean orderingGuarantee, 086 final int numberOfTries, 087 final int retryTimeout); 088 089 /** 090 * The all-out constructor of DefaultRemoteManagerImplementation. Avoid if you can. 091 * 092 * @param name the name of the returned RemoteManager to instantiate. 093 * @param hostAddress the address the returned RemoteManager binds to. 094 * @param listeningPort the port on which the returned RemoteManager listens. 095 * @param codec the codec to use to decode the messages sent to / by this RemoteManager. 096 * @param errorHandler the error handler invoked for exceptions by the returned RemoteManager. 097 * @param orderingGuarantee whether or not the returned RemoteManager should guarantee message orders. 098 * @param numberOfTries the number of retries before the returned RemoteManager declares sending a failure. 099 * @param retryTimeout the time (in ms) after which the returned RemoteManager considers a sending attempt 100 * failed. 101 * @param localAddressProvider the LocalAddressProvider used by the returned RemoteManager to determine the address 102 * to bind to. 103 * @param tcpPortProvider the TcpPortProvider used by the returned RemoteManager to determine the port 104 * to listen to. 105 * @param <T> the message type sent / received by the returned RemoteManager. 106 * @return a new instance of RemoteManager with all parameters but the given one injected via Tang. 107 */ 108 <T> RemoteManager getInstance(final String name, 109 final String hostAddress, 110 final int listeningPort, 111 final Codec<T> codec, 112 final EventHandler<Throwable> errorHandler, 113 final boolean orderingGuarantee, 114 final int numberOfTries, 115 final int retryTimeout, 116 final LocalAddressProvider localAddressProvider, 117 final TcpPortProvider tcpPortProvider); 118 119 120}