SyncActions.c File Reference

Part of CCNx Sync. More...

Go to the source code of this file.

Defines

#define M   1000000
#define StatsLine(XXX)

Enumerations

enum  SyncCompareState {
  SyncCompare_init, SyncCompare_preload, SyncCompare_busy, SyncCompare_waiting,
  SyncCompare_done
}
enum  SyncUpdateState {
  SyncUpdate_init, SyncUpdate_inserted, SyncUpdate_busy, SyncUpdate_error,
  SyncUpdate_done
}

Functions

static struct SyncActionDatanewActionData (enum SyncRegisterActionKind kind)
static void linkActionData (struct SyncRootStruct *root, struct SyncActionData *data)
static void delinkActionData (struct SyncActionData *data)
static int moveActionData (struct SyncActionData *data, enum SyncActionState dstState)
static struct SyncActionDatadestroyActionData (struct SyncActionData *data)
static char * getCmdStr (enum SyncRegisterActionKind kind)
static char * getKindStr (enum SyncRegisterActionKind kind)
static void setCovered (struct SyncHashCacheEntry *ce)
static int isCovered (struct SyncHashCacheEntry *ce)
static int compareHash (struct ccn_charbuf *hashX, struct ccn_charbuf *hashY)
static struct SyncNameAccumsortNames (struct SyncRootStruct *root, struct SyncNameAccum *src)
int reportExclude (struct SyncRootStruct *root, struct ccn_buf_decoder *d)
static struct ccn_charbufformatStats (struct SyncRootStruct *root, struct ccn_charbuf *cb)
static struct SyncNameAccumexclusionsFromHashList (struct SyncRootStruct *root, struct SyncHashInfoList *list)
static struct ccn_charbufconstructCommandPrefix (struct SyncRootStruct *root, enum SyncRegisterActionKind kind)
static struct SyncNodeCompositeextractNode (struct SyncRootStruct *root, struct ccn_upcall_info *info)
static int noteRemoteHash (struct SyncRootStruct *root, struct SyncHashCacheEntry *ce, int add)
static struct SyncHashInfoListchooseRemoteHash (struct SyncRootStruct *root)
static int fauxError (struct SyncBaseStruct *base)
static void destroyCompareData (struct SyncCompareData *data)
static void abortCompare (struct SyncCompareData *data, char *why)
static int extractBuf (struct ccn_charbuf *cb, struct SyncNodeComposite *nc, struct SyncNodeElem *ne)
static struct SyncHashCacheEntryensureRemoteEntry (struct SyncCompareData *data, const unsigned char *xp, ssize_t xs)
static struct SyncHashCacheEntrycacheEntryForElem (struct SyncCompareData *data, struct SyncNodeComposite *nc, struct SyncNodeElem *ne, int remote)
static int comparisonFailed (struct SyncCompareData *data, char *why, int line)
static int addNameFromCompare (struct SyncCompareData *data)
static int doPreload (struct SyncCompareData *data)
static int doComparison (struct SyncCompareData *data)
static int fetchStablePoint (struct SyncBaseStruct *base, ccnr_hwm *ptr)
static int storeStablePoint (struct SyncBaseStruct *base, ccnr_hwm point)
static int isRootStableEnough (struct SyncRootStruct *root, ccnr_hwm target)
static void purgeOldEntries (struct SyncRootStruct *root)
static int CompareAction (struct ccn_schedule *sched, void *clienth, struct ccn_scheduled_event *ev, int flags)
static void kickCompare (struct SyncCompareData *scd, struct SyncActionData *action)
static struct SyncHashCacheEntrynewNodeCommon (struct SyncRootStruct *root, struct SyncNodeAccum *nodes, struct SyncNodeComposite *nc)
static struct SyncHashCacheEntrynodeFromNodes (struct SyncRootStruct *root, struct SyncNodeAccum *na)
int SyncStartSliceEnum (struct SyncRootStruct *root)
 starts a slice enumeration for the root
