net.named_data.jndn
public class Node extends Object implements ElementListener
Constructor and Description |
---|
Node(Transport transport,
Transport.ConnectionInfo connectionInfo)
Create a new Node for communication with an NDN hub with the given
Transport object and connectionInfo.
|
Modifier and Type | Method and Description |
---|---|
void |
callLater(double delayMilliseconds,
Runnable callback)
Call callback.run() after the given delay.
|
void |
expressInterest(long pendingInterestId,
Interest interestCopy,
OnData onData,
OnTimeout onTimeout,
OnNetworkNack onNetworkNack,
WireFormat wireFormat,
Face face)
Send the Interest through the transport, read the entire response and call
onData, onTimeout or onNetworkNack as described below.
|
Transport.ConnectionInfo |
getConnectionInfo() |
static int |
getMaxNdnPacketSize()
Get the practical limit of the size of a network-layer packet.
|
long |
getNextEntryId()
Get the next unique entry ID for the pending interest table, interest
filter table, etc.
|
Transport |
getTransport() |
boolean |
isLocal()
Check if the face is local based on the current connection through the
Transport; some Transport may cause network IO (e.g.
|
void |
onReceivedElement(ByteBuffer element)
This is called when an entire element is received.
|
void |
processEvents()
Process any packets to receive and call callbacks such as onData,
onInterest or onTimeout.
|
void |
putData(Data data,
WireFormat wireFormat)
The OnInterestCallback calls this to put a Data packet which
satisfies an Interest.
|
void |
registerPrefix(long registeredPrefixId,
Name prefix,
OnInterestCallback onInterest,
OnRegisterFailed onRegisterFailed,
OnRegisterSuccess onRegisterSuccess,
ForwardingFlags flags,
WireFormat wireFormat,
KeyChain commandKeyChain,
Name commandCertificateName,
Face face)
Register prefix with the connected NDN hub and call onInterest when a
matching interest is received.
|
void |
removePendingInterest(long pendingInterestId)
Remove the pending interest entry with the pendingInterestId from the
pending interest table.
|
void |
removeRegisteredPrefix(long registeredPrefixId)
Remove the registered prefix entry with the registeredPrefixId from the
registered prefix table.
|
void |
send(ByteBuffer encoding)
Send the encoded packet out through the transport.
|
void |
setInterestFilter(long interestFilterId,
InterestFilter filter,
OnInterestCallback onInterest,
Face face)
Add an entry to the local interest filter table to call the onInterest
callback for a matching incoming Interest.
|
void |
shutdown()
Shut down by closing the transport
|
void |
unsetInterestFilter(long interestFilterId)
Remove the interest filter entry which has the interestFilterId from the
interest filter table.
|
public Node(Transport transport, Transport.ConnectionInfo connectionInfo)
transport
- A Transport object used for communication.connectionInfo
- A Transport.ConnectionInfo to be used to connect to
the transport.public final void expressInterest(long pendingInterestId, Interest interestCopy, OnData onData, OnTimeout onTimeout, OnNetworkNack onNetworkNack, WireFormat wireFormat, Face face) throws IOException
pendingInterestId
- The getNextEntryId() for the pending interest ID
which Face got so it could return it to the caller.interestCopy
- The Interest which is NOT copied for this internal Node
method. The Face expressInterest is responsible for making a copy for Node
to use.onData
- When a matching data packet is received, this calls
onData.onData(interest, data) where interest is the interest given to
expressInterest and data is the received Data object.onTimeout
- If the interest times out according to the interest
lifetime, this calls onTimeout.onTimeout(interest) where interest is the
interest given to expressInterest. If onTimeout is null, this does not use
it.onNetworkNack
- When a network Nack packet for the interest is
received and onNetworkNack is not null, this calls
onNetworkNack.onNetworkNack(interest, networkNack) and does not call
onTimeout. However, if a network Nack is received and onNetworkNack is null,
do nothing and wait for the interest to time out.wireFormat
- A WireFormat object used to encode the message.face
- The face which has the callLater method, used for interest
timeouts. The callLater method may be overridden in a subclass of Face.IOException
- For I/O error in sending the interest.Error
- If the encoded interest size exceeds getMaxNdnPacketSize().public final void removePendingInterest(long pendingInterestId)
pendingInterestId
- The ID returned from expressInterest.public final void registerPrefix(long registeredPrefixId, Name prefix, OnInterestCallback onInterest, OnRegisterFailed onRegisterFailed, OnRegisterSuccess onRegisterSuccess, ForwardingFlags flags, WireFormat wireFormat, KeyChain commandKeyChain, Name commandCertificateName, Face face) throws IOException, SecurityException
registeredPrefixId
- The getNextEntryId() for the registered prefix ID
which Face got so it could return it to the caller.prefix
- A Name for the prefix to register. This copies the Name.onInterest
- If not null, this creates an interest filter from prefix
so that when an Interest is received which matches the filter, this calls
onInterest.onInterest(prefix, interest, face, interestFilterId, filter).
If onInterest is null, it is ignored and you must call setInterestFilter.onRegisterFailed
- This calls onRegisterFailed.onRegisterFailed(prefix)
if failed to retrieve the connected hub's ID or failed to register the
prefix.onRegisterSuccess
- This calls
onRegisterSuccess.onRegisterSuccess(prefix, registeredPrefixId) when this
receives a success message from the forwarder. If onRegisterSuccess is null,
this does not use it.flags
- The flags for finer control of which interests are forwarded
to the application.wireFormat
- A WireFormat object used to encode the message.commandKeyChain
- The KeyChain object for signing interests.commandCertificateName
- The certificate name for signing interests.face
- The face which is passed to the onInterest callback. If
onInterest is null, this is ignored.IOException
- For I/O error in sending the registration request.SecurityException
- If signing a command interest for NFD and cannot
find the private key for the certificateName.public final void removeRegisteredPrefix(long registeredPrefixId)
registeredPrefixId
- The ID returned from registerPrefix.public final void setInterestFilter(long interestFilterId, InterestFilter filter, OnInterestCallback onInterest, Face face)
interestFilterId
- The getNextEntryId() for the interest filter ID
which Face got so it could return it to the caller.filter
- The InterestFilter with a prefix and optional regex filter
used to match the name of an incoming Interest. This makes a copy of filter.onInterest
- When an Interest is received which matches the filter,
this calls
onInterest.onInterest(prefix, interest, face, interestFilterId, filter).face
- The face which is passed to the onInterest callback.public final void unsetInterestFilter(long interestFilterId)
interestFilterId
- The ID returned from setInterestFilter.public final void putData(Data data, WireFormat wireFormat) throws IOException
data
- The Data packet which satisfies the interest.wireFormat
- A WireFormat object used to encode the Data packet.Error
- If the encoded Data packet size exceeds getMaxNdnPacketSize().IOException
public final void send(ByteBuffer encoding) throws IOException
encoding
- The array of bytes for the encoded packet to send. This
reads from position() to limit(), but does not change the position.Error
- If the encoded packet size exceeds getMaxNdnPacketSize().IOException
public final void processEvents() throws IOException, EncodingException
IOException
EncodingException
public final Transport getTransport()
public final Transport.ConnectionInfo getConnectionInfo()
public final void onReceivedElement(ByteBuffer element) throws EncodingException
ElementListener
onReceivedElement
in interface ElementListener
element
- The element. This buffer is only valid during this call.
If you need the data later, you must copy.EncodingException
public final boolean isLocal() throws IOException
IOException
public final void shutdown()
public static int getMaxNdnPacketSize()
public final void callLater(double delayMilliseconds, Runnable callback)
delayMilliseconds
- The delay in milliseconds.callback
- This calls callback.run() after the delay.public long getNextEntryId()
Copyright © 2016. All rights reserved.