|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--net.vattp.data.DataPath
Field Summary | |
private long |
bytesReceived
The total bytes of messages received over this DataPath |
private long |
bytesSent
The total bytes of messages sent over this DataPath |
private long |
lastNetActivity
The time we last received a part of an inbound message or sent a part of an outbound message. |
private int |
maxReceivedMessageSize
The size of the largest message received over this DataPath |
private int |
maxSentMessageSize
The size of the largest message sent over this DataPath |
private long |
messagesReceived
The total number of messages received over this DataPath |
private long |
messagesSent
The total number of messages sent over this DataPath |
private Clock |
myClock
The Clock object we are using to timeout messages |
private VatTPMgr |
myConnMgr
The VatTPMgr we report the remote identity to for an incoming connection. |
private VatTPConnection |
myDataConnection
The VatTPConnection we report status changes to. |
private ConditionLock |
myEmbargoLock
for debugging purposes |
private KeyPair |
myIdentityKeys
The key pair which defines the identity of this vat |
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 String |
myLocalVatID
The local vatID. |
private MsgHandler[] |
myMsgHandlers
Array of MsgHandlers indexed by message type |
private AuthSecrets |
myProtocolParms
Values for autherization parameters and protocol versions |
private RecvThread |
myRecvThread
The RecvThread receiving messages for this VatTPConnection |
private String |
myRemoteAddr
The location the current Send/Recv Threads are (to) (have been) speaking to. |
private NetAddr |
myRemoteNetAddr
The InetAddress of the remote end, or null if no connection has been made |
private int |
myRemotePortNumber
The port number we are trying to connect to, or 0 for an inbound DataPath. |
private String |
myRemoteVatID
The VatID of the other end of the connectiion. |
private String |
mySavedFlattenedSearchPath
The search path the other end provided on an incoming connection. |
private SendThread |
mySendThread
The SendThread we use for output. |
private StartUpProtocol |
myStartUpProtocol
While connecting, the StartUpProtocol object. |
private Vat |
myVat
The Vat to have the SendThread and RecvThread synchronize on when calling methods in this object. |
private SynchQueue |
myWriter
SynchQueue for queueing outbound messages. |
private static byte[] |
thePingMsg
The ping message to send when a when no messages have been received within . |
private static byte[] |
thePongMsg
The pong message to send when a ping message is received. |
(package private) static Object |
theShutDownToken
enqueued to effectively close the SynchQueue |
private long |
timePingSent
The time we last sent a ping, or zero if we have received a message which canceled the ping timeout. |
Constructor Summary | |
(package private) |
DataPath(VatTPMgr connMgr,
Socket tcpConnection,
KeyPair identityKeys,
String localVatID,
Vat vat,
String localFlattenedSearchPath,
VatLocationLookup vls)
Make a new DataPath for an incoming connection |
(package private) |
DataPath(VatTPMgr connMgr,
VatTPConnection connection,
String remoteVatID,
String remoteAddr,
Hashtable addressesTried,
KeyPair identityKeys,
String localVatID,
Vat vat,
byte[] outgoingSuspendID,
AuthSecrets protocolParms,
String localFlattenedSearchPath)
Make a new DataPath |
Method Summary | |
(package private) void |
acceptReceiver(RecvThread receiver,
NetAddr remoteNetAddr,
NetAddr localNetAddr)
Accept the RecvThread from the SendThread when it has been created. |
(package private) void |
cantResume(String reason)
Handle the case where the resume ID's don't match. |
private SynchQueue |
commonConstructionSetup(KeyPair identityKeys,
String localVatID,
byte[] suspendID,
Vat vat,
String localFlattenedSearchPath,
VatLocationLookup vls)
Do the common setup operations for the two constructor methods. |
(package private) String |
connectConnection(VatTPConnection connection,
AuthSecrets protocolParms)
Connect this DataPath to a VatTPConnection. |
void |
connectionDead(VatTPConnection connection,
Throwable reason)
Receive notification that the connection is dead. |
(package private) void |
connectToSelf()
Notify the connectToVatAt caller that he has tried to connect to self |
(package private) void |
duplicatePath(String reason,
boolean isIdentified)
Duplicate crossed connection DataPath exiting. |
(package 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. |
(package private) ConditionLock |
getEmbargoLock()
|
(package private) String |
getRemoteAddress()
Return the remote address we are connected to. |
(package private) int |
getStartupState()
Get the startup state of this DataPath. |
(package private) int |
identifyIncoming(String localVatID,
String remoteVatID,
String remoteSearchPath)
Identify the remote vat's vatID for an incoming connection. |
(package private) Object |
identifyOutgoing(String localVatID,
String remoteVatID,
String remoteFlattenedSearchPath)
Identify the remote vat's vatID for an outgoing "to WHOEVER" connection. |
(package private) boolean |
isChoiceIncoming()
Decide whether to keep incoming connection or outgoing when other end asks us to chose on an outgoing connection. |
(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. |
void |
processMessage(byte[] message,
VatTPConnection connection)
Process an incoming message from the VatTPConnection. |
(package private) void |
recordSendProgress()
Record that sending data has made progress for ping/pong logic. |
(package private) void |
registerMsgHandler(int msgType,
MsgHandler handler)
Register a MsgHandler for a particular message type. |
(package private) boolean |
resumeConnection(byte[] suspendID)
Check if a connection should be resumed. |
void |
run(long tick)
Called by Clocks on their targets after each tick. |
(package private) void |
sendFinished(int count,
int length,
StreamMessage msg)
sendFinished called when a message has been completely passed to TCP |
(package private) void |
setAuthorizationSecrets(byte[] dhSecret,
byte[] sendSequence,
byte[] recvSequence)
Set the initial sequences to be used with a connection. |
(package private) void |
shutDownFinished(byte[] sendSequence,
Throwable reason)
shutDownFinished called when all queued messages have been sent and the socket closed. |
(package private) void |
shutDownPath()
Causes a shutdown of the path. |
(package private) void |
startupSuccessful(String eMsgProtocolVersion,
String protocolSuite)
Called by StartUpProtocol when a connection to a remote vat has been successfully made. |
(package private) void |
stopStartUpProtocol()
Stop the start up protocol on this DataPath. |
String |
toString()
Describe this path object. |
(package private) void |
tryNext(String reason)
Stop TCP to this address and try the next on on the list. |
(package private) void |
unRegisterMsgHandler(int 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 |
static final Object theShutDownToken
private static final byte[] thePongMsg
private static final byte[] thePingMsg
private VatTPConnection myDataConnection
private final VatTPMgr myConnMgr
private MsgHandler[] myMsgHandlers
private SynchQueue myWriter
private RecvThread myRecvThread
private final SendThread mySendThread
private long lastNetActivity
private long timePingSent
private Clock myClock
private String myRemoteAddr
private NetAddr myRemoteNetAddr
private NetAddr myLocalNetAddr
private int myRemotePortNumber
private String myRemoteVatID
private Vat myVat
private KeyPair myIdentityKeys
private String myLocalVatID
private String myLocalFlattenedSearchPath
private String mySavedFlattenedSearchPath
private StartUpProtocol myStartUpProtocol
private final boolean myIsIncoming
private AuthSecrets myProtocolParms
private long bytesReceived
private long messagesReceived
private int maxReceivedMessageSize
private long bytesSent
private long messagesSent
private int maxSentMessageSize
private final ConditionLock myEmbargoLock
Constructor Detail |
DataPath(VatTPMgr connMgr, Socket tcpConnection, KeyPair identityKeys, String localVatID, Vat vat, String localFlattenedSearchPath, VatLocationLookup vls)
connMgr
- The VatTPMgr to notify of status changes.tcpConnection
- The Socket to the TCP connection.identityKeys
- is the KeyPair which defines the identity of this
vat.vat
- is the Vat whose thread we use to synchronize
calls into the DataPath object from the SendThread and ReceiveThreadlocalFlattenedSearchPath
- Is the search path we publish for
references to us, flattened into a string.DataPath(VatTPMgr connMgr, VatTPConnection connection, String remoteVatID, String remoteAddr, Hashtable addressesTried, KeyPair identityKeys, String localVatID, Vat vat, byte[] outgoingSuspendID, AuthSecrets protocolParms, String localFlattenedSearchPath)
connMgr
- is the VatTPMgr if this DataPath is supporting
a "connectToVatAt" operation. Otherwise it is null.connection
- The VatTPConnection to notify of status
changes.remoteVatID
- the vatID of the remote vatremoteAddr
- is the dotted IP address or DNS name and port number
of the place to try for the remote vat.addressesTried
- is a Hashtable of the InetAddresses already
tried to locate the vat which failed due to host,
rather than port related problems, and are not to be
tried again.identityKeys
- is the KeyPair which defines the identity of this
vat.vat
- is the Vat whose thread we use to synchronize
calls into the DataPath object from the SendThread and ReceiveThreadoutgoingSuspendID
- Is the Suspend ID we are to send to the
remote vat for resuming a connection, or null for a new connection.protocolParms
- is the AuthSecrets object which has the resume
state for protocol versions an protocol parameters for resuming a
connection, or null for a new connection.localFlattenedSearchPath
- Is the search path we publish for
references to us, flattened into a string.Method Detail |
ConditionLock getEmbargoLock()
void acceptReceiver(RecvThread receiver, NetAddr remoteNetAddr, NetAddr localNetAddr)
receiver
- is the RecvThread object.remoteNetAddr
- is the remote end's address.localNetAddr
- is the local end's address.void cantResume(String reason)
reason
- The reason for abandoning the attempt.private SynchQueue commonConstructionSetup(KeyPair identityKeys, String localVatID, byte[] suspendID, Vat vat, String localFlattenedSearchPath, VatLocationLookup vls)
identityKeys
- is the public/private key pair that define this vat.localVatID
- is the vatID of this vat.suspendID
- is the suspend ID to send during the startup protocol,
or null if this is an incoming connection or a new connection.vat
- is the Vat to synchronize on when other
threads call methods which are "in vat".localFlattenedSearchPath
- is the search path for this vat as a
String, the elements separated by semicolons.vls
- is the object which gives VLS look functionality, or null
if this vat doesn't support that functionality or if this
is an outgoing connection.
String connectConnection(VatTPConnection connection, AuthSecrets protocolParms)
connection
- is the VatTPConnection object to connect to.protocolParms
- is the protocol versions and parameters
to use for resuming a connection, or null for none.
public void connectionDead(VatTPConnection connection, Throwable reason)
If an object is registered to handle more than one message type, it will receive one connectionDead notification for each message type for which it is registered.
connectionDead
in interface MsgHandler
connection
- The VatTPConnection object which has just died.
For this use, it may be null.reason
- is a Throwable describing why the connection was shut down.void connectToSelf()
void duplicatePath(String reason, boolean isIdentified)
reason
- The reason for abandoning the attempt.void enqueue(Object message)
message
- the message to queuevoid extendSearchPath(ConstList addresses)
addresses
- An array of Strings of the addresses to add.String getRemoteAddress()
int getStartupState()
int identifyIncoming(String localVatID, String remoteVatID, String remoteSearchPath) throws IOException
remoteVatID
- the VatID of the remote vat.remoteSearchPath
- the search path to use to find the remote vat
in array form.
IOException
Object identifyOutgoing(String localVatID, String remoteVatID, String remoteFlattenedSearchPath) throws IOException
remoteVatID
- is the VatID of the remote vat.remoteFlattenedSearchPath
- is the search path to use to find the
remote vat.
IOException
boolean isChoiceIncoming()
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 problempublic void run(long tick)
run
in interface TickReactor
tick
- is the current tick count for the Clock - ignoredpublic void processMessage(byte[] message, VatTPConnection connection)
processMessage
in interface MsgHandler
message
- is the incoming message. The first byte (message[0])
is the message type (see class Msg). A handler which is registered
for more than one message can use the initial byte to determine what
is the message type of the current message.connection
- is the VatTPConnection object on which the the message
arrived. For this use, it may be null.Msg
,
VatTPConnection
void recordSendProgress()
void registerMsgHandler(int 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 an error to register more
than one handler for a message type.
It is a fatal error if the msgType is out of range.
It is a fatal error 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 handler registered for this message type.Msg
,
MsgHandler
,
VatTPMgr
boolean resumeConnection(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 sendFinished(int count, int length, StreamMessage msg)
length
- The size of the message passed to TCP.void setAuthorizationSecrets(byte[] dhSecret, byte[] sendSequence, byte[] recvSequence)
dhSecret
- is the Diffie Hellman shared secret.sendSequence
- is the first sequence number to be used to send
data to the remote vat.recvSequence
- is the first sequence number to be used to
receive data from the remote vat.void shutDownFinished(byte[] sendSequence, Throwable reason)
sendSequence
- is the next sequence number to use on the send
path after resume.reason
- is a Throwable which describes why the shutdown.void shutDownPath()
void startupSuccessful(String eMsgProtocolVersion, String protocolSuite) throws IOException
eMsgProtocolVersion
- the version of the E message protocl
selected.protocolSuite
- the type of authentication selected.
IOException
void stopStartUpProtocol()
public String toString()
toString
in class Object
void tryNext(String reason)
reason
- is a message describing the reason for abandoning this
try.void unRegisterMsgHandler(int 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 |