net.jini.jeri.connection
Class ConnectionManager.OutboundMux

java.lang.Object
  extended by com.sun.jini.jeri.internal.mux.Mux
      extended by com.sun.jini.jeri.internal.mux.MuxClient
          extended by net.jini.jeri.connection.ConnectionManager.OutboundMux
Enclosing class:
ConnectionManager

private final class ConnectionManager.OutboundMux
extends MuxClient

Subclass wrapper around MuxClient for outbound connections.


Field Summary
private  Connection c
          The outbound connection.
private  long idleTime
          The time this mux was found to be idle by the Reaper thread.
private  int pendingNewRequests
          Number of pending newRequest calls.
private  boolean pendingStart
          True if the mux needs to be started.
private  Object startLock
          Lock to enforce single start of mux.
 
Fields inherited from class com.sun.jini.jeri.internal.mux.Mux
MAX_REQUESTS
 
Constructor Summary
ConnectionManager.OutboundMux(Connection c)
          Constructs an instance from the connection's streams.
ConnectionManager.OutboundMux(Connection c, boolean ignore)
          Constructs an instance from the connection's channel.
 
Method Summary
(package private)  boolean checkIdle(long now)
          Returns true if the mux is dead, or the mux is idle and the recorded idle time is more than TIMEOUT milliseconds before now, and returns false otherwise.
(package private)  Connection getConnection()
          Returns the outbound connection.
protected  void handleDown()
          Close the connection, so that the provider is notified.
 OutboundRequest newRequest()
          Initiates a new request on the mux and returns it, and sets the idle time to zero.
(package private)  void newRequestPending()
          Registers a pending newRequest call.
 int requestsInProgress()
          Returns the number of active and pending requests.
(package private)  boolean shouldRetry()
           
 
Methods inherited from class com.sun.jini.jeri.internal.mux.MuxClient
populateContext, shutdown
 
Methods inherited from class com.sun.jini.jeri.internal.mux.Mux
setStartTimeout, start
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

c

private final Connection c
The outbound connection.


startLock

private final Object startLock
Lock to enforce single start of mux.


pendingStart

private boolean pendingStart
True if the mux needs to be started.


pendingNewRequests

private int pendingNewRequests
Number of pending newRequest calls. Guarded by enclosing ConnectionManager's lock.


idleTime

private long idleTime
The time this mux was found to be idle by the Reaper thread. Set to zero each time a request is initiated. Guarded by enclosing ConnectionManager's lock.

Constructor Detail

ConnectionManager.OutboundMux

ConnectionManager.OutboundMux(Connection c)
                        throws IOException
Constructs an instance from the connection's streams.

Throws:
IOException

ConnectionManager.OutboundMux

ConnectionManager.OutboundMux(Connection c,
                              boolean ignore)
                        throws IOException
Constructs an instance from the connection's channel.

Throws:
IOException
Method Detail

getConnection

Connection getConnection()
Returns the outbound connection.


newRequestPending

void newRequestPending()
Registers a pending newRequest call.


newRequest

public OutboundRequest newRequest()
                           throws IOException
Initiates a new request on the mux and returns it, and sets the idle time to zero. Starts the mux if necessary, and decrements the pending newRequest count.

Overrides:
newRequest in class MuxClient
Returns:
the OutboundRequest for the newly created request
Throws:
IOException

requestsInProgress

public int requestsInProgress()
                       throws IOException
Returns the number of active and pending requests.

Overrides:
requestsInProgress in class MuxClient
Returns:
the number of requests in progress over this connection
Throws:
IOException - if the multiplexed connection is no longer active

checkIdle

boolean checkIdle(long now)
Returns true if the mux is dead, or the mux is idle and the recorded idle time is more than TIMEOUT milliseconds before now, and returns false otherwise. If the mux is idle and the recorded idle time is zero, sets the recorded idle time to now.


handleDown

protected void handleDown()
Close the connection, so that the provider is notified.

Overrides:
handleDown in class Mux

shouldRetry

boolean shouldRetry()


Copyright 2007-2010, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.