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