The low level interface to ccnd. More...
Classes | |
class | CCNDIdGetter |
class | Filter |
Record of a filter describing portion of namespace for which this application can respond to interests. More... | |
class | InterestRegistration |
Record of Interest listener must be set (non-null) for cases of standing Interest that holds until canceled by the application. More... | |
class | ListenerRegistration |
Generic superclass for registration objects that may have a listener Handles invalidation and pending delivery consistently to enable subclass to call listener callback without holding any library locks, yet avoid delivery to a cancelled listener. More... | |
class | PeriodicWriter |
Do scheduled interest and registration refreshes. | |
class | RegisteredPrefix |
Keep track of prefixes that are actually registered with ccnd (as opposed to Filters used to dispatch interests). More... | |
class | ReRegisterThread |
Public Types | |
enum | NetworkProtocol { UDP = (17), TCP = (6) } |
Definitions for which network protocol to use. More... | |
enum | StatsEnum { Puts = ("ContentObjects", "The number of put calls"), Gets = ("ContentObjects", "The number of get calls"), WriteInterest = ("calls", "The number of calls to write(Interest)"), WriteObject = ("calls", "The number of calls to write(ContentObject)"), WriteErrors = ("count", "Error count for writeInner()"), WriteUnderflows = ("count", "The count of times when the bytes written to the channel < buffer size"), ExpressInterest = ("calls", "The number of calls to expressInterest"), CancelInterest = ("calls", "The number of calls to cancelInterest"), DeliverInterest = ("calls", "The number of calls to deliverInterest"), DeliverContent = ("calls", "The number of calls to cancelInterest"), DeliverContentMatchingInterests = ("calls", "Count of the calls to threadpool.execute in handleData()"), DeliverContentFailed = ("calls", "The number of content deliveries that failed"), DeliverInterestFailed = ("calls", "The number of interest deliveries that failed"), ReceiveObject = ("objects", "Receive count of ContentObjects from channel"), ReceiveInterest = ("interests", "Receive count of Interests from channel"), ReceiveUnknown = ("calls", "Receive count of unknown type from channel"), ReceiveErrors = ("errors", "Number of errors from the channel in run() loop"), ContentObjectsIgnored = ("ContentObjects", "The number of ContentObjects that are never handled") } |
Public Member Functions | |
CCNNetworkManager (KeyManager keyManager) throws IOException | |
The constructor. | |
void | shutdown () |
Shutdown the connection to ccnd and all threads associated with this network manager. | |
NetworkProtocol | getProtocol () |
Get the protocol this network manager is using. | |
void | setTap (String pathname) throws IOException |
Turns on writing of all packets to a file for test/debug Overrides any previous setTap or environment/property setting. | |
PublisherPublicKeyDigest | getCCNDId () throws IOException |
Get the CCN Name of the 'ccnd' we're connected to. | |
KeyManager | getKeyManager () |
void | setKeyManager (KeyManager manager) |
ContentObject | put (ContentObject co) throws IOException, InterruptedException |
Write content to ccnd. | |
ContentObject | get (Interest interest, long timeout) throws IOException, InterruptedException |
get content matching an interest from ccnd. | |
void | expressInterest (Object caller, Interest interest, CCNInterestListener callbackListener) throws IOException |
We express interests to the ccnd and register them within the network manager. | |
void | cancelInterest (Object caller, Interest interest, CCNInterestListener callbackListener) |
Cancel this query with all the repositories we sent it to. | |
void | setInterestFilter (Object caller, ContentName filter, CCNFilterListener callbackListener) throws IOException |
Register a standing interest filter with callback to receive any matching interests seen. | |
void | setInterestFilter (Object caller, ContentName filter, CCNFilterListener callbackListener, Integer registrationFlags) throws IOException |
Register a standing interest filter with callback to receive any matching interests seen. | |
void | cancelInterestFilter (Object caller, ContentName filter, CCNFilterListener callbackListener) |
Unregister a standing interest filter. | |
void | write (Interest interest) throws ContentEncodingException |
Don't do this unless you know what you are doing! | |
void | run () |
Thread method: this thread will handle reading datagrams and starts threads to dispatch data to handlers registered for it. | |
CCNStats | getStats () |
Static Public Attributes | |
static final int | DEFAULT_AGENT_PORT = 9695 |
static final String | DEFAULT_AGENT_HOST = "localhost" |
static final String | PROP_AGENT_PORT = "ccn.agent.port" |
static final String | PROP_AGENT_HOST = "ccn.agent.host" |
static final String | PROP_TAP = "ccn.tap" |
static final String | ENV_TAP = "CCN_TAP" |
static final int | PERIOD = 2000 |
static final int | MAX_PERIOD = PERIOD * 8 |
static final String | KEEPALIVE_NAME = "/HereIAm" |
static final int | THREAD_LIFE = 8 |
static final int | MAX_PAYLOAD = 8800 |
static final boolean | DEFAULT_PREFIX_REG = true |
Protected Member Functions | |
void | finalize () throws Throwable |
RegisteredPrefix | getRegisteredPrefix (ContentName prefix) |
Merge prefixes so we only add a new one when it doesn't have a common ancestor already registered. | |
void | write (ContentObject data) throws ContentEncodingException |
void | deliverInterest (InterestRegistration ireg) |
Internal delivery of interests to pending filter listeners. | |
void | deliverData (ContentObject co) |
Deliver data to blocked getters and registered interests. | |
PublisherPublicKeyDigest | fetchCCNDId (CCNNetworkManager mgr, KeyManager keyManager) throws IOException |
String | formatMessage (String message) |
Protected Attributes | |
final int | _managerId |
final String | _managerIdString |
Integer | _faceID = null |
CCNDIdGetter | _getter = null |
Thread | _thread = null |
ThreadPoolExecutor | _threadpool = null |
CCNNetworkChannel | _channel = null |
boolean | _run = true |
FileOutputStream | _tapStreamOut = null |
FileOutputStream | _tapStreamIn = null |
long | _lastHeartbeat = 0 |
int | _port = DEFAULT_AGENT_PORT |
String | _host = DEFAULT_AGENT_HOST |
NetworkProtocol | _protocol = SystemConfiguration.AGENT_PROTOCOL |
KeyManager | _keyManager |
InterestTable < InterestRegistration > | _myInterests = new InterestTable<InterestRegistration>() |
InterestTable< Filter > | _myFilters = new InterestTable<Filter>() |
boolean | _usePrefixReg = DEFAULT_PREFIX_REG |
PrefixRegistrationManager | _prefixMgr = null |
Timer | _periodicTimer = null |
Object | _timersSetupLock = new Object() |
Boolean | _timersSetup = false |
TreeMap< ContentName, RegisteredPrefix > | _registeredPrefixes = new TreeMap<ContentName, RegisteredPrefix>() |
CCNEnumStats< StatsEnum > | _stats = new CCNEnumStats<StatsEnum>(StatsEnum.Puts) |
Static Protected Attributes | |
static final AtomicInteger | _managerIdCount = new AtomicInteger(0) |
static Integer | _idSyncer = new Integer(0) |
static PublisherPublicKeyDigest | _ccndId = null |
The low level interface to ccnd.
Connects to a ccnd. For UDP it must maintain the connection by sending heartbeats to it. Other functions include reading and writing interests and content to/from the ccnd, starting handler threads to feed interests and content to registered handlers, and refreshing unsatisfied interests.
This class attempts to notice when a ccnd has died and to reconnect to a ccnd when it is restarted.
It also handles the low level output "tap" functionality - this allows inspection or logging of all the communications with ccnd.
Starts a separate thread to listen to, decode and handle incoming data from ccnd.
Definitions for which network protocol to use.
This allows overriding the current default.
org.ccnx.ccn.impl.CCNNetworkManager.CCNNetworkManager | ( | KeyManager | keyManager | ) | throws IOException |
The constructor.
Attempts to connect to a ccnd at the currently specified port number
IOException | if the port is invalid |
void org.ccnx.ccn.impl.CCNNetworkManager.cancelInterest | ( | Object | caller, | |
Interest | interest, | |||
CCNInterestListener | callbackListener | |||
) |
Cancel this query with all the repositories we sent it to.
caller | must not be null | |
interest | ||
callbackListener |
void org.ccnx.ccn.impl.CCNNetworkManager.cancelInterestFilter | ( | Object | caller, | |
ContentName | filter, | |||
CCNFilterListener | callbackListener | |||
) |
Unregister a standing interest filter.
caller | must not be null | |
filter | currently registered filter | |
callbackListener | the CCNFilterListener registered to it |
void org.ccnx.ccn.impl.CCNNetworkManager.deliverData | ( | ContentObject | co | ) | [protected] |
Deliver data to blocked getters and registered interests.
co |
void org.ccnx.ccn.impl.CCNNetworkManager.deliverInterest | ( | InterestRegistration | ireg | ) | [protected] |
Internal delivery of interests to pending filter listeners.
ireg |
void org.ccnx.ccn.impl.CCNNetworkManager.expressInterest | ( | Object | caller, | |
Interest | interest, | |||
CCNInterestListener | callbackListener | |||
) | throws IOException |
We express interests to the ccnd and register them within the network manager.
caller | must not be null | |
interest | the interest | |
callbackListener | listener to callback on receipt of data |
IOException | on incorrect interest |
ContentObject org.ccnx.ccn.impl.CCNNetworkManager.get | ( | Interest | interest, | |
long | timeout | |||
) | throws IOException, InterruptedException |
get content matching an interest from ccnd.
Expresses an interest, waits for ccnd to return matching the data, then removes the interest and returns the data to the caller.
TODO should probably handle InterruptedException at this level instead of throwing it to higher levels
interest | the interest | |
timeout | time to wait for return in ms |
IOException | on incorrect interest data | |
InterruptedException | if process is interrupted during wait |
PublisherPublicKeyDigest org.ccnx.ccn.impl.CCNNetworkManager.getCCNDId | ( | ) | throws IOException |
Get the CCN Name of the 'ccnd' we're connected to.
IOException |
NetworkProtocol org.ccnx.ccn.impl.CCNNetworkManager.getProtocol | ( | ) |
Get the protocol this network manager is using.
RegisteredPrefix org.ccnx.ccn.impl.CCNNetworkManager.getRegisteredPrefix | ( | ContentName | prefix | ) | [protected] |
Merge prefixes so we only add a new one when it doesn't have a common ancestor already registered.
Must be called with _registeredPrefixes locked
We decided that if we are registering a prefix that already has another prefix that is an descendant of it registered, we won't bother to now deregister that prefix because it would be complicated to do that and doesn't hurt anything.
Notes on efficiency: First of all I'm not sure how important efficiency is in this routine because it may not be too common to have many different prefixes registered. Currently we search all prefixes until we see one that is past the one we want to register before deciding there are none that encapsulate it. There may be a more efficient way to code this that is still correct but I haven't come up with it.
prefix |
ContentObject org.ccnx.ccn.impl.CCNNetworkManager.put | ( | ContentObject | co | ) | throws IOException, InterruptedException |
Write content to ccnd.
co | the content |
TODO - code doesn't actually throw either of these exceptions but need to fix upper level code to compensate when they are removed.
IOException | ||
InterruptedException |
void org.ccnx.ccn.impl.CCNNetworkManager.setInterestFilter | ( | Object | caller, | |
ContentName | filter, | |||
CCNFilterListener | callbackListener, | |||
Integer | registrationFlags | |||
) | throws IOException |
Register a standing interest filter with callback to receive any matching interests seen.
Any interests whose prefix completely matches "filter" will be delivered to the listener. Also if this filter matches no currently registered prefixes, register its prefix with ccnd.
caller | must not be null | |
filter | ContentName containing prefix of interests to match | |
callbackListener | a CCNFilterListener | |
registrationFlags | to use for this registration. |
IOException |
void org.ccnx.ccn.impl.CCNNetworkManager.setInterestFilter | ( | Object | caller, | |
ContentName | filter, | |||
CCNFilterListener | callbackListener | |||
) | throws IOException |
Register a standing interest filter with callback to receive any matching interests seen.
Any interests whose prefix completely matches "filter" will be delivered to the listener. Also if this filter matches no currently registered prefixes, register its prefix with ccnd.
caller | must not be null | |
filter | ContentName containing prefix of interests to match | |
callbackListener | a CCNFilterListener |
IOException |
void org.ccnx.ccn.impl.CCNNetworkManager.setTap | ( | String | pathname | ) | throws IOException |
Turns on writing of all packets to a file for test/debug Overrides any previous setTap or environment/property setting.
Pass null to turn off tap.
pathname | name of tap file |
void org.ccnx.ccn.impl.CCNNetworkManager.write | ( | Interest | interest | ) | throws ContentEncodingException |
Don't do this unless you know what you are doing!
interest |
ContentEncodingException |