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.transport; 020 021import org.apache.reef.tang.annotations.DefaultImplementation; 022import org.apache.reef.wake.EStage; 023import org.apache.reef.wake.EventHandler; 024import org.apache.reef.wake.remote.impl.TransportEvent; 025import org.apache.reef.wake.remote.ports.TcpPortProvider; 026import org.apache.reef.wake.remote.transport.netty.MessagingTransportFactory; 027 028/** 029 * Factory that creates a transport. 030 */ 031@DefaultImplementation(MessagingTransportFactory.class) 032public interface TransportFactory { 033 034 /** 035 * Creates a transport. 036 * 037 * @param port a listening port 038 * @param clientHandler a transport client-side handler 039 * @param serverHandler a transport server-side handler 040 * @param exHandler an exception handler 041 * @return transport 042 */ 043 Transport newInstance(int port, 044 EventHandler<TransportEvent> clientHandler, 045 EventHandler<TransportEvent> serverHandler, 046 EventHandler<Exception> exHandler); 047 048 /** 049 * Creates a transport. 050 * 051 * @param hostAddress a host address 052 * @param port a listening port 053 * @param clientStage a transport client-side stage 054 * @param serverStage a transport server-side stage 055 * @param numberOfTries the number of retries for connection 056 * @param retryTimeout retry timeout 057 * @return transport 058 */ 059 Transport newInstance(final String hostAddress, int port, 060 final EStage<TransportEvent> clientStage, 061 final EStage<TransportEvent> serverStage, 062 final int numberOfTries, 063 final int retryTimeout); 064 065 /** 066 * Creates a transport. 067 * 068 * @param hostAddress a host address 069 * @param port a listening port 070 * @param clientStage a transport client-side stage 071 * @param serverStage a transport server-side stage 072 * @param numberOfTries the number of retries for connection 073 * @param retryTimeout retry timeout 074 * @param tcpPortProvider tcpPortProvider 075 * @return transport 076 */ 077 Transport newInstance(final String hostAddress, 078 int port, 079 final EStage<TransportEvent> clientStage, 080 final EStage<TransportEvent> serverStage, 081 final int numberOfTries, 082 final int retryTimeout, 083 final TcpPortProvider tcpPortProvider); 084 085 086}