|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--net.vattp.data.VatTPConnection
Untamed:
Field Summary | |
private long |
bytesReceived
The total bytes of messages received over this VatTPConnection |
private long |
bytesSent
The total bytes of messages sent over this VatTPConnection |
private static byte |
DEAD
|
private static byte |
DIEING
|
private int |
maxReceivedMessageSize
The size of the largest message received over this VatTPConnection |
private int |
maxSentMessageSize
The size of the largest message sent over this VatTPConnection |
private long |
messagesReceived
The total number of messages received over this VatTPConnection |
private long |
messagesSent
The total number of messages sent over this VatTPConnection |
private Hashtable |
myAddressesTried
A Hashtable of the InetAddresses tried which failed due to host related problems. |
private VatTPMgr |
myConnMgr
The VatTPMgr we report status changes to. |
private DataPath |
myDataPath
The DataPath object we are using. |
private String |
myFirstAddressToTry
The first place to look for the remote vat when resuming the connection. |
private String |
myFlattenedRemoteSearchPath
The places to search for the remote vat as a semicolon separated list. |
private KeyPair |
myIdentityKeys
The key pair which defines the identity of this vat |
private DataPath |
myIncomingDataPath
During crossed connection resolution, the incoming DataPath. |
private boolean |
myIsIncoming
Whether we are initiating the connection or responding to a remotely initiated connection. |
private String |
myLocalFlattenedSearchPath
The semicolon separated search path for this vat |
private NetAddr |
myLocalNetAddr
The InetAddress of the local end, or null if no connection has been made |
private byte[] |
myLocalSuspendID
The suspend ID we asked the other end to present to resume the connection, or null if the connection is not suspended. |
private String |
myLocalVatID
|
private MsgHandler[] |
myMsgHandlers
Array of MsgHandlers indexed by message type |
private byte[] |
myOutgoingSuspendID
The suspend ID to present to the other end for a resume, or null for a new connection |
private Vector |
myPendingOutput
Place to queue outgoing messages while myState != RUNNING |
private Vector |
myProblemAccumulator
Place to accumulate the results of our search attempts |
private AuthSecrets |
myProtocolParms
The protocol versions and authorization parameters |
private String |
myRemoteAddr
The location the current DataPath are (to) (have been) speaking to. |
private NetAddr |
myRemoteNetAddr
The InetAddress of the remote end, or null if no connection has been made |
private String |
myRemoteVatID
The VatID of the other end of the connectiion. |
private Throwable |
myShutdownReason
The reason shutDownConnection has been called |
private DynamicMapEnumeration |
mySiteSearch
An enumeration of the places to search for the remote vat |
private byte |
myState
The current state of this VatTPConnection |
private Vat |
myVat
The Vat to have the SendThread and RecvThread synchronize on when calling methods in this object. |
private static byte |
RESUMING
|
private static byte |
RUNNING
|
private static byte |
STARTING
|
private static byte |
SUSPENDED
|
private static byte |
SUSPENDING
|
Constructor Summary | |
(package private) |
VatTPConnection(VatTPMgr connMgr,
KeyPair identityKeys,
String localVatID,
Vat vat,
String remoteVatID,
DataPath path,
String localFlattenedSearchPath,
boolean isIncoming)
Make a new VatTPConnection for an incoming connection |
(package private) |
VatTPConnection(VatTPMgr connMgr,
String remoteVatID,
String flattenedRemoteSearchPath,
KeyPair identityKeys,
String localVatID,
Vat vat,
String localFlattenedSearchPath)
Make a new VatTPConnection |
Method Summary | |
(package private) void |
close()
Close the TCP link on this connection. |
(package private) int |
connectPath(DataPath incomingPath,
String remoteVatID,
boolean isIncoming)
Connect a DataPath object for an incoming connection to an existing VatTPConnection object. |
(package private) void |
duplicatePath(String reason,
DataPath path)
Duplicate crossed connection DataPath exiting. |
private void |
enqueue(Object message)
Enqueue a message for output. |
(package private) void |
extendSearchPath(ConstList addresses)
Add an address to the list of addresses to try. |
ConditionLock |
getEmbargoLock()
Enabled: |
NetAddr |
getLocalNetAddr()
Enabled: Get the NetAddr of the local end, or null if no connection has been made. |
String |
getLocalVatID()
Enabled: Get the vatID of the local end. |
(package private) byte[] |
getOutgoingSuspendID()
Get the outgoing suspend ID for resuming a connection. |
NetAddr |
getRemoteNetAddr()
Enabled: Get the NetAddr of the remote end, or null if no connection has been made. |
ConstList |
getRemoteSearchPath()
Enabled: Get the search path to the remote end |
String |
getRemoteVatID()
Enabled: Get the vatID of the remote end. |
(package private) int |
getState()
Get the state of this VatTPConnection. |
private void |
handleConnectionDeath(Throwable reason)
Handle the death of the connection |
(package private) void |
handleSuspend(byte[] suspendID)
Suspend this connection in response to a request from the other end. |
(package private) void |
identifiedPathDied(String reason,
DataPath path)
Notice that an identified incoming DataPath has failed to complete the startup protocol. |
(package private) boolean |
isChoiceIncoming()
Decide whether to keep incoming connection or outgoing when other end asks us to chose on an outgoing connection. |
private String |
makeConnectionStatusReport()
|
(package private) void |
newIncomingMsg(byte[] message)
Handle a new incoming message from the remote end. |
(package private) void |
noticeProblem(Throwable problem)
Notice problem on the connection. |
(package private) boolean |
noticeRemoteResume(byte[] suspendID)
Check if a connection should be resumed. |
(package private) void |
recordConnectionFailure(Object msg)
Record why this try failed. |
void |
registerMsgHandler(byte msgType,
MsgHandler handler)
Enabled: Register a MsgHandler for a particular message type. |
(package private) void |
sendFinished(int count,
int length,
StreamMessage msg)
sendFinished called when a message has been completely passed to TCP |
void |
sendMsg(byte[] message)
Enabled: Send a message to the remote vat. |
void |
sendMsg(byte[] message,
Runnable notification,
Vat placeToRun)
Enabled: Send a message to the remote vat with notification that it has been queued for processing by the TCP/IP stack on the local machine. |
void |
shutDownConnection()
Enabled: Causes a clean shutdown of the connection. |
void |
shutDownConnection(Throwable reason)
Enabled: Causes a clean shutdown of the connection. |
(package private) void |
shutDownFinished(Throwable reason)
shutDownFinished called when all queued messages have been sent and the socket closed. |
private void |
startResume()
Start trying to resume the connection. |
(package private) void |
startupSuccessful(DataPath path,
String remoteVatID,
NetAddr remoteNetAddr,
NetAddr localNetAddr,
int remotePort,
AuthSecrets authParms)
Called by StartUpProtocol when a connection to a remote vat has been successfully made. |
void |
suspend()
Enabled: Suspend the connection. |
String |
toString()
Suppressed: Describe this connection object. |
private void |
tryNextAddress()
Start an attempt to connect to the next (first) address in the list of addresses to try. |
(package private) void |
unRegisterMsgHandler(byte msgType,
MsgHandler handler)
Remove the registration for a handler for a particular message type. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
private final VatTPMgr myConnMgr
private DataPath myDataPath
private DataPath myIncomingDataPath
private final MsgHandler[] myMsgHandlers
private DynamicMapEnumeration mySiteSearch
private Hashtable myAddressesTried
private String myFirstAddressToTry
private String myFlattenedRemoteSearchPath
private String myRemoteAddr
private NetAddr myRemoteNetAddr
private NetAddr myLocalNetAddr
private final String myRemoteVatID
private final Vat myVat
private final KeyPair myIdentityKeys
private final String myLocalVatID
private final String myLocalFlattenedSearchPath
private Throwable myShutdownReason
private static final byte STARTING
private static final byte RUNNING
private static final byte SUSPENDING
private static final byte SUSPENDED
private static final byte RESUMING
private static final byte DIEING
private static final byte DEAD
private byte myState
private Vector myPendingOutput
private Vector myProblemAccumulator
private boolean myIsIncoming
private byte[] myOutgoingSuspendID
private byte[] myLocalSuspendID
private AuthSecrets myProtocolParms
private long bytesReceived
private long messagesReceived
private int maxReceivedMessageSize
private long bytesSent
private long messagesSent
private int maxSentMessageSize
Constructor Detail |
VatTPConnection(VatTPMgr connMgr, String remoteVatID, String flattenedRemoteSearchPath, KeyPair identityKeys, String localVatID, Vat vat, String localFlattenedSearchPath)
connMgr
- The VatTPMgr to notify of status
changes.remoteVatID
- the vatID of the remote vatflattenedRemoteSearchPath
- is a pathlist of Strings each of which
is the IP address and port number of a place to look for the remote vat.
The IP address can be a DNS name or a dot repsentation of the 32 bit IP
number. Most commonly, the Strings will be the location of the Vat
Location Servers (VLSs) with which the remote vat is believed to
register.identityKeys
- is the KeyPair which defines the identity of this
vat.vat
- is the Vat whose thread we use to synchronize calls into the
VatTPConnection object from the SendThread and ReceiveThreadlocalFlattenedSearchPath
- Is the search path we publish for
references to us, flattened into a string.VatTPConnection(VatTPMgr connMgr, KeyPair identityKeys, String localVatID, Vat vat, String remoteVatID, DataPath path, String localFlattenedSearchPath, boolean isIncoming) throws IOException
connMgr
- The VatTPMgr to notify of status
changes.identityKeys
- is the KeyPair which defines the identity of this
vat.localVatID
- is the vatID of the local vat.vat
- is the Vat whose thread we use to synchronize
calls into the VatTPConnection object from the
SendThread and ReceiveThreadremoteVatID
- is the vatID of the remote vat.path
- The DataPath object controlling the TCP connection.localFlattenedSearchPath
- Is the search path we publish for
references to us, flattened into a string.isIncoming
- is true if this connection is an incoming connection,
otherwise false.Method Detail |
public ConditionLock getEmbargoLock()
void close()
int connectPath(DataPath incomingPath, String remoteVatID, boolean isIncoming)
incomingPath
- is the DataPath object for the incoming connection.remoteVatID
- is the vatID of the remote vat.isIncoming
- is true if the DataPath represents an incoming TCP
connection, is false if it is an outgoing TCP connection.
void duplicatePath(String reason, DataPath path)
reason
- is the reason this is a duplicate.path
- is the path which has been declared duplicate.private void enqueue(Object message) throws IOException
message
- the message to queue
IOException
- if state is DEAD or DIEINGvoid extendSearchPath(ConstList addresses)
addresses
- An array of Strings of the addresses to add.public NetAddr getLocalNetAddr()
public String getLocalVatID()
byte[] getOutgoingSuspendID()
public NetAddr getRemoteNetAddr()
public ConstList getRemoteSearchPath()
public String getRemoteVatID()
int getState()
private void handleConnectionDeath(Throwable reason)
void handleSuspend(byte[] suspendID) throws IOException
suspendID
- is the ID we will need to present to resume the connection.
IOException
void identifiedPathDied(String reason, DataPath path)
path
- is the DataPath object which failed.boolean isChoiceIncoming()
private String makeConnectionStatusReport()
void newIncomingMsg(byte[] message)
message
- the incoming message as a byte array. The first
character is the message type as defined in class Msg.void noticeProblem(Throwable problem)
problem
- The exception which describes the problemboolean noticeRemoteResume(byte[] suspendID)
suspendID
- The secret that the other side must know to resume a
connection or null if this is a new connection.
false if the connection should be abandoned.
void recordConnectionFailure(Object msg)
msg
- A String or Throwable describing the reason for
abandoning this try.public void registerMsgHandler(byte msgType, MsgHandler handler) throws IOException
msgType
- is the message type. It must be chosen from the types
defined in the definition class Msg. An IOException is thrown if an
attempt is made to register more
than one handler for a message type.
An assertion is made that the msgType is not out of range. An assertion is made that no attempts are made to register a handler after the reactToNewConnection method of the object registered with the VatTPMgr has returned.
handler
- is an object which implements the MsgHandler interface.
It will be called with processMessage when a message
of msgType is received from the remote vat. It will be called with
connectionDead when this connection dies.
IOException
- is thrown if
there is already a different handler registered for this message type.Msg
,
MsgHandler
,
VatTPMgr
void sendFinished(int count, int length, StreamMessage msg)
length
- The size of the message passed to TCP.public void sendMsg(byte[] message) throws IOException
message
- is the message to be sent. It must not be altered after
the call to sendMsg. The first byte of message is the message type and
must be chosen from the types defined in the definition class Msg.
(These two restrictions allow sendMsg to avoid copying the message
into a private buffer.)
IOException
- is thrown if the message can not be queued to
be sent because the connection has broken, if the message is longer
than, Msg.MAX_OUTBOUND_MSG_LENGTH, or if there is no listener
registered to process messages of this message's message type.Msg
public void sendMsg(byte[] message, Runnable notification, Vat placeToRun) throws IOException
message
- is the message to be sent. It must not be altered after
the call to sendMsg. The first byte of message is the message type and
must be chosen from the types defined in the definition class Msg.
(These two restrictions allow sendMsg to avoid copying the message
into a private buffer.)notification
- is the Runnable which will be enqueued when
the message has been passed to the platform's TCP stack.placeToRun
- is the Vat where the notification will be
enqueued.
IOException
- is thrown if the message can not be queued to
be sent because the connection has broken, if the message is longer
than, Msg.MAX_OUTBOUND_MSG_LENGTH, or if there is no listener
registered to process messages of this message's message type.Msg
public void shutDownConnection()
public void shutDownConnection(Throwable reason)
XXX markm: I made this public, and changed ProxyConnection to call this with a non-ConnectionShutDownException. As far as I can tell, this shouldn't break anything. But Bill, it would be good for you to double check this.
reason
- indicates why the connection is shutting downvoid shutDownFinished(Throwable reason)
private void startResume()
void startupSuccessful(DataPath path, String remoteVatID, NetAddr remoteNetAddr, NetAddr localNetAddr, int remotePort, AuthSecrets authParms)
path
- is the DataPath object which made the connection.remoteVatID
- is the vatID of the remote vat.remoteNetAddr
- is the remote end's network address.localNetAddr
- is the local end's network address.remotePort
- is the remote port number we tried to connect to,
or 0 if this is an inbound connection (or the port number
is unavailable for some other reason). This port number
will be used if we need to resume the connection later.authParms
- is the AuthSecrets object which contains the
protocol versions and authorization parameters for the connection.public void suspend() throws IOException
Suspended connections will be automatically resumed when data is sent to them with sendMsg().
IOException
- if the connection isn't in the RUNNING state.public String toString()
toString
in class Object
private void tryNextAddress()
void unRegisterMsgHandler(byte msgType, MsgHandler handler) throws IOException
msgType
- is the message type. It must be chosen from the types
defined in the definition class Msg.
It is a fatal error if the msgType is out of range.handler
- is the object currently registered as the handler.
IOException
- is thrown if the handler passed is not the
handler registered for this message type.Msg
,
MsgHandler
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |