org.littleshoot.util
Class ConnectionMaintainerImpl<T,ServerT>

java.lang.Object
  extended by org.littleshoot.util.ConnectionMaintainerImpl<T,ServerT>
Type Parameters:
T - The type of the object that identifies a server.
ServerT - The type of the object that represents a connection to a server.
All Implemented Interfaces:
ConnectionMaintainer<ServerT>

public final class ConnectionMaintainerImpl<T,ServerT>
extends Object
implements ConnectionMaintainer<ServerT>

An implementation of the connection maintainer interface.


Constructor Summary
ConnectionMaintainerImpl(ConnectionEstablisher<T,ServerT> establisher, CandidateProvider<T> candidateProvider, int minNumConnected)
          Constructs a new connection maintainer.
 
Method Summary
 Collection<ServerT> getConnectedServers()
          Returns a collection of the servers that are currently connected.
 Optional<ServerT> getMostRecentlyActive()
          Returns the most recently active server.
 void start()
          Starts this maintainer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConnectionMaintainerImpl

public ConnectionMaintainerImpl(ConnectionEstablisher<T,ServerT> establisher,
                                CandidateProvider<T> candidateProvider,
                                int minNumConnected)
Constructs a new connection maintainer.

Parameters:
establisher - The object used to establish connections.
candidateProvider - The object that provides candidate servers with which to try establishing connections.
minNumConnected - The minimum number of connections to maintain.
Method Detail

start

public void start()
Description copied from interface: ConnectionMaintainer
Starts this maintainer.

Specified by:
start in interface ConnectionMaintainer<ServerT>

getMostRecentlyActive

public Optional<ServerT> getMostRecentlyActive()
Description copied from interface: ConnectionMaintainer
Returns the most recently active server.

Specified by:
getMostRecentlyActive in interface ConnectionMaintainer<ServerT>
Returns:
The most recently active server. If no server has been active yet, a None object is returned. Otherwise, a Some object with map entry of the most recently active server is returned. The type of the server is determined by the types used by the implementation. In the default implementation, the type of the server is determined by the ConnectionEstablisher that is used.

getConnectedServers

public Collection<ServerT> getConnectedServers()
Description copied from interface: ConnectionMaintainer
Returns a collection of the servers that are currently connected.

Specified by:
getConnectedServers in interface ConnectionMaintainer<ServerT>
Returns:
A collection of the servers that are currently connected. The type of these servers is determined by the types used by the implementation. In the default implementation, the type of the server is determined by the ConnectionEstablisher that is used.


Copyright © 2011-2013 LittleShoot. All Rights Reserved.