com.sleepycat.je.rep.utilint
Class NamedChannelWithTimeout

java.lang.Object
  extended by com.sleepycat.je.rep.utilint.NamedChannel
      extended by com.sleepycat.je.rep.utilint.NamedChannelWithTimeout
All Implemented Interfaces:
Closeable, ByteChannel, Channel, ReadableByteChannel, WritableByteChannel

public class NamedChannelWithTimeout
extends NamedChannel

NamedChannelWithTimeout permits association of timeouts with a SocketChannel. This mechanism is necessary, since the standard mechanism for associating timeouts with sockets using Socket.setSoTimeout is not supported by nio SocketChannels.


Field Summary
 
Fields inherited from class com.sleepycat.je.rep.utilint.NamedChannel
channel
 
Constructor Summary
NamedChannelWithTimeout(RepNode repNode, SocketChannel channel, int timeoutMs)
           
 
Method Summary
 void close()
           
 boolean isActive(long timeMs)
          Method invoked by the time thread to check on the channel on a periodic basis.
 int read(ByteBuffer dst)
           
 void setTimeoutMs(int timeoutMs)
          Used to modify the timeout associated with the channel.
 
Methods inherited from class com.sleepycat.je.rep.utilint.NamedChannel
getChannel, getNameIdPair, isOpen, setNameIdPair, toString, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NamedChannelWithTimeout

public NamedChannelWithTimeout(RepNode repNode,
                               SocketChannel channel,
                               int timeoutMs)
Method Detail

setTimeoutMs

public void setTimeoutMs(int timeoutMs)
Used to modify the timeout associated with the channel.

Parameters:
timeoutMs - the new timeout value

read

public int read(ByteBuffer dst)
         throws IOException
Specified by:
read in interface ReadableByteChannel
Overrides:
read in class NamedChannel
Throws:
IOException

close

public void close()
           throws IOException
Specified by:
close in interface Closeable
Specified by:
close in interface Channel
Overrides:
close in class NamedChannel
Throws:
IOException

isActive

public boolean isActive(long timeMs)
Method invoked by the time thread to check on the channel on a periodic basis. Note that the time that is passed in is a "pseudo" time that is only meaningful for calculating time differences.

Parameters:
timeMs - the pseudo time
Returns:
true if the channel is active, false if it isn't and has been closed


Copyright (c) 2004-2012 Oracle. All rights reserved.