ChronoSync2013 implements the NDN ChronoSync protocol as described in the 2013 paper "Let's ChronoSync: Decentralized Dataset State Synchronization in
Named Data Networking".
More...
#include <chrono-sync2013.hpp>
|
class | SyncState |
| A SyncState holds the values of a sync state message which is passed to the onReceivedSyncState callback which was given to the ChronoSyn2013 constructor. More...
|
|
|
typedef func_lib::function< void(const std::vector< ChronoSync2013::SyncState > &syncStates, bool isRecovery)> | OnReceivedSyncState |
|
typedef func_lib::function< void()> | OnInitialized |
|
|
| ChronoSync2013 (const OnReceivedSyncState &onReceivedSyncState, const OnInitialized &onInitialized, const Name &applicationDataPrefix, const Name &applicationBroadcastPrefix, int sessionNo, Face &face, KeyChain &keyChain, const Name &certificateName, Milliseconds syncLifetime, const OnRegisterFailed &onRegisterFailed) |
| Create a new ChronoSync2013 to communicate using the given face. More...
|
|
int | getProducerSequenceNo (const std::string &dataPrefix, int sessionNo) const |
| Get the current sequence number in the digest tree for the given producer dataPrefix and sessionNo. More...
|
|
void | publishNextSequenceNo () |
| Increment the sequence number, create a sync message with the new sequence number and publish a data packet where the name is the applicationBroadcastPrefix + the root digest of the current digest tree. More...
|
|
int | getSequenceNo () const |
| Get the sequence number of the latest data published by this application instance. More...
|
|
void | shutdown () |
| Unregister callbacks so that this does not respond to interests anymore. More...
|
|
ChronoSync2013 implements the NDN ChronoSync protocol as described in the 2013 paper "Let's ChronoSync: Decentralized Dataset State Synchronization in
Named Data Networking".
http://named-data.net/publications/chronosync .
- Note
- The support for ChronoSync is experimental and the API is not finalized. See the API docs for more detail at http://named-data.net/doc/ndn-ccl-api/chrono-sync2013.html .
ndn::ChronoSync2013::ChronoSync2013 |
( |
const OnReceivedSyncState & |
onReceivedSyncState, |
|
|
const OnInitialized & |
onInitialized, |
|
|
const Name & |
applicationDataPrefix, |
|
|
const Name & |
applicationBroadcastPrefix, |
|
|
int |
sessionNo, |
|
|
Face & |
face, |
|
|
KeyChain & |
keyChain, |
|
|
const Name & |
certificateName, |
|
|
Milliseconds |
syncLifetime, |
|
|
const OnRegisterFailed & |
onRegisterFailed |
|
) |
| |
|
inline |
Create a new ChronoSync2013 to communicate using the given face.
Initialize the digest log with a digest of "00" and and empty content. Register the applicationBroadcastPrefix to receive interests for sync state messages and express an interest for the initial root digest "00".
- Note
- Your application must call processEvents. Since processEvents modifies the internal ChronoSync data structures, your application should make sure that it calls processEvents in the same thread as this constructor (which also modifies the data structures).
- Parameters
-
onReceivedSyncState | When ChronoSync receives a sync state message, this calls onReceivedSyncState(syncStates, isRecovery) where syncStates is the list of SyncState messages and isRecovery is true if this is the initial list of SyncState messages or from a recovery interest. (For example, if isRecovery is true, a chat application would not want to re-display all the associated chat messages.) The callback should send interests to fetch the application data for the sequence numbers in the sync state. 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. |
onInitialized | This calls onInitialized() when the first sync data is received (or the interest times out because there are no other publishers yet). 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. |
applicationDataPrefix | The prefix used by this application instance for application data. For example, "/my/local/prefix/ndnchat4/0K4wChff2v". This is used when sending a sync message for a new sequence number. In the sync message, this uses applicationDataPrefix.toUri(). |
applicationBroadcastPrefix | The broadcast name prefix including the application name. For example, "/ndn/broadcast/ChronoChat-0.3/ndnchat1". This makes a copy of the name. |
sessionNo | The session number used with the applicationDataPrefix in sync state messages. |
face | The Face for calling registerPrefix and expressInterest. The Face object must remain valid for the life of this ChronoSync2013 object. |
keyChain | To sign a data packet containing a sync state message, this calls keyChain.sign(data, certificateName). |
certificateName | The certificate name of the key to use for signing a data packet containing a sync state message. |
syncLifetime | The interest lifetime in milliseconds for sending sync interests. |
onRegisterFailed | If failed to register the prefix to receive interests for the applicationBroadcastPrefix, this calls onRegisterFailed(applicationBroadcastPrefix). 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. |
int ndn::ChronoSync2013::getProducerSequenceNo |
( |
const std::string & |
dataPrefix, |
|
|
int |
sessionNo |
|
) |
| const |
|
inline |
Get the current sequence number in the digest tree for the given producer dataPrefix and sessionNo.
- Parameters
-
dataPrefix | The producer data prefix as a Name URI string. |
sessionNo | The producer session number. |
- Returns
- The current producer sequence number, or -1 if the producer namePrefix and sessionNo are not in the digest tree.
int ndn::ChronoSync2013::getSequenceNo |
( |
| ) |
const |
|
inline |
Get the sequence number of the latest data published by this application instance.
- Returns
- The sequence number.
void ndn::ChronoSync2013::publishNextSequenceNo |
( |
| ) |
|
|
inline |
Increment the sequence number, create a sync message with the new sequence number and publish a data packet where the name is the applicationBroadcastPrefix + the root digest of the current digest tree.
Then add the sync message to the digest tree and digest log which creates a new root digest. Finally, express an interest for the next sync update with the name applicationBroadcastPrefix + the new root digest. After this, your application should publish the content for the new sequence number. You can get the new sequence number with getSequenceNo().
- Note
- Your application must call processEvents. Since processEvents modifies the internal ChronoSync data structures, your application should make sure that it calls processEvents in the same thread as publishNextSequenceNo() (which also modifies the data structures).
void ndn::ChronoSync2013::shutdown |
( |
| ) |
|
|
inline |
Unregister callbacks so that this does not respond to interests anymore.
If you will delete this ChronoSync2013 object while your application is still running, you should call shutdown() first. After calling this, you should not call publishNextSequenceNo() again since the behavior will be undefined.
- Note
- Because this modifies internal ChronoSync data structures, your application should make sure that it calls processEvents in the same thread as shutdown() (which also modifies the data structures).
The documentation for this class was generated from the following file: