net.named_data.jndn
public class ThreadPoolFace extends Face
commandCertificateName_, commandKeyChain_, node_
Constructor and Description |
---|
ThreadPoolFace(ScheduledExecutorService threadPool,
Transport transport,
Transport.ConnectionInfo connectionInfo)
Create a new ThreadPoolFace 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)
Override to schedule in the thread pool to call callback.run() after the
given delay.
|
long |
expressInterest(Interest interest,
OnData onData,
OnTimeout onTimeout,
OnNetworkNack onNetworkNack,
WireFormat wireFormat)
Override to submit a task to use the thread pool given to the constructor.
|
long |
expressInterest(Name name,
Interest interestTemplate,
OnData onData,
OnTimeout onTimeout,
OnNetworkNack onNetworkNack,
WireFormat wireFormat)
Override to submit a task to use the thread pool given to the constructor.
|
long |
registerPrefix(Name prefix,
OnInterestCallback onInterest,
OnRegisterFailed onRegisterFailed,
OnRegisterSuccess onRegisterSuccess,
ForwardingFlags flags,
WireFormat wireFormat)
Submit a task to the thread pool to register prefix with the connected
forwarder and call onInterest when a matching interest is received.
|
long |
setInterestFilter(InterestFilter filter,
OnInterestCallback onInterest)
Submit a task to the thread pool to add an entry to the local interest
filter table to call the onInterest callback for a matching incoming
Interest.
|
expressInterest, expressInterest, expressInterest, expressInterest, expressInterest, expressInterest, expressInterest, expressInterest, expressInterest, expressInterest, expressInterest, expressInterest, expressInterest, expressInterest, expressInterest, expressInterest, getInterestCopy, getMaxNdnPacketSize, isLocal, makeCommandInterest, makeCommandInterest, processEvents, putData, putData, registerPrefix, registerPrefix, registerPrefix, registerPrefix, registerPrefix, registerPrefix, registerPrefix, registerPrefix, registerPrefix, registerPrefix, registerPrefix, registerPrefix, registerPrefix, registerPrefix, registerPrefix, removePendingInterest, removeRegisteredPrefix, send, send, setCommandCertificateName, setCommandSigningInfo, setInterestFilter, shutdown, unsetInterestFilter
public ThreadPoolFace(ScheduledExecutorService threadPool, Transport transport, Transport.ConnectionInfo connectionInfo)
threadPool
- The thread pool used to submit method calls such as
expressInterest and the related callbacks such as onData. The thread pool
is also used to schedule the interest timeouts.transport
- A Transport object used for communication. If you do not
want to call processEvents, then the transport should be an async transport
like AsyncTcpTransport, in which case the transport should use the same
ioService.connectionInfo
- A Transport.ConnectionInfo to be used to connect to
the transport.public long expressInterest(Interest interest, OnData onData, OnTimeout onTimeout, OnNetworkNack onNetworkNack, WireFormat wireFormat) throws IOException
expressInterest
in class Face
interest
- The Interest to send. This copies the Interest.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. NOTE: You must not
change the interest object - if you need to change it then make a copy.
NOTE: The library will log any exceptions thrown by this callback, but for
better error handling the callback should catch and properly handle any
exceptions.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.
NOTE: The library will log any exceptions thrown by this callback, but for
better error handling the callback should catch and properly handle any
exceptions.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. (Therefore, an
application which does not yet process a network Nack reason treats a
Nack the same as a timeout.)
NOTE: The library will log any exceptions thrown by this callback, but for
better error handling the callback should catch and properly handle any
exceptions.wireFormat
- A WireFormat object used to encode the message.IOException
- For I/O error in sending the interest.public long expressInterest(Name name, Interest interestTemplate, OnData onData, OnTimeout onTimeout, OnNetworkNack onNetworkNack, WireFormat wireFormat) throws IOException
expressInterest
in class Face
name
- A Name for the interest. This copies the Name.interestTemplate
- If not null, copy interest selectors from the
template. This does not keep a pointer to the Interest object.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. NOTE: You must not
change the interest object - if you need to change it then make a copy.
NOTE: The library will log any exceptions thrown by this callback, but for
better error handling the callback should catch and properly handle any
exceptions.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.
NOTE: The library will log any exceptions thrown by this callback, but for
better error handling the callback should catch and properly handle any
exceptions.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. (Therefore, an
application which does not yet process a network Nack reason treats a
Nack the same as a timeout.)
NOTE: The library will log any exceptions thrown by this callback, but for
better error handling the callback should catch and properly handle any
exceptions.wireFormat
- A WireFormat object used to encode the message.IOException
- For I/O error in sending the interest.public long registerPrefix(Name prefix, OnInterestCallback onInterest, OnRegisterFailed onRegisterFailed, OnRegisterSuccess onRegisterSuccess, ForwardingFlags flags, WireFormat wireFormat) throws IOException, SecurityException
registerPrefix
in class Face
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).
The onInterest callback should supply the Data with face.putData().
NOTE: You must not change the prefix or filter objects - if you need to
change them then make a copy.
If onInterest is null, it is ignored and you must call setInterestFilter.
NOTE: The library will log any exceptions thrown by this callback, but for
better error handling the callback should catch and properly handle any
exceptions.onRegisterFailed
- If register prefix fails for any reason, this
calls onRegisterFailed.onRegisterFailed(prefix).
NOTE: The library will log any exceptions thrown by this callback, but for
better error handling the callback should catch and properly handle any
exceptions.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. (The onRegisterSuccess parameter comes after
onRegisterFailed because it can be null or omitted, unlike onRegisterFailed.)
NOTE: The library will log any exceptions thrown by this callback, but for
better error handling the callback should catch and properly handle any
exceptions.flags
- The flags for finer control of which interests are forwarded
to the application.wireFormat
- A WireFormat object used to encode the message.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.SecurityException
public long setInterestFilter(InterestFilter filter, OnInterestCallback onInterest)
setInterestFilter
in class Face
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).
NOTE: The library will log any exceptions thrown by this callback, but for
better error handling the callback should catch and properly handle any
exceptions.public void callLater(double delayMilliseconds, Runnable callback)
Copyright © 2016. All rights reserved.