net.named_data.jndn.util
public class MemoryContentCache extends Object implements OnInterestCallback
Constructor and Description |
---|
MemoryContentCache(Face face)
Create a new MemoryContentCache to use the given Face, with a default
cleanupIntervalMilliseconds of 1000.0 milliseconds.
|
MemoryContentCache(Face face,
double cleanupIntervalMilliseconds)
Create a new MemoryContentCache to use the given Face.
|
Modifier and Type | Method and Description |
---|---|
void |
add(Data data)
Add the Data packet to the cache so that it is available to use to
answer interests.
|
OnInterestCallback |
getStorePendingInterest()
Return a callback to use for onDataNotFound in registerPrefix which simply
calls storePendingInterest() to store the interest that doesn't match a
Data packet.
|
void |
onInterest(Name prefix,
Interest interest,
Face face,
long interestFilterId,
InterestFilter filter)
When an interest is received which matches the interest filter, onInterest
is called.
|
void |
registerPrefix(Name prefix,
OnRegisterFailed onRegisterFailed)
Call registerPrefix on the Face given to the constructor so that this
MemoryContentCache will answer interests whose name matches the filter.
|
void |
registerPrefix(Name prefix,
OnRegisterFailed onRegisterFailed,
OnInterestCallback onDataNotFound)
Call registerPrefix on the Face given to the constructor so that this
MemoryContentCache will answer interests whose name has the prefix.
|
void |
registerPrefix(Name prefix,
OnRegisterFailed onRegisterFailed,
OnInterestCallback onDataNotFound,
ForwardingFlags flags)
Call registerPrefix on the Face given to the constructor so that this
MemoryContentCache will answer interests whose name has the prefix.
|
void |
registerPrefix(Name prefix,
OnRegisterFailed onRegisterFailed,
OnInterestCallback onDataNotFound,
ForwardingFlags flags,
WireFormat wireFormat)
Call registerPrefix on the Face given to the constructor so that this
MemoryContentCache will answer interests whose name has the prefix.
|
void |
registerPrefix(Name prefix,
OnRegisterFailed onRegisterFailed,
OnRegisterSuccess onRegisterSuccess)
Call registerPrefix on the Face given to the constructor so that this
MemoryContentCache will answer interests whose name has the prefix.
|
void |
registerPrefix(Name prefix,
OnRegisterFailed onRegisterFailed,
OnRegisterSuccess onRegisterSuccess,
OnInterestCallback onDataNotFound)
Call registerPrefix on the Face given to the constructor so that this
MemoryContentCache will answer interests whose name has the prefix.
|
void |
registerPrefix(Name prefix,
OnRegisterFailed onRegisterFailed,
OnRegisterSuccess onRegisterSuccess,
OnInterestCallback onDataNotFound,
ForwardingFlags flags)
Call registerPrefix on the Face given to the constructor so that this
MemoryContentCache will answer interests whose name has the prefix.
|
void |
registerPrefix(Name prefix,
OnRegisterFailed onRegisterFailed,
OnRegisterSuccess onRegisterSuccess,
OnInterestCallback onDataNotFound,
ForwardingFlags flags,
WireFormat wireFormat)
Call registerPrefix on the Face given to the constructor so that this
MemoryContentCache will answer interests whose name has the prefix.
|
void |
setInterestFilter(InterestFilter filter)
Call setInterestFilter on the Face given to the constructor so that this
MemoryContentCache will answer interests whose name has the prefix.
|
void |
setInterestFilter(InterestFilter filter,
OnInterestCallback onDataNotFound)
Call setInterestFilter on the Face given to the constructor so that this
MemoryContentCache will answer interests whose name matches the filter.
|
void |
setInterestFilter(Name prefix)
Call setInterestFilter on the Face given to the constructor so that this
MemoryContentCache will answer interests whose name has the prefix.
|
void |
setInterestFilter(Name prefix,
OnInterestCallback onDataNotFound)
Call setInterestFilter on the Face given to the constructor so that this
MemoryContentCache will answer interests whose name has the prefix.
|
void |
storePendingInterest(Interest interest,
Face face)
Store an interest from an OnInterest callback in the internal pending
interest table (normally because there is no Data packet available yet to
satisfy the interest).
|
void |
unregisterAll()
Call Face.unsetInterestFilter and Face.removeRegisteredPrefix for all the
prefixes given to the setInterestFilter and registerPrefix method on this
MemoryContentCache object so that it will not receive interests any more.
|
public MemoryContentCache(Face face, double cleanupIntervalMilliseconds)
face
- The Face to use to call registerPrefix and setInterestFilter,
and which will call this object's OnInterest callback.cleanupIntervalMilliseconds
- The interval in milliseconds
between each check to clean up stale content in the cache. If this is a
large number, then effectively the stale content will not be removed from
the cache.public MemoryContentCache(Face face)
face
- The Face to use to call registerPrefix and setInterestFilter,
and which will call this object's OnInterest callback.public final void registerPrefix(Name prefix, OnRegisterFailed onRegisterFailed, OnRegisterSuccess onRegisterSuccess, OnInterestCallback onDataNotFound, ForwardingFlags flags, WireFormat wireFormat) throws IOException, SecurityException
prefix
- The Name for the prefix to register. This copies the Name.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.
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.onDataNotFound
- If a data packet for an interest is not found in the
cache, this forwards the interest by calling
onDataNotFound.onInterest(prefix, interest, face, interestFilterId, filter).
Your callback can find the Data packet for the interest and call
face.putData(data). If your callback cannot find the Data packet, it can
optionally call storePendingInterest(interest, face) to store the pending
interest in this object to be satisfied by a later call to add(data). If
you want to automatically store all pending interests, you can simply use
getStorePendingInterest() for onDataNotFound. If onDataNotFound 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.flags
- See Face.registerPrefix.wireFormat
- See Face.registerPrefix.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 registerPrefix(Name prefix, OnRegisterFailed onRegisterFailed, OnRegisterSuccess onRegisterSuccess, OnInterestCallback onDataNotFound, ForwardingFlags flags) throws IOException, SecurityException
prefix
- The Name for the prefix to register. This copies the Name.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.
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.onDataNotFound
- If a data packet for an interest is not found in the
cache, this forwards the interest by calling
onInterest.onInterest(prefix, interest, face, interestFilterId, filter).
Your callback can find the Data packet for the interest and call
face.putData(data). If your callback cannot find the Data packet, it can
optionally call storePendingInterest(interest, face) to store the pending
interest in this object to be satisfied by a later call to add(data). If
you want to automatically store all pending interests, you can simply use
getStorePendingInterest() for onDataNotFound. If onDataNotFound is null,
this does not use it.flags
- See Face.registerPrefix.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 registerPrefix(Name prefix, OnRegisterFailed onRegisterFailed, OnRegisterSuccess onRegisterSuccess, OnInterestCallback onDataNotFound) throws IOException, SecurityException
prefix
- The Name for the prefix to register. This copies the Name.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.
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.onDataNotFound
- If a data packet for an interest is not found in the
cache, this forwards the interest by calling
onDataNotFound.onInterest(prefix, interest, face, interestFilterId, filter).
Your callback can find the Data packet for the interest and call
face.putData(data). If your callback cannot find the Data packet, it can
optionally call storePendingInterest(interest, face) to store the pending
interest in this object to be satisfied by a later call to add(data). If
you want to automatically store all pending interests, you can simply use
getStorePendingInterest() for onDataNotFound. If onDataNotFound 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.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 registerPrefix(Name prefix, OnRegisterFailed onRegisterFailed, OnRegisterSuccess onRegisterSuccess) throws IOException, SecurityException
prefix
- The Name for the prefix to register. This copies the Name.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.
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.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 registerPrefix(Name prefix, OnRegisterFailed onRegisterFailed, OnInterestCallback onDataNotFound, ForwardingFlags flags, WireFormat wireFormat) throws IOException, SecurityException
prefix
- The Name for the prefix to register. This copies the Name.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.onDataNotFound
- If a data packet for an interest is not found in the
cache, this forwards the interest by calling
onDataNotFound.onInterest(prefix, interest, face, interestFilterId, filter).
Your callback can find the Data packet for the interest and call
face.putData(data). If your callback cannot find the Data packet, it can
optionally call storePendingInterest(interest, face) to store the pending
interest in this object to be satisfied by a later call to add(data). If
you want to automatically store all pending interests, you can simply use
getStorePendingInterest() for onDataNotFound. If onDataNotFound 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.flags
- See Face.registerPrefix.wireFormat
- See Face.registerPrefix.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 registerPrefix(Name prefix, OnRegisterFailed onRegisterFailed, OnInterestCallback onDataNotFound, ForwardingFlags flags) throws IOException, SecurityException
prefix
- The Name for the prefix to register. This copies the Name.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.onDataNotFound
- If a data packet for an interest is not found in the
cache, this forwards the interest by calling
onDataNotFound.onInterest(prefix, interest, face, interestFilterId, filter).
Your callback can find the Data packet for the interest and call
face.putData(data). If your callback cannot find the Data packet, it can
optionally call storePendingInterest(interest, face) to store the pending
interest in this object to be satisfied by a later call to add(data). If
you want to automatically store all pending interests, you can simply use
getStorePendingInterest() for onDataNotFound. If onDataNotFound is null,
this does not use it.flags
- See Face.registerPrefix.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 registerPrefix(Name prefix, OnRegisterFailed onRegisterFailed, OnInterestCallback onDataNotFound) throws IOException, SecurityException
prefix
- The Name for the prefix to register. This copies the Name.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.onDataNotFound
- If a data packet for an interest is not found in the
cache, this forwards the interest by calling
onDataNotFound.onInterest(prefix, interest, face, interestFilterId, filter).
Your callback can find the Data packet for the interest and call
face.putData(data). If your callback cannot find the Data packet, it can
optionally call storePendingInterest(interest, face) to store the pending
interest in this object to be satisfied by a later call to add(data). If
you want to automatically store all pending interests, you can simply use
getStorePendingInterest() for onDataNotFound. If onDataNotFound 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.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 registerPrefix(Name prefix, OnRegisterFailed onRegisterFailed) throws IOException, SecurityException
prefix
- The Name for the prefix to register. This copies the Name.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.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 setInterestFilter(InterestFilter filter, OnInterestCallback onDataNotFound)
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.onDataNotFound
- If a data packet for an interest is not found in the
cache, this forwards the interest by calling
onDataNotFound.onInterest(prefix, interest, face, interestFilterId, filter).
Your callback can find the Data packet for the interest and call
face.putData(data). Note: If you call setInterestFilter multiple times where
filter.getPrefix() is the same, it is undetermined which onDataNotFound
will be called. If your callback cannot find the Data packet, it can
optionally call storePendingInterest(interest, face) to store the pending
interest in this object to be satisfied by a later call to add(data). If
you want to automatically store all pending interests, you can simply use
getStorePendingInterest() for onDataNotFound. If onDataNotFound 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.public final void setInterestFilter(InterestFilter filter)
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.public final void setInterestFilter(Name prefix, OnInterestCallback onDataNotFound)
prefix
- The Name prefix used to match the name of an incoming
Interest. This copies the Name.onDataNotFound
- If a data packet for an interest is not found in the
cache, this forwards the interest by calling
onDataNotFound.onInterest(prefix, interest, face, interestFilterId, filter).
Your callback can find the Data packet for the interest and call
face.putData(data). Note: If you call setInterestFilter multiple times where
filter.getPrefix() is the same, it is undetermined which onDataNotFound
will be called. If your callback cannot find the Data packet, it can
optionally call storePendingInterest(interest, face) to store the pending
interest in this object to be satisfied by a later call to add(data). If
you want to automatically store all pending interests, you can simply use
getStorePendingInterest() for onDataNotFound. If onDataNotFound 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.public final void setInterestFilter(Name prefix)
prefix
- The Name prefix used to match the name of an incoming
Interest. This copies the Name.public final void unregisterAll()
public final void add(Data data)
data
- The Data packet object to put in the cache. This copies the
fields from the object.public final void storePendingInterest(Interest interest, Face face)
interest
- The Interest for which we don't have a Data packet yet. You
should not modify the interest after calling this.face
- The Face with the connection which received the interest. This
comes from the OnInterest callback.public final OnInterestCallback getStorePendingInterest()
public final void onInterest(Name prefix, Interest interest, Face face, long interestFilterId, InterestFilter filter)
OnInterestCallback
onInterest
in interface OnInterestCallback
prefix
- The Name prefix given to registerPrefix or setInterestFilter
(or directly to the InterestFilter constructor). NOTE: You must not change
the prefix object - if you need to change it then make a copy.interest
- The received interest.face
- You should call face.putData to supply a Data packet which
satisfies the Interest.interestFilterId
- The interest filter ID which can be used with
Face.unsetInterestFilter.filter
- The InterestFilter given to registerPrefix or
setInterestFilter, or the InterestFilter created from the Name prefix. The
first argument, prefix, is provided for convenience and is the same as
filter.getPrefix(). NOTE: You must not change the filter object - if you
need to change it then make a copy.Copyright © 2016. All rights reserved.