org.jgroups.blocks
Class TCPConnectionMap.TCPConnection

java.lang.Object
  extended by org.jgroups.blocks.TCPConnectionMap.TCPConnection
All Implemented Interfaces:
Connection
Enclosing class:
TCPConnectionMap

public class TCPConnectionMap.TCPConnection
extends java.lang.Object
implements Connection


Nested Class Summary
protected  class TCPConnectionMap.TCPConnection.ConnectionPeerReceiver
           
protected  class TCPConnectionMap.TCPConnection.Sender
           
 
Field Summary
protected  java.util.concurrent.atomic.AtomicBoolean active
           
protected  TCPConnectionMap.TCPConnection.ConnectionPeerReceiver connectionPeerReceiver
           
protected  byte[] cookie
           
protected  java.io.DataInputStream in
           
protected  long last_access
           
protected  Log log
           
protected  java.io.DataOutputStream out
           
protected  Address peer_addr
           
protected  int peer_addr_read_timeout
           
protected  java.util.concurrent.locks.Lock send_lock
           
protected  TCPConnectionMap.TCPConnection.Sender sender
           
protected  java.net.Socket sock
           
 
Method Summary
protected  void _send(byte[] data, int offset, int length, boolean acquire_lock)
          Sends data using the 'out' output stream of the socket
 void close()
           
protected  void doSend(byte[] data, int offset, int length)
           
protected  Address getPeerAddress()
           
protected  java.lang.String getSockAddress()
           
 boolean isConnected()
           
 boolean isExpired(long now)
           
 boolean isOpen()
           
protected  boolean isSenderUsed()
           
protected  boolean matchCookie(byte[] input)
           
protected  Address readPeerAddress(java.net.Socket client_sock)
          Reads the peer's address.
protected  void send(byte[] data, int offset, int length)
           
protected  void sendLocalAddress(Address local_addr)
          Send the cookie first, then the our port number.
protected  void start(ThreadFactory f)
           
 java.lang.String toString()
           
protected  void updateLastAccessed()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

sock

protected final java.net.Socket sock

send_lock

protected final java.util.concurrent.locks.Lock send_lock

log

protected final Log log

cookie

protected final byte[] cookie

out

protected final java.io.DataOutputStream out

in

protected final java.io.DataInputStream in

peer_addr

protected final Address peer_addr

peer_addr_read_timeout

protected final int peer_addr_read_timeout
See Also:
Constant Field Values

last_access

protected long last_access

sender

protected TCPConnectionMap.TCPConnection.Sender sender

connectionPeerReceiver

protected TCPConnectionMap.TCPConnection.ConnectionPeerReceiver connectionPeerReceiver

active

protected final java.util.concurrent.atomic.AtomicBoolean active
Method Detail

getPeerAddress

protected Address getPeerAddress()

updateLastAccessed

protected void updateLastAccessed()

start

protected void start(ThreadFactory f)

isSenderUsed

protected boolean isSenderUsed()

getSockAddress

protected java.lang.String getSockAddress()

send

protected void send(byte[] data,
                    int offset,
                    int length)
             throws java.lang.Exception
Parameters:
data - Guaranteed to be non null
offset -
length -
Throws:
java.lang.Exception

_send

protected void _send(byte[] data,
                     int offset,
                     int length,
                     boolean acquire_lock)
              throws java.lang.Exception
Sends data using the 'out' output stream of the socket

Parameters:
data -
offset -
length -
acquire_lock -
Throws:
java.lang.Exception

doSend

protected void doSend(byte[] data,
                      int offset,
                      int length)
               throws java.lang.Exception
Throws:
java.lang.Exception

readPeerAddress

protected Address readPeerAddress(java.net.Socket client_sock)
                           throws java.lang.Exception
Reads the peer's address. First a cookie has to be sent which has to match my own cookie, otherwise the connection will be refused

Throws:
java.lang.Exception

sendLocalAddress

protected void sendLocalAddress(Address local_addr)
                         throws java.lang.Exception
Send the cookie first, then the our port number. If the cookie doesn't match the receiver's cookie, the receiver will reject the connection and close it.

Throws:
java.lang.Exception

matchCookie

protected boolean matchCookie(byte[] input)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

isExpired

public boolean isExpired(long now)
Specified by:
isExpired in interface Connection

isConnected

public boolean isConnected()

isOpen

public boolean isOpen()
Specified by:
isOpen in interface Connection

close

public void close()
           throws java.io.IOException
Specified by:
close in interface Connection
Throws:
java.io.IOException


Copyright © 1998-2012 Bela Ban / Red Hat. All Rights Reserved.