static int HeartbeatAction (struct ccn_schedule *sched, void *clienth, struct ccn_scheduled_event *ev, int flags)
int SyncStartHeartbeat (struct SyncBaseStruct *base)
 starts a periodic wakeup that maintains state across all roots
enum ccn_upcall_res SyncRemoteFetchResponse (struct ccn_closure *selfp, enum ccn_upcall_kind kind, struct ccn_upcall_info *info)
int SyncStartNodeFetch (struct SyncRootStruct *root, struct SyncHashCacheEntry *ce, struct SyncCompareData *comp)
 starts a remote fetch of the given node, based on the hash comp may be NULL if this is not for a compare
int SyncStartContentFetch (struct SyncRootStruct *root, struct ccn_charbuf *name, struct SyncCompareData *comp)
 starts a remote fetch of the given name comp may be NULL if this is not for a compare
static struct SyncActionDataSyncFindAction (struct SyncRootStruct *root, enum SyncRegisterActionKind kind)
int SyncAddName (struct SyncBaseStruct *base, struct ccn_charbuf *name, ccnr_accession item)
 Adds the given name to any applicable roots.
static int findAndDeleteRoot (struct SyncBaseStruct *base, char *here, const unsigned char *hp, ssize_t hs)
int SyncHandleSlice (struct SyncBaseStruct *base, struct ccn_charbuf *name)
 Creates a new slice from a full name.
enum ccn_upcall_res SyncInterestArrived (struct ccn_closure *selfp, enum ccn_upcall_kind kind, struct ccn_upcall_info *info)
static int SyncRegisterInterest (struct SyncRootStruct *root, enum SyncRegisterActionKind kind)
int SyncRegisterInterests (struct SyncRootStruct *root)
 registers interests associated with the given root these include C1.S.RA (Root Advise) and C1.S.NF (Node Fetch) interests additional interests may be registered as the protocol evolves
enum ccn_upcall_res SyncRootAdviseResponse (struct ccn_closure *selfp, enum ccn_upcall_kind kind, struct ccn_upcall_info *info)
int SyncSendRootAdviseInterest (struct SyncRootStruct *root)
 send a root advise request for the given root only one at a time may be outstanding
static int MakeNodeFromNames (struct SyncUpdateData *ud, int split)
static int TryNodeSplit (struct SyncUpdateData *ud)
static int AddUpdateName (struct SyncUpdateData *ud, struct ccn_charbuf *name)
static int SyncTreeMergeNames (struct SyncTreeWorkerHead *head, struct SyncUpdateData *ud)
static int UpdateAction (struct ccn_schedule *sched, void *clienth, struct ccn_scheduled_event *ev, int flags)
int SyncUpdateRoot (struct SyncRootStruct *root)
 updates the root with the current root->namesToAdd
int SyncStartCompareAction (struct SyncRootStruct *root, struct ccn_charbuf *hashR)
 initiates a compare action with the given remote hash

Variables

static int cachePurgeTrigger = 60
static int cacheCleanBatch = 16
static int cacheCleanDelta = 8
static int adviseNeedReset = 1
static int updateStallDelta = 15
static int updateNeedDelta = 6
static int shortDelayMicros = 1000
static int compareAssumeBad = 20
static int nodeSplitTrigger = 4000
static int exclusionLimit = 1000
static int stableTimeTrig = 10
static int hashSplitTrigger = 17
static int namesYieldInc = 100
static int namesYieldMicros = 20*1000
static char * syncStableSuffix = "SyncStable"
static int syncScope = 2


Detailed Description

Part of CCNx Sync.

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1 as published by the Free Software Foundation. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

Definition in file SyncActions.c.


Define Documentation

#define M   1000000

#define StatsLine ( XXX   ) 

Value:

if (stats->XXX) \
pos += snprintf(s+pos, lim-pos, ", %s %ju", #XXX, (uintmax_t) stats->XXX);

Definition at line 378 of file SyncActions.c.

Referenced by formatStats().


Enumeration Type Documentation

Enumerator:
SyncCompare_init 
SyncCompare_preload 
SyncCompare_busy 
SyncCompare_waiting 
SyncCompare_done 

Definition at line 62 of file SyncActions.c.

Enumerator:
SyncUpdate_init 
SyncUpdate_inserted 
SyncUpdate_busy 
SyncUpdate_error 
SyncUpdate_done 

Definition at line 97 of file SyncActions.c.


Function Documentation

static void abortCompare ( struct SyncCompareData *  data,
char *  why 
) [static]

Definition at line 725 of file SyncActions.c.

Referenced by CompareAction(), and HeartbeatAction().

static int addNameFromCompare ( struct SyncCompareData *  data  )  [static]

Definition at line 842 of file SyncActions.c.

Referenced by doComparison().

static int AddUpdateName ( struct SyncUpdateData *  ud,
struct ccn_charbuf name 
) [static]

Definition at line 3067 of file SyncActions.c.

Referenced by SyncTreeMergeNames().

static struct SyncHashCacheEntry* cacheEntryForElem ( struct SyncCompareData *  data,
struct SyncNodeComposite nc,
struct SyncNodeElem ne,
int  remote 
) [static, read]

Definition at line 795 of file SyncActions.c.

Referenced by doComparison(), and doPreload().

static struct SyncHashInfoList* chooseRemoteHash ( struct SyncRootStruct root  )  [static, read]

Definition at line 646 of file SyncActions.c.

Referenced by HeartbeatAction().

static int CompareAction ( struct ccn_schedule *  sched,
void *  clienth,
struct ccn_scheduled_event ev,
int  flags 
) [static]

Definition at line 1281 of file SyncActions.c.

Referenced by kickCompare().

static int compareHash ( struct ccn_charbuf hashX,
struct ccn_charbuf hashY 
) [static]

Definition at line 299 of file SyncActions.c.

Referenced by abortCompare(), SyncStartNodeFetch(), and UpdateAction().

static int comparisonFailed ( struct SyncCompareData *  data,
char *  why,
int  line 
) [static]

Definition at line 835 of file SyncActions.c.

Referenced by doComparison().

static struct ccn_charbuf* constructCommandPrefix ( struct SyncRootStruct root,
enum SyncRegisterActionKind  kind 
) [static, read]

static void delinkActionData ( struct SyncActionData data  )  [static]

Definition at line 148 of file SyncActions.c.

Referenced by destroyActionData(), and moveActionData().

static struct SyncActionData* destroyActionData ( struct SyncActionData data  )  [static, read]

static void destroyCompareData ( struct SyncCompareData *  data  )  [static]

Definition at line 692 of file SyncActions.c.

Referenced by abortCompare(), and CompareAction().

static int doComparison ( struct SyncCompareData *  data  )  [static]

Definition at line 940 of file SyncActions.c.

Referenced by CompareAction().

static int doPreload ( struct SyncCompareData *  data  )  [static]

Definition at line 867 of file SyncActions.c.

Referenced by CompareAction().

static struct SyncHashCacheEntry* ensureRemoteEntry ( struct SyncCompareData *  data,
const unsigned char *  xp,
ssize_t  xs 
) [static, read]

Definition at line 779 of file SyncActions.c.

Referenced by cacheEntryForElem().

static struct SyncNameAccum* exclusionsFromHashList ( struct SyncRootStruct root,
struct SyncHashInfoList list 
) [static, read]

Definition at line 498 of file SyncActions.c.

Referenced by SyncSendRootAdviseInterest().

static int extractBuf ( struct ccn_charbuf cb,
struct SyncNodeComposite nc,
struct SyncNodeElem ne 
) [static]

Definition at line 770 of file SyncActions.c.

Referenced by doComparison(), and SyncTreeMergeNames().

static struct SyncNodeComposite* extractNode ( struct SyncRootStruct root,
struct ccn_upcall_info info 
) [static, read]

Definition at line 567 of file SyncActions.c.

Referenced by SyncRemoteFetchResponse(), and SyncRootAdviseResponse().

static int fauxError ( struct SyncBaseStruct base  )  [static]

Definition at line 675 of file SyncActions.c.

Referenced by SyncRemoteFetchResponse(), and SyncRootAdviseResponse().

static int fetchStablePoint ( struct SyncBaseStruct base,
ccnr_hwm ptr 
) [static]

Definition at line 1149 of file SyncActions.c.

Referenced by SyncStartHeartbeat().

static int findAndDeleteRoot ( struct SyncBaseStruct base,
char *  here,
const unsigned char *  hp,
ssize_t  hs 
) [static]

Definition at line 2212 of file SyncActions.c.

Referenced by SyncHandleSlice().

static struct ccn_charbuf* formatStats ( struct SyncRootStruct root,
struct ccn_charbuf cb 
) [static, read]

Definition at line 383 of file SyncActions.c.

Referenced by CompareAction(), getFile(), putFile(), SyncInterestArrived(), and UpdateAction().

static char* getCmdStr ( enum SyncRegisterActionKind  kind  )  [static]

Definition at line 236 of file SyncActions.c.

Referenced by constructCommandPrefix().

static char* getKindStr ( enum SyncRegisterActionKind  kind  )  [static]

Definition at line 252 of file SyncActions.c.

Referenced by SyncInterestArrived(), and SyncRegisterInterest().

static int HeartbeatAction ( struct ccn_schedule *  sched,
void *  clienth,
struct ccn_scheduled_event ev,
int  flags 
) [static]

Definition at line 1609 of file SyncActions.c.

Referenced by SyncStartHeartbeat().

static int isCovered ( struct SyncHashCacheEntry ce  )  [static]

Definition at line 289 of file SyncActions.c.

Referenced by doComparison(), SyncRemoteFetchResponse(), and SyncRootAdviseResponse().

static int isRootStableEnough ( struct SyncRootStruct root,
ccnr_hwm  target 
) [static]

Definition at line 1229 of file SyncActions.c.

Referenced by HeartbeatAction().

static void kickCompare ( struct SyncCompareData *  scd,
struct SyncActionData action 
) [static]

Definition at line 1431 of file SyncActions.c.

Referenced by SyncRemoteFetchResponse(), and SyncStartCompareAction().

static void linkActionData ( struct SyncRootStruct root,
struct SyncActionData data 
) [static]

static int MakeNodeFromNames ( struct SyncUpdateData *  ud,
int  split 
) [static]

Definition at line 2915 of file SyncActions.c.

Referenced by TryNodeSplit(), and UpdateAction().

static int moveActionData ( struct SyncActionData data,
enum SyncActionState  dstState 
) [static]

Definition at line 193 of file SyncActions.c.

Referenced by SyncRemoteFetchResponse().

static struct SyncActionData* newActionData ( enum SyncRegisterActionKind  kind  )  [static, read]

static struct SyncHashCacheEntry* newNodeCommon ( struct SyncRootStruct root,
struct SyncNodeAccum nodes,
struct SyncNodeComposite nc 
) [static, read]

Definition at line 1449 of file SyncActions.c.

Referenced by MakeNodeFromNames(), and nodeFromNodes().

static struct SyncHashCacheEntry* nodeFromNodes ( struct SyncRootStruct root,
struct SyncNodeAccum na 
) [static, read]

Definition at line 1515 of file SyncActions.c.

Referenced by UpdateAction().

static int noteRemoteHash ( struct SyncRootStruct root,
struct SyncHashCacheEntry ce,
int  add 
) [static]

Definition at line 596 of file SyncActions.c.

Referenced by SyncInterestArrived(), and SyncRootAdviseResponse().

static void purgeOldEntries ( struct SyncRootStruct root  )  [static]

Definition at line 1238 of file SyncActions.c.

Referenced by SyncInterestArrived().

int reportExclude ( struct SyncRootStruct root,
struct ccn_buf_decoder d 
)

Definition at line 350 of file SyncActions.c.

Referenced by SyncInterestArrived().

static void setCovered ( struct SyncHashCacheEntry ce  )  [static]

static struct SyncNameAccum* sortNames ( struct SyncRootStruct root,
struct SyncNameAccum src 
) [static, read]

Definition at line 313 of file SyncActions.c.

Referenced by exclusionsFromHashList().

static int storeStablePoint ( struct SyncBaseStruct base,
ccnr_hwm  point 
) [static]

Definition at line 1201 of file SyncActions.c.

Referenced by HeartbeatAction().

int SyncAddName ( struct SyncBaseStruct base,
struct ccn_charbuf name,
ccnr_accession  item 
)

Adds the given name to any applicable roots.

Use item == 0 to ignore accession number.

Returns:
< 0 for failure, number of additions to roots for success.

Definition at line 2163 of file SyncActions.c.

Referenced by SyncNotifyContent(), and SyncStartContentFetch().

static struct SyncActionData* SyncFindAction ( struct SyncRootStruct root,
enum SyncRegisterActionKind  kind 
) [static, read]

Definition at line 2153 of file SyncActions.c.

Referenced by SyncInterestArrived(), and SyncSendRootAdviseInterest().

int SyncHandleSlice ( struct SyncBaseStruct base,
struct ccn_charbuf name 
)

Creates a new slice from a full name.

The name must start with base->priv->sliceCmdPrefix.

Returns:
< 0 if an error occured, otherwise the new root number.

Definition at line 2258 of file SyncActions.c.

Referenced by SyncNotifyContent().

enum ccn_upcall_res SyncInterestArrived ( struct ccn_closure selfp,
enum ccn_upcall_kind  kind,
struct ccn_upcall_info info 
)

Definition at line 2377 of file SyncActions.c.

Referenced by SyncRegisterInterest().

static int SyncRegisterInterest ( struct SyncRootStruct root,
enum SyncRegisterActionKind  kind 
) [static]

Definition at line 2625 of file SyncActions.c.

Referenced by SyncRegisterInterests().

int SyncRegisterInterests ( struct SyncRootStruct root  ) 

registers interests associated with the given root these include C1.S.RA (Root Advise) and C1.S.NF (Node Fetch) interests additional interests may be registered as the protocol evolves

Returns:
< 0 for error, >= 0 for success

Definition at line 2662 of file SyncActions.c.

Referenced by SyncAddRoot().

enum ccn_upcall_res SyncRemoteFetchResponse ( struct ccn_closure selfp,
enum ccn_upcall_kind  kind,
struct ccn_upcall_info info 
)

Definition at line 1843 of file SyncActions.c.

Referenced by SyncStartContentFetch(), and SyncStartNodeFetch().

enum ccn_upcall_res SyncRootAdviseResponse ( struct ccn_closure selfp,
enum ccn_upcall_kind  kind,
struct ccn_upcall_info info 
)

Definition at line 2716 of file SyncActions.c.

Referenced by SyncSendRootAdviseInterest().

int SyncSendRootAdviseInterest ( struct SyncRootStruct root  ) 

send a root advise request for the given root only one at a time may be outstanding

Returns:
< 0 for error, >= 0 for OK

Definition at line 2848 of file SyncActions.c.

Referenced by HeartbeatAction(), and UpdateAction().

int SyncStartCompareAction ( struct SyncRootStruct root,
struct ccn_charbuf hashR 
)

initiates a compare action with the given remote hash

Returns:
< 0 for error, >= 0 for OK

Definition at line 3455 of file SyncActions.c.

Referenced by HeartbeatAction().

int SyncStartContentFetch ( struct SyncRootStruct root,
struct ccn_charbuf name,
struct SyncCompareData *  comp 
)

starts a remote fetch of the given name comp may be NULL if this is not for a compare

Returns:
< 0 for error, >= 0 for success

Definition at line 2095 of file SyncActions.c.

Referenced by CompareAction().

int SyncStartHeartbeat ( struct SyncBaseStruct base  ) 

starts a periodic wakeup that maintains state across all roots

Returns:
< 0 for error, >= 0 for success

Definition at line 1788 of file SyncActions.c.

Referenced by SyncInit().

int SyncStartNodeFetch ( struct SyncRootStruct root,
struct SyncHashCacheEntry ce,
struct SyncCompareData *  comp 
)

starts a remote fetch of the given node, based on the hash comp may be NULL if this is not for a compare

Returns:
< 0 for error, >= 0 for success

Definition at line 2018 of file SyncActions.c.

Referenced by doComparison(), and doPreload().

int SyncStartSliceEnum ( struct SyncRootStruct root  ) 

starts a slice enumeration for the root

Returns:
< 0 for error, 0 if some enumeration is busy, 1 for success

Definition at line 1578 of file SyncActions.c.

Referenced by HeartbeatAction(), and SyncNotifyContent().

static int SyncTreeMergeNames ( struct SyncTreeWorkerHead head,
struct SyncUpdateData *  ud 
) [static]

Definition at line 3086 of file SyncActions.c.

Referenced by UpdateAction().

int SyncUpdateRoot ( struct SyncRootStruct root  ) 

updates the root with the current root->namesToAdd

Returns:
< 0 for error, >= 0 for OK

Definition at line 3411 of file SyncActions.c.

Referenced by HeartbeatAction(), and testReadBuilder().

static int TryNodeSplit ( struct SyncUpdateData *  ud  )  [static]

Definition at line 2989 of file SyncActions.c.

Referenced by AddUpdateName().

static int UpdateAction ( struct ccn_schedule *  sched,
void *  clienth,
struct ccn_scheduled_event ev,
int  flags 
) [static]

Definition at line 3217 of file SyncActions.c.

Referenced by SyncUpdateRoot().


Variable Documentation

int adviseNeedReset = 1 [static]

int cacheCleanBatch = 16 [static]

Definition at line 45 of file SyncActions.c.

Referenced by HeartbeatAction().

int cacheCleanDelta = 8 [static]

Definition at line 46 of file SyncActions.c.

Referenced by HeartbeatAction().

int cachePurgeTrigger = 60 [static]

Definition at line 44 of file SyncActions.c.

Referenced by purgeOldEntries().

int compareAssumeBad = 20 [static]

Definition at line 51 of file SyncActions.c.

Referenced by HeartbeatAction().

int exclusionLimit = 1000 [static]

Definition at line 53 of file SyncActions.c.

Referenced by exclusionsFromHashList().

int hashSplitTrigger = 17 [static]

Definition at line 55 of file SyncActions.c.

Referenced by TryNodeSplit().

int namesYieldInc = 100 [static]

Definition at line 56 of file SyncActions.c.

Referenced by SyncTreeMergeNames(), and UpdateAction().

int namesYieldMicros = 20*1000 [static]

Definition at line 57 of file SyncActions.c.

Referenced by SyncTreeMergeNames(), and UpdateAction().

int nodeSplitTrigger = 4000 [static]

Definition at line 52 of file SyncActions.c.

Referenced by AddUpdateName(), newNodeCommon(), nodeFromNodes(), and TryNodeSplit().

int shortDelayMicros = 1000 [static]

Definition at line 50 of file SyncActions.c.

Referenced by CompareAction(), HeartbeatAction(), kickCompare(), and UpdateAction().

int stableTimeTrig = 10 [static]

Definition at line 54 of file SyncActions.c.

Referenced by HeartbeatAction().

int syncScope = 2 [static]

char* syncStableSuffix = "SyncStable" [static]

Definition at line 58 of file SyncActions.c.

Referenced by fetchStablePoint(), and storeStablePoint().

int updateNeedDelta = 6 [static]

Definition at line 49 of file SyncActions.c.

Referenced by HeartbeatAction().

int updateStallDelta = 15 [static]

Definition at line 48 of file SyncActions.c.

Referenced by HeartbeatAction().


Generated on Thu Feb 16 00:44:26 2012 for Content-Centric Networking in C by  doxygen 1.5.6