Manage splitting interests and generating interests for a single base name. More...
Classes | |
class | InterestMapData |
Public Types | |
enum | StatsEnum { Receive = ("ContentObjects", "The number of objects recieved in handleContent"), ReceiveVersionNumberError = ("Errors", "Errors parsing VersionNumber from content name"), ReceiveReturnInterest = ("interests", "Number of non-null interests returned from receive()"), ReceiveIgnored = ("count", "Count of objects ignored because version was out-of-bounds"), ReceiveDuplicates = ("count", "Count of duplicate version numbers received"), ReceiveUnique = ("count", "Count of objects with unique version numbers received"), ReceiveNoPendingInterest = ("Errors", "Received object did not match a pending interest in _interestMap"), Rebuild = ("count", "Calls to rebuild()"), RebuileShiftLeft = ("count", "Number of left-shift rebuilds"), RebuildShiftRight = ("count", "Number of right-shift rebuilds"), RebuildCreateLeft = ("count", "Number of create left neighbor rebuilds"), RebuildCreateRight = ("count", "Number of create right neighbor rebuilds"), RebuildInsertLeft = ("count", "Number of inserts to left rebuilds"), RebuildInsertRight = ("count", "Number of inserts to right rebuilds"), RebuildRollLeft = ("count", "Number of roll left rebuilds"), RebuildRollRight = ("count", "Number of roll right rebuilds"), SendInterest = ("count", "Interests sent (not counting ReceiveReturnInterest)"), CancelInterest = ("count", "Interests cancelled"), SendInterestErrors = ("errors", "Errors calling expressInterest()") } |
Public Member Functions | |
VersioningInterestManager (CCNHandle handle, ContentName name, Set< VersionNumber > exclusions, VersionNumber startingVersion, CCNInterestListener listener) | |
Create a VersioningInterestManager for a specific content name. | |
synchronized void | start () throws IOException |
Generate interests and return data to the listener. | |
synchronized void | stop () |
cancel all interests and stop operation | |
Interest | handleContent (ContentObject data, Interest interest) |
Callback called when we get new results for our query. | |
String | dumpExcluded () |
This is purely a debugging aid. | |
CCNStats | getStats () |
Static Public Attributes | |
static final int | MIN_FILL = 50 |
static final int | MID_FILL = 125 |
static final int | MAX_FILL = 200 |
Protected Member Functions | |
Interest | receive (ContentObject data, Interest interest) |
Called from handleInterest. | |
void | rebuild (VersionNumber version, InterestData datum) |
We received a new version and tried to add it to the given datum, but that datum is too full. | |
void | sendInterest (InterestData id) |
Send a new interest and manage the _interestMap. | |
Protected Attributes | |
final CCNHandle | _handle |
final Object | _dataLock = new Object() |
final TreeSet6< VersionNumber > | _exclusions = new TreeSet6<VersionNumber>() |
final TreeSet6< InterestData > | _interestData = new TreeSet6<InterestData>(new InterestData.StartTimeComparator()) |
final Map< Interest, InterestMapData > | _interestMap = new HashMap<Interest, InterestMapData>() |
CCNEnumStats< StatsEnum > | _stats = new CCNEnumStats<StatsEnum>(StatsEnum.Receive) |
Manage splitting interests and generating interests for a single base name.
This class is used by VersioningInterest, and should not be used stand-alone.
Current interest filling algorithm: Interests are filled to MIN_FULL exclusions initially and allowed to grow to MAX_FULL exclusions. When MAX_FULL exclusions is reached, the starting times are re-arranged.
This operates by maintaining a set of interests from [startingVersion, infinity). Initially, we issue one interest I_0[startingVersion, infinity). When that interest fills, it is split in to two interests, and it is split to the left: I_-1[startingVersion, k], I_0[k+1, infinity), where "k" is picked to keep MIN_FILL in the right member (I_0).
"infinity" is really the maximum version component, so it is well-defined.
At some point, we will have a series of interests: I0[startingVersion, k0], I1[k0+1, k1], I2[k1+1, k2], I3[k2+1, k3], I4[k3+1, infinity)
Algorithm:
Let the current InterestData be M[a, b].
org.ccnx.ccn.profiles.versioning.VersioningInterestManager.VersioningInterestManager | ( | CCNHandle | handle, | |
ContentName | name, | |||
Set< VersionNumber > | exclusions, | |||
VersionNumber | startingVersion, | |||
CCNInterestListener | listener | |||
) |
Create a VersioningInterestManager for a specific content name.
Send results to the listener.
handle | ||
name | ||
exclusions | may be null or empty | |
startingVersion | non-negative, use 0 for all versions | |
listener |
Interest org.ccnx.ccn.profiles.versioning.VersioningInterestManager.handleContent | ( | ContentObject | data, | |
Interest | interest | |||
) |
Callback called when we get new results for our query.
data | the ContentObject that matched our Interest | |
interest | Interest that was satisfied |
Implements org.ccnx.ccn.CCNInterestListener.
void org.ccnx.ccn.profiles.versioning.VersioningInterestManager.rebuild | ( | VersionNumber | version, | |
InterestData | datum | |||
) | [protected] |
We received a new version and tried to add it to the given datum, but that datum is too full.
we need to split the interest.
The strategy we use is to keep shifting left. If there is no interest to the left of datum, make one. If there is and it's full, rebuild it, then add our exclusion to the left.
handleContent is synchronized, and the only path to rebuild is from there, so we don't worry about locking too much.
datum | ||
version | may be null for a rebuild w/o insert |
Interest org.ccnx.ccn.profiles.versioning.VersioningInterestManager.receive | ( | ContentObject | data, | |
Interest | interest | |||
) | [protected] |
Called from handleInterest.
data | ||
interest |
void org.ccnx.ccn.profiles.versioning.VersioningInterestManager.sendInterest | ( | InterestData | id | ) | [protected] |
Send a new interest and manage the _interestMap.
If the InterestData has an old interest, we set the reexpress flag to false it in the map, so it will no longer cause a new interest to be sent and then add the new interest to the map, so when we receive an object for it, we'll issue a new interest.
Reimplemented in org.ccnx.ccn.test.profiles.versioning.VersioningHelper.TestVIM.
synchronized void org.ccnx.ccn.profiles.versioning.VersioningInterestManager.start | ( | ) | throws IOException |
Generate interests and return data to the listener.
IOException |