|
Rice Pastry API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.mpisws.p2p.transport.rendezvous.RendezvousTransportLayerImpl<Identifier,HighIdentifier>
Identifier
- public class RendezvousTransportLayerImpl<Identifier,HighIdentifier extends RendezvousContact>
The trick here is that this layer is at some level, say InetSocketAddress, but must pass around very High-Level Identifiers, such as a NodeHandle for the rendezvous strategy to do its job, but maybe this can just be the RendezvousContact, and it can be casted. protocol: byte CONNECTOR_SOCKET HighIdentifier target = serializer.deserialize(sib); HighIdentifier opener = serializer.deserialize(sib); int uid = sib.readInt(); byte ACCEPTOR_SOCKET HighIdentifier target = serializer.deserialize(sib); HighIdentifier opener = serializer.deserialize(sib); int uid = sib.readInt();
Fields inherited from interface org.mpisws.p2p.transport.rendezvous.RendezvousTransportLayer |
---|
SUCCESS |
Constructor Summary | |
---|---|
RendezvousTransportLayerImpl(TransportLayer<Identifier,java.nio.ByteBuffer> tl,
java.lang.String RENDEZVOUS_CONTACT_STRING,
HighIdentifier myRendezvousContact,
ContactDeserializer<Identifier,HighIdentifier> deserializer,
RendezvousGenerationStrategy<HighIdentifier> rendezvousGenerator,
PilotFinder<HighIdentifier> pilotFinder,
RendezvousStrategy<HighIdentifier> rendezvousStrategy,
ResponseStrategy<Identifier> responseStrategy,
Environment env)
|
Method Summary | |
---|---|
void |
acceptMessages(boolean b)
Toggle accepting incoming messages. |
void |
acceptSockets(boolean b)
Toggle accepting new sockets. |
void |
closePilot(HighIdentifier i)
Tells the manager that the pilot to the Identifier is no longer useful |
protected void |
createForwarder(P2PSocket<Identifier> a,
P2PSocket<Identifier> b,
HighIdentifier connector,
HighIdentifier acceptor,
int uid)
|
void |
destroy()
|
protected HighIdentifier |
getHighIdentifier(java.util.Map<java.lang.String,java.lang.Object> options)
|
Identifier |
getLocalIdentifier()
The local node. |
void |
incomingSocket(P2PSocket<Identifier> s)
Notification of a new socket. |
void |
messageReceived(Identifier i,
java.nio.ByteBuffer m,
java.util.Map<java.lang.String,java.lang.Object> options)
Called when a new message is received. |
void |
messageReceivedFromOverlay(HighIdentifier i,
java.nio.ByteBuffer m,
java.util.Map<java.lang.String,java.lang.Object> options)
Usually called from the higher level app, who probably used routing to get the message here. |
protected void |
openAcceptSocket(HighIdentifier requestor,
HighIdentifier middleMan,
int uid)
We are a firewalled node and got a connect request, now time to respond to it |
void |
openChannel(HighIdentifier requestor,
HighIdentifier middleMan,
int uid)
Open a socket to the dest, then after writing credentials, call notify the higher layer: incomingSocket() |
SocketRequestHandle<HighIdentifier> |
openPilot(HighIdentifier i,
Continuation<SocketRequestHandle<HighIdentifier>,java.lang.Exception> deliverAckToMe)
Only used by NATted node. |
SocketRequestHandle<Identifier> |
openSocket(Identifier i,
SocketCallback<Identifier> deliverSocketToMe,
java.util.Map<java.lang.String,java.lang.Object> options)
Open a socket to the Identifier |
protected boolean |
openSocketUsingPilotToMe(HighIdentifier contact,
SocketRequestHandle<Identifier> handle,
SocketCallback<Identifier> deliverSocketToMe,
java.util.Map<java.lang.String,java.lang.Object> options)
Return true there was a pilot to me. |
protected void |
openSocketViaPilot(HighIdentifier dest,
HighIdentifier middleMan,
SocketRequestHandle<Identifier> handle,
SocketCallback<Identifier> deliverSocketToMe,
java.util.Map<java.lang.String,java.lang.Object> options)
|
void |
putConnectSocket(HighIdentifier requestor,
HighIdentifier target,
int uid,
P2PSocket<Identifier> socket)
This map stores the connect socket until the corresponding accept socket arrives |
protected void |
putExpectedIncomingSocket(HighIdentifier contact,
int uid,
SocketCallback<Identifier> deliverSocketToMe,
SocketRequestHandle<Identifier> requestHandle)
|
protected void |
readAcceptHeader(P2PSocket<Identifier> acceptorSocket)
|
protected void |
readConnectHeader(P2PSocket<Identifier> socket)
|
P2PSocket<Identifier> |
removeConnectSocket(HighIdentifier requestor,
HighIdentifier target,
int uid)
|
protected Tuple<SocketCallback<Identifier>,SocketRequestHandle<Identifier>> |
removeExpectedIncomingSocket(HighIdentifier target,
int uid)
|
protected void |
routeForSocket()
|
MessageRequestHandle<Identifier,java.nio.ByteBuffer> |
sendMessage(Identifier i,
java.nio.ByteBuffer m,
MessageCallback<Identifier,java.nio.ByteBuffer> deliverAckToMe,
java.util.Map<java.lang.String,java.lang.Object> options)
What to do if firewalled? ConnectRequest UDP only? For now always use UDP_AND_TCP |
void |
setCallback(TransportLayerCallback<Identifier,java.nio.ByteBuffer> callback)
Set the callback for incoming sockets/messages |
void |
setErrorHandler(ErrorHandler<Identifier> handler)
To be notified of problems not related to an outgoing messaage/socket. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final byte NORMAL_SOCKET
public static final byte CONNECTOR_SOCKET
public static final byte ACCEPTOR_SOCKET
public static final byte PILOT_SOCKET
public static final byte CONNECTION_RESPONSE_FAILURE
public static final byte CONNECTION_RESPONSE_SUCCESS
public static final java.lang.String OPTION_USE_PILOT
public java.lang.String RENDEZVOUS_CONTACT_STRING
protected TransportLayer<Identifier,java.nio.ByteBuffer> tl
protected TransportLayerCallback<Identifier,java.nio.ByteBuffer> callback
protected RendezvousGenerationStrategy<HighIdentifier extends RendezvousContact> rendezvousGenerator
protected PilotFinder<HighIdentifier extends RendezvousContact> pilotFinder
protected RendezvousStrategy<HighIdentifier extends RendezvousContact> rendezvousStrategy
protected ResponseStrategy<Identifier> responseStrategy
protected HighIdentifier extends RendezvousContact localNodeHandle
protected Logger logger
protected ContactDeserializer<Identifier,HighIdentifier extends RendezvousContact> serializer
protected SelectorManager selectorManager
protected RandomSource random
public static final java.lang.String FROM_OVERLAY
public static final byte PILOT_PING
public static final byte PILOT_PONG
public static final byte PILOT_REQUEST
public static final byte[] PILOT_PING_BYTES
public static final byte[] PILOT_PONG_BYTES
public static final byte[] PILOT_SOCKET_BYTES
public static final int PILOT_PING_PERIOD
Constructor Detail |
---|
public RendezvousTransportLayerImpl(TransportLayer<Identifier,java.nio.ByteBuffer> tl, java.lang.String RENDEZVOUS_CONTACT_STRING, HighIdentifier myRendezvousContact, ContactDeserializer<Identifier,HighIdentifier> deserializer, RendezvousGenerationStrategy<HighIdentifier> rendezvousGenerator, PilotFinder<HighIdentifier> pilotFinder, RendezvousStrategy<HighIdentifier> rendezvousStrategy, ResponseStrategy<Identifier> responseStrategy, Environment env)
Method Detail |
---|
public SocketRequestHandle<Identifier> openSocket(Identifier i, SocketCallback<Identifier> deliverSocketToMe, java.util.Map<java.lang.String,java.lang.Object> options)
TransportLayer
openSocket
in interface TransportLayer<Identifier,java.nio.ByteBuffer>
i
- who to open the socket todeliverSocketToMe
- the callback when the socket is openedoptions
- options on how to open the socket (don't source route, encrypt etc) (may not be respected if layer cannot provide service)
protected boolean openSocketUsingPilotToMe(HighIdentifier contact, SocketRequestHandle<Identifier> handle, SocketCallback<Identifier> deliverSocketToMe, java.util.Map<java.lang.String,java.lang.Object> options)
contact
- handle
- deliverSocketToMe
-
protected void openSocketViaPilot(HighIdentifier dest, HighIdentifier middleMan, SocketRequestHandle<Identifier> handle, SocketCallback<Identifier> deliverSocketToMe, java.util.Map<java.lang.String,java.lang.Object> options)
protected void routeForSocket()
protected HighIdentifier getHighIdentifier(java.util.Map<java.lang.String,java.lang.Object> options)
public void incomingSocket(P2PSocket<Identifier> s) throws java.io.IOException
TransportLayerCallback
incomingSocket
in interface TransportLayerCallback<Identifier,java.nio.ByteBuffer>
s
- the incoming socket
java.io.IOException
protected void readConnectHeader(P2PSocket<Identifier> socket) throws java.io.IOException
java.io.IOException
protected void readAcceptHeader(P2PSocket<Identifier> acceptorSocket) throws java.io.IOException
java.io.IOException
protected void putExpectedIncomingSocket(HighIdentifier contact, int uid, SocketCallback<Identifier> deliverSocketToMe, SocketRequestHandle<Identifier> requestHandle)
protected Tuple<SocketCallback<Identifier>,SocketRequestHandle<Identifier>> removeExpectedIncomingSocket(HighIdentifier target, int uid)
protected void createForwarder(P2PSocket<Identifier> a, P2PSocket<Identifier> b, HighIdentifier connector, HighIdentifier acceptor, int uid)
public void putConnectSocket(HighIdentifier requestor, HighIdentifier target, int uid, P2PSocket<Identifier> socket)
socket
- requestor
- target
- uid
- public P2PSocket<Identifier> removeConnectSocket(HighIdentifier requestor, HighIdentifier target, int uid)
public void openChannel(HighIdentifier requestor, HighIdentifier middleMan, int uid)
RendezvousTransportLayer
openChannel
in interface RendezvousTransportLayer<HighIdentifier extends RendezvousContact>
protected void openAcceptSocket(HighIdentifier requestor, HighIdentifier middleMan, int uid)
requestor
- i
- sib
- public MessageRequestHandle<Identifier,java.nio.ByteBuffer> sendMessage(Identifier i, java.nio.ByteBuffer m, MessageCallback<Identifier,java.nio.ByteBuffer> deliverAckToMe, java.util.Map<java.lang.String,java.lang.Object> options)
sendMessage
in interface TransportLayer<Identifier,java.nio.ByteBuffer>
i
- the destinationm
- the messagedeliverAckToMe
- layer dependent notification when the message is sent (can indicate placed on the wire, point-to-point acknowledgment, or end-to-end acknowledgement)options
- delivery options (don't source route, encrypt etc) (may not be respected if layer cannot provide service)
public java.lang.String toString()
toString
in class java.lang.Object
public void messageReceivedFromOverlay(HighIdentifier i, java.nio.ByteBuffer m, java.util.Map<java.lang.String,java.lang.Object> options) throws java.io.IOException
messageReceivedFromOverlay
in interface RendezvousTransportLayer<HighIdentifier extends RendezvousContact>
i
- m
- options
-
java.io.IOException
public void messageReceived(Identifier i, java.nio.ByteBuffer m, java.util.Map<java.lang.String,java.lang.Object> options) throws java.io.IOException
TransportLayerCallback
messageReceived
in interface TransportLayerCallback<Identifier,java.nio.ByteBuffer>
i
- The node it is coming fromm
- the messageoptions
- describe how the message arrived (udp/tcp, encrypted etc)
java.io.IOException
- if there is a problem decoding the messagepublic void acceptMessages(boolean b)
TransportLayer
acceptMessages
in interface TransportLayer<Identifier,java.nio.ByteBuffer>
public void acceptSockets(boolean b)
TransportLayer
acceptSockets
in interface TransportLayer<Identifier,java.nio.ByteBuffer>
public Identifier getLocalIdentifier()
TransportLayer
getLocalIdentifier
in interface TransportLayer<Identifier,java.nio.ByteBuffer>
public void setCallback(TransportLayerCallback<Identifier,java.nio.ByteBuffer> callback)
TransportLayer
setCallback
in interface TransportLayer<Identifier,java.nio.ByteBuffer>
callback
- the callback for incoming sockets/messagespublic void setErrorHandler(ErrorHandler<Identifier> handler)
TransportLayer
setErrorHandler
in interface TransportLayer<Identifier,java.nio.ByteBuffer>
handler
- to be notified of problems not related to a specific messaage/socket.public void destroy()
destroy
in interface Destructable
public SocketRequestHandle<HighIdentifier> openPilot(HighIdentifier i, Continuation<SocketRequestHandle<HighIdentifier>,java.lang.Exception> deliverAckToMe)
openPilot
in interface PilotManager<HighIdentifier extends RendezvousContact>
deliverAckToMe
- optional
public void closePilot(HighIdentifier i)
PilotManager
closePilot
in interface PilotManager<HighIdentifier extends RendezvousContact>
|
Rice Pastry API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |