|
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.networkinfo.NetworkInfoTransportLayer
public class NetworkInfoTransportLayer
Can open a TCP connection to a known node, and it will return your IP address. Use getMyIpAddress() header = 0; // bypass header = 1; // return IP Also holds a "serialized id." This is an externally specified piece of information. It can be a NodeHandle, a PublicKey etc, any information that any node should be able to query for and may need to do so w/o having a joined PastryNode.
Field Summary | |
---|---|
protected TransportLayerCallback<java.net.InetSocketAddress,java.nio.ByteBuffer> |
callback
|
protected Environment |
environment
|
protected ErrorHandler<java.net.InetSocketAddress> |
errorHandler
|
protected static byte |
HEADER_ID_REQUEST_BYTE
|
protected static byte[] |
HEADER_IP_ADDRESS_REQUEST
|
protected static byte |
HEADER_IP_ADDRESS_REQUEST_BYTE
|
protected static byte[] |
HEADER_NODES_REQUEST
|
protected static byte |
HEADER_NODES_REQUEST_BYTE
|
protected static byte[] |
HEADER_PASSTHROUGH
|
protected static byte |
HEADER_PASSTHROUGH_BYTE
|
protected static byte |
HEADER_PROBE_REQUEST_BYTE
|
protected static byte |
HEADER_PROBE_RESPONSE_BYTE
|
protected Logger |
logger
|
protected ProbeStrategy |
probeStrategy
Ask this strategy to probe a requesting node, but from a 3rd party node |
protected TransportLayer<java.net.InetSocketAddress,java.nio.ByteBuffer> |
tl
|
Constructor Summary | |
---|---|
NetworkInfoTransportLayer(TransportLayer<java.net.InetSocketAddress,java.nio.ByteBuffer> tl,
Environment env,
ErrorHandler<java.net.InetSocketAddress> errorHandler)
|
Method Summary | |
---|---|
void |
acceptMessages(boolean b)
Toggle accepting incoming messages. |
void |
acceptSockets(boolean b)
Toggle accepting new sockets. |
void |
destroy()
|
Cancellable |
getExternalNodes(java.net.InetSocketAddress bootstrap,
Continuation<java.util.Collection<java.net.InetSocketAddress>,java.io.IOException> c,
java.util.Map<java.lang.String,java.lang.Object> options)
find nodes outside of our firewall so I can boot |
Cancellable |
getId(java.net.InetSocketAddress bootstrap,
byte index,
Continuation<byte[],java.io.IOException> c,
java.util.Map<java.lang.String,java.lang.Object> options)
|
java.net.InetSocketAddress |
getLocalIdentifier()
The local node. |
Cancellable |
getMyInetAddress(java.net.InetSocketAddress bootstrap,
Continuation<java.net.InetSocketAddress,java.io.IOException> c,
java.util.Map<java.lang.String,java.lang.Object> options)
Returns the local node's InetSocketAddress |
void |
handleIdRequest(P2PSocket<java.net.InetSocketAddress> socket)
|
void |
handleIpRequest(P2PSocket<java.net.InetSocketAddress> socket)
|
void |
handleNodesRequest(P2PSocket<java.net.InetSocketAddress> socket)
|
void |
handleProbeRequest(P2PSocket<java.net.InetSocketAddress> socket)
|
void |
handleProbeResponse(P2PSocket<java.net.InetSocketAddress> socket)
|
void |
incomingSocket(P2PSocket<java.net.InetSocketAddress> s)
Notification of a new socket. |
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<java.net.InetSocketAddress> |
openSocket(java.net.InetSocketAddress i,
byte[] header,
SocketCallback<java.net.InetSocketAddress> deliverSocketToMe,
java.util.Map<java.lang.String,java.lang.Object> options)
|
SocketRequestHandle<java.net.InetSocketAddress> |
openSocket(java.net.InetSocketAddress i,
SocketCallback<java.net.InetSocketAddress> deliverSocketToMe,
java.util.Map<java.lang.String,java.lang.Object> options)
Open a socket to the Identifier |
Cancellable |
probe(java.net.InetSocketAddress addr,
long uid,
Continuation<java.lang.Long,java.lang.Exception> deliverResponseToMe,
java.util.Map<java.lang.String,java.lang.Object> options)
|
MessageRequestHandle<java.net.InetSocketAddress,java.nio.ByteBuffer> |
sendMessage(java.net.InetSocketAddress i,
java.nio.ByteBuffer m,
MessageCallback<java.net.InetSocketAddress,java.nio.ByteBuffer> deliverAckToMe,
java.util.Map<java.lang.String,java.lang.Object> options)
Set the PASSTHROUGH header |
void |
setCallback(TransportLayerCallback<java.net.InetSocketAddress,java.nio.ByteBuffer> callback)
Set the callback for incoming sockets/messages |
void |
setErrorHandler(ErrorHandler<java.net.InetSocketAddress> handler)
To be notified of problems not related to an outgoing messaage/socket. |
void |
setId(byte index,
byte[] value)
|
void |
setProbeStrategy(ProbeStrategy probeStrategy)
|
Cancellable |
verifyConnectivity(MultiInetSocketAddress local,
java.net.InetSocketAddress probeAddress,
ConnectivityResult deliverResultToMe,
java.util.Map<java.lang.String,java.lang.Object> options)
ask probeAddress to call probeStrategy.requestProbe() |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected Logger logger
protected Environment environment
protected TransportLayerCallback<java.net.InetSocketAddress,java.nio.ByteBuffer> callback
protected ErrorHandler<java.net.InetSocketAddress> errorHandler
protected TransportLayer<java.net.InetSocketAddress,java.nio.ByteBuffer> tl
protected static final byte HEADER_PASSTHROUGH_BYTE
protected static final byte HEADER_IP_ADDRESS_REQUEST_BYTE
protected static final byte HEADER_PROBE_REQUEST_BYTE
protected static final byte HEADER_PROBE_RESPONSE_BYTE
protected static final byte HEADER_NODES_REQUEST_BYTE
protected static final byte HEADER_ID_REQUEST_BYTE
protected static final byte[] HEADER_PASSTHROUGH
protected static final byte[] HEADER_IP_ADDRESS_REQUEST
protected static final byte[] HEADER_NODES_REQUEST
protected ProbeStrategy probeStrategy
Constructor Detail |
---|
public NetworkInfoTransportLayer(TransportLayer<java.net.InetSocketAddress,java.nio.ByteBuffer> tl, Environment env, ErrorHandler<java.net.InetSocketAddress> errorHandler)
Method Detail |
---|
public Cancellable getMyInetAddress(java.net.InetSocketAddress bootstrap, Continuation<java.net.InetSocketAddress,java.io.IOException> c, java.util.Map<java.lang.String,java.lang.Object> options)
InetSocketAddressLookup
getMyInetAddress
in interface InetSocketAddressLookup
bootstrap
- who to askc
- where the return value is deliveredoptions
- can be null
public void setId(byte index, byte[] value)
public Cancellable getId(java.net.InetSocketAddress bootstrap, byte index, Continuation<byte[],java.io.IOException> c, java.util.Map<java.lang.String,java.lang.Object> options)
public Cancellable getExternalNodes(java.net.InetSocketAddress bootstrap, Continuation<java.util.Collection<java.net.InetSocketAddress>,java.io.IOException> c, java.util.Map<java.lang.String,java.lang.Object> options)
InetSocketAddressLookup
getExternalNodes
in interface InetSocketAddressLookup
public SocketRequestHandle<java.net.InetSocketAddress> openSocket(java.net.InetSocketAddress i, SocketCallback<java.net.InetSocketAddress> deliverSocketToMe, java.util.Map<java.lang.String,java.lang.Object> options)
TransportLayer
openSocket
in interface TransportLayer<java.net.InetSocketAddress,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 SocketRequestHandle<java.net.InetSocketAddress> openSocket(java.net.InetSocketAddress i, byte[] header, SocketCallback<java.net.InetSocketAddress> deliverSocketToMe, java.util.Map<java.lang.String,java.lang.Object> options)
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 void handleIpRequest(P2PSocket<java.net.InetSocketAddress> socket) throws java.io.IOException
java.io.IOException
public void handleNodesRequest(P2PSocket<java.net.InetSocketAddress> socket) throws java.io.IOException
java.io.IOException
public void handleIdRequest(P2PSocket<java.net.InetSocketAddress> socket) throws java.io.IOException
java.io.IOException
public void handleProbeRequest(P2PSocket<java.net.InetSocketAddress> socket)
public void handleProbeResponse(P2PSocket<java.net.InetSocketAddress> socket)
public void setCallback(TransportLayerCallback<java.net.InetSocketAddress,java.nio.ByteBuffer> callback)
TransportLayer
setCallback
in interface TransportLayer<java.net.InetSocketAddress,java.nio.ByteBuffer>
callback
- the callback for incoming sockets/messagespublic void setErrorHandler(ErrorHandler<java.net.InetSocketAddress> handler)
TransportLayer
setErrorHandler
in interface TransportLayer<java.net.InetSocketAddress,java.nio.ByteBuffer>
handler
- to be notified of problems not related to a specific messaage/socket.public void acceptMessages(boolean b)
TransportLayer
acceptMessages
in interface TransportLayer<java.net.InetSocketAddress,java.nio.ByteBuffer>
public void acceptSockets(boolean b)
TransportLayer
acceptSockets
in interface TransportLayer<java.net.InetSocketAddress,java.nio.ByteBuffer>
public java.net.InetSocketAddress getLocalIdentifier()
TransportLayer
getLocalIdentifier
in interface TransportLayer<java.net.InetSocketAddress,java.nio.ByteBuffer>
public MessageRequestHandle<java.net.InetSocketAddress,java.nio.ByteBuffer> sendMessage(java.net.InetSocketAddress i, java.nio.ByteBuffer m, MessageCallback<java.net.InetSocketAddress,java.nio.ByteBuffer> deliverAckToMe, java.util.Map<java.lang.String,java.lang.Object> options)
sendMessage
in interface TransportLayer<java.net.InetSocketAddress,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 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 void destroy()
destroy
in interface Destructable
public void setProbeStrategy(ProbeStrategy probeStrategy)
public Cancellable verifyConnectivity(MultiInetSocketAddress local, java.net.InetSocketAddress probeAddress, ConnectivityResult deliverResultToMe, java.util.Map<java.lang.String,java.lang.Object> options)
verifyConnectivity
in interface InetSocketAddressLookup
public Cancellable probe(java.net.InetSocketAddress addr, long uid, Continuation<java.lang.Long,java.lang.Exception> deliverResponseToMe, java.util.Map<java.lang.String,java.lang.Object> options)
probe
in interface Prober
addr
- the address to probeuid
- the uid with the probedeliverResponseToMe
- let me know how it goesoptions
- tl options
|
Rice Pastry API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |