|
Rice Pastry API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.mpisws.p2p.transport.multiaddress.MultiInetAddressTransportLayerImpl
public class MultiInetAddressTransportLayerImpl
This class adds an epoch and a list of InetSocketAddresses, and also disambiguates between them for the lower layer. This is useful in situations where the node is behind a NAT and is addressed differently for nodes outside the NAT as inside. Optimization: Pre-serialize localAddress in the ctor, then just mem-copy it to the buffer
Constructor Summary | |
---|---|
MultiInetAddressTransportLayerImpl(MultiInetSocketAddress localAddress,
TransportLayer<java.net.InetSocketAddress,java.nio.ByteBuffer> wire,
Environment env,
ErrorHandler<MultiInetSocketAddress> handler,
AddressStrategy strategy)
|
Method Summary | |
---|---|
void |
acceptMessages(boolean b)
Toggle accepting incoming messages. |
void |
acceptSockets(boolean b)
Toggle accepting new sockets. |
void |
destroy()
|
AddressStrategy |
getAddressStrategy()
|
MultiInetSocketAddress |
getLocalIdentifier()
The local node. |
void |
incomingSocket(P2PSocket<java.net.InetSocketAddress> s)
Notification of a new socket. |
boolean |
isSendIdentifier()
|
void |
messageReceived(java.net.InetSocketAddress i,
java.nio.ByteBuffer m,
java.util.Map<java.lang.String,java.lang.Object> options)
Called when a new message is received. |
SocketRequestHandle<MultiInetSocketAddress> |
openSocket(MultiInetSocketAddress i,
SocketCallback<MultiInetSocketAddress> deliverSocketToMe,
java.util.Map<java.lang.String,java.lang.Object> options)
Open a socket to the Identifier |
MessageRequestHandle<MultiInetSocketAddress,java.nio.ByteBuffer> |
sendMessage(MultiInetSocketAddress i,
java.nio.ByteBuffer m,
MessageCallback<MultiInetSocketAddress,java.nio.ByteBuffer> deliverAckToMe,
java.util.Map<java.lang.String,java.lang.Object> options)
Send the message to the identifier |
void |
setCallback(TransportLayerCallback<MultiInetSocketAddress,java.nio.ByteBuffer> callback)
Set the callback for incoming sockets/messages |
void |
setErrorHandler(ErrorHandler<MultiInetSocketAddress> handler)
To be notified of problems not related to an outgoing messaage/socket. |
void |
setSendIdentifier(boolean sendIdentifier)
Set this to false to prevent sending/receiving the identifier at this layer for the message/socket. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public MultiInetAddressTransportLayerImpl(MultiInetSocketAddress localAddress, TransportLayer<java.net.InetSocketAddress,java.nio.ByteBuffer> wire, Environment env, ErrorHandler<MultiInetSocketAddress> handler, AddressStrategy strategy)
Method Detail |
---|
public AddressStrategy getAddressStrategy()
getAddressStrategy
in interface MultiInetAddressTransportLayer
public SocketRequestHandle<MultiInetSocketAddress> openSocket(MultiInetSocketAddress i, SocketCallback<MultiInetSocketAddress> deliverSocketToMe, java.util.Map<java.lang.String,java.lang.Object> options)
TransportLayer
openSocket
in interface TransportLayer<MultiInetSocketAddress,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)
public void incomingSocket(P2PSocket<java.net.InetSocketAddress> s) throws java.io.IOException
TransportLayerCallback
incomingSocket
in interface TransportLayerCallback<java.net.InetSocketAddress,java.nio.ByteBuffer>
s
- the incoming socket
java.io.IOException
public MessageRequestHandle<MultiInetSocketAddress,java.nio.ByteBuffer> sendMessage(MultiInetSocketAddress i, java.nio.ByteBuffer m, MessageCallback<MultiInetSocketAddress,java.nio.ByteBuffer> deliverAckToMe, java.util.Map<java.lang.String,java.lang.Object> options)
TransportLayer
sendMessage
in interface TransportLayer<MultiInetSocketAddress,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 messageReceived(java.net.InetSocketAddress i, java.nio.ByteBuffer m, java.util.Map<java.lang.String,java.lang.Object> options) throws java.io.IOException
TransportLayerCallback
messageReceived
in interface TransportLayerCallback<java.net.InetSocketAddress,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 MultiInetSocketAddress getLocalIdentifier()
TransportLayer
getLocalIdentifier
in interface TransportLayer<MultiInetSocketAddress,java.nio.ByteBuffer>
public void acceptMessages(boolean b)
TransportLayer
acceptMessages
in interface TransportLayer<MultiInetSocketAddress,java.nio.ByteBuffer>
public void acceptSockets(boolean b)
TransportLayer
acceptSockets
in interface TransportLayer<MultiInetSocketAddress,java.nio.ByteBuffer>
public void destroy()
destroy
in interface Destructable
public void setCallback(TransportLayerCallback<MultiInetSocketAddress,java.nio.ByteBuffer> callback)
TransportLayer
setCallback
in interface TransportLayer<MultiInetSocketAddress,java.nio.ByteBuffer>
callback
- the callback for incoming sockets/messagespublic void setErrorHandler(ErrorHandler<MultiInetSocketAddress> handler)
TransportLayer
setErrorHandler
in interface TransportLayer<MultiInetSocketAddress,java.nio.ByteBuffer>
handler
- to be notified of problems not related to a specific messaage/socket.public void setSendIdentifier(boolean sendIdentifier)
sendIdentifier
- public boolean isSendIdentifier()
|
Rice Pastry API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |