org.fusesource.fabric.dosgi.tcp
Class TransportPool

java.lang.Object
  extended by org.fusesource.fabric.dosgi.tcp.TransportPool
All Implemented Interfaces:
Service
Direct Known Subclasses:
ClientInvokerImpl.InvokerTransportPool

public abstract class TransportPool
extends java.lang.Object
implements Service


Nested Class Summary
protected  class TransportPool.Listener
           
protected static class TransportPool.Pair
           
protected static class TransportPool.TransportState
           
 
Field Summary
static long DEFAULT_EVICTION_DELAY
           
static int DEFAULT_POOL_SIZE
           
protected  long evictionDelay
           
protected static org.slf4j.Logger LOGGER
           
protected  java.util.LinkedList<TransportPool.Pair> pending
           
protected  int poolSize
           
protected  org.fusesource.hawtdispatch.DispatchQueue queue
           
protected  java.util.concurrent.atomic.AtomicBoolean running
           
protected  java.util.Map<Transport,TransportPool.TransportState> transports
           
protected  java.lang.String uri
           
 
Constructor Summary
TransportPool(java.lang.String uri, org.fusesource.hawtdispatch.DispatchQueue queue)
           
TransportPool(java.lang.String uri, org.fusesource.hawtdispatch.DispatchQueue queue, int poolSize, long evictionDelay)
           
 
Method Summary
protected abstract  ProtocolCodec createCodec()
           
protected abstract  Transport createTransport(java.lang.String uri)
           
protected  boolean doOffer(Transport transport, java.lang.Object command, java.lang.Object id)
           
protected  Transport getIdleTransport()
           
 void offer(java.lang.Object data, java.lang.Object id)
           
protected abstract  void onCommand(java.lang.Object command)
           
protected  void onDone(java.lang.Object id)
           
protected abstract  void onFailure(java.lang.Object id, java.lang.Throwable throwable)
           
 void start()
          Starts the service.
 void start(java.lang.Runnable onComplete)
          Starts the service.
protected  void startNewTransport()
           
 void stop()
          Stops the service.
 void stop(java.lang.Runnable onComplete)
          Stops the service.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOGGER

protected static final org.slf4j.Logger LOGGER

DEFAULT_POOL_SIZE

public static final int DEFAULT_POOL_SIZE
See Also:
Constant Field Values

DEFAULT_EVICTION_DELAY

public static final long DEFAULT_EVICTION_DELAY

uri

protected final java.lang.String uri

queue

protected final org.fusesource.hawtdispatch.DispatchQueue queue

pending

protected final java.util.LinkedList<TransportPool.Pair> pending

transports

protected final java.util.Map<Transport,TransportPool.TransportState> transports

running

protected java.util.concurrent.atomic.AtomicBoolean running

poolSize

protected int poolSize

evictionDelay

protected long evictionDelay
Constructor Detail

TransportPool

public TransportPool(java.lang.String uri,
                     org.fusesource.hawtdispatch.DispatchQueue queue)

TransportPool

public TransportPool(java.lang.String uri,
                     org.fusesource.hawtdispatch.DispatchQueue queue,
                     int poolSize,
                     long evictionDelay)
Method Detail

createTransport

protected abstract Transport createTransport(java.lang.String uri)
                                      throws java.lang.Exception
Throws:
java.lang.Exception

createCodec

protected abstract ProtocolCodec createCodec()

onCommand

protected abstract void onCommand(java.lang.Object command)

onFailure

protected abstract void onFailure(java.lang.Object id,
                                  java.lang.Throwable throwable)

onDone

protected void onDone(java.lang.Object id)

offer

public void offer(java.lang.Object data,
                  java.lang.Object id)

doOffer

protected boolean doOffer(Transport transport,
                          java.lang.Object command,
                          java.lang.Object id)

getIdleTransport

protected Transport getIdleTransport()

start

public void start()
           throws java.lang.Exception
Description copied from interface: Service
Starts the service. No guarantee is given that the service has fully started by the time this method returns.

Specified by:
start in interface Service
Throws:
java.lang.Exception

start

public void start(java.lang.Runnable onComplete)
           throws java.lang.Exception
Description copied from interface: Service
Starts the service. Executes the onComplete runnable once the service has fully started up.

Specified by:
start in interface Service
Parameters:
onComplete - my be set to null if not interested in a callback.
Throws:
java.lang.Exception

stop

public void stop()
Description copied from interface: Service
Stops the service. No guarantee is given that the service has fully stopped by the time this method returns.

Specified by:
stop in interface Service

stop

public void stop(java.lang.Runnable onComplete)
Description copied from interface: Service
Stops the service. Executes the onComplete runnable once the service has fully stopped.

Specified by:
stop in interface Service
Parameters:
onComplete - my be set to null if not interested in a callback.

startNewTransport

protected void startNewTransport()
                          throws java.lang.Exception
Throws:
java.lang.Exception


Copyright © 2013 Red Hat. All Rights Reserved.