ccnr_store.c File Reference

Part of ccnr - CCNx Repository Daemon. More...

Go to the source code of this file.

Data Structures

struct  content_entry
 The content hash table is keyed by the initial portion of the ContentObject that contains all the parts of the complete name. More...

Defines

#define FAILIF(cond)   do {} while ((cond) && r_store_fatal(h, __func__, __LINE__))
#define CHKSYS(res)   FAILIF((res) == -1)
#define CHKRES(res)   FAILIF((res) < 0)
#define CHKPTR(p)   FAILIF((p) == NULL)
#define CCN_BT_CLEAN_BATCH   3
 Number of btree index writes to do in a batch.
#define CCN_BT_CLEAN_TICK_MICROS   65536
 Approximate delay between batches of btree index writes.

Functions

static int r_store_set_flatname (struct ccnr_handle *h, struct content_entry *content, struct ccn_parsed_ContentObject *pco)
 Parses content object and sets content->flatname.
static int r_store_content_btree_insert (struct ccnr_handle *h, struct content_entry *content, struct ccn_parsed_ContentObject *pco, ccnr_accession *accp)
static int r_store_fatal (struct ccnr_handle *h, const char *fn, int lineno)
PUBLIC ccnr_accession r_store_content_accession (struct ccnr_handle *h, struct content_entry *content)
PUBLIC ccnr_cookie r_store_content_cookie (struct ccnr_handle *h, struct content_entry *content)
PUBLIC size_t r_store_content_size (struct ccnr_handle *h, struct content_entry *content)
static off_t r_store_offset_from_accession (struct ccnr_handle *h, ccnr_accession a)
static unsigned r_store_repofile_from_accession (struct ccnr_handle *h, ccnr_accession a)
static const unsigned char * r_store_content_mapped (struct ccnr_handle *h, struct content_entry *content)
static const unsigned char * r_store_content_read (struct ccnr_handle *h, struct content_entry *content)
PUBLIC int r_store_content_trim (struct ccnr_handle *h, struct content_entry *content)
 If the content appears to be safely stored in the repository, removes any buffered copy.
PUBLIC void r_store_trim (struct ccnr_handle *h, unsigned long limit)
 Evict recoverable content from in-memory buffers.
PUBLIC const unsigned char * r_store_content_base (struct ccnr_handle *h, struct content_entry *content)
 Get the base address of the content object.
PUBLIC int r_store_name_append_components (struct ccn_charbuf *dst, struct ccnr_handle *h, struct content_entry *content, int skip, int count)
PUBLIC int r_store_content_flags (struct content_entry *content)
PUBLIC int r_store_content_change_flags (struct content_entry *content, int set, int clear)
static int r_store_write_stable_point (struct ccnr_handle *h)
 Write a file named index/stable that contains the size of repoFile1 when the repository is shut down.
static void r_store_read_stable_point (struct ccnr_handle *h)
 Read the former size of repoFile1 from index/stable, and remove the latter.
static int r_store_reindexing (struct ccn_schedule *sched, void *clienth, struct ccn_scheduled_event *ev, int flags)
 Log a bit if we are taking a while to re-index.
static unsigned choose_limit (unsigned l, unsigned m)
 Select power of 2 between l and m + 1 (if possible).
PUBLIC void r_store_init (struct ccnr_handle *h)
PUBLIC int r_store_final (struct ccnr_handle *h, int stable)
PUBLIC struct content_entryr_store_content_from_accession (struct ccnr_handle *h, ccnr_accession accession)
PUBLIC struct content_entryr_store_content_from_cookie (struct ccnr_handle *h, ccnr_cookie cookie)
PUBLIC ccnr_cookie r_store_enroll_content (struct ccnr_handle *h, struct content_entry *content)
 This makes a cookie for content, and, if it has an accession number already, enters it into the content_by_accession_tab.
PUBLIC void r_store_forget_content (struct ccnr_handle *h, struct content_entry **pentry)
 Remove internal representation of a content object.
static struct content_entryr_store_look (struct ccnr_handle *h, const unsigned char *key, size_t size)
 Get a handle on the content object that matches key, or if there is no match, the one that would come just after it.
PUBLIC struct content_entryr_store_find_first_match_candidate (struct ccnr_handle *h, const unsigned char *interest_msg, const struct ccn_parsed_interest *pi)
PUBLIC int r_store_content_matches_interest_prefix (struct ccnr_handle *h, struct content_entry *content, const unsigned char *interest_msg, size_t interest_size)
PUBLIC struct content_entryr_store_content_next (struct ccnr_handle *h, struct content_entry *content)
PUBLIC struct content_entryr_store_next_child_at_level (struct ccnr_handle *h, struct content_entry *content, int level)
PUBLIC struct content_entryr_store_lookup (struct ccnr_handle *h, const unsigned char *msg, const struct ccn_parsed_interest *pi, struct ccn_indexbuf *comps)
PUBLIC struct content_entryr_store_lookup_ccnb (struct ccnr_handle *h, const unsigned char *namish, size_t size)
 Find the first content handle that matches the prefix given by the namish, which may be a Name, Interest, ContentObject, .
PUBLIC void r_store_mark_stale (struct ccnr_handle *h, struct content_entry *content)
 Mark content as stale.
static int expire_content (struct ccn_schedule *sched, void *clienth, struct ccn_scheduled_event *ev, int flags)
 Scheduled event that makes content stale when its FreshnessSeconds has expired.
PUBLIC void r_store_set_content_timer (struct ccnr_handle *h, struct content_entry *content, struct ccn_parsed_ContentObject *pco)
 Schedules content expiration based on its FreshnessSeconds.
PUBLIC struct ccn_charbufr_store_content_flatname (struct ccnr_handle *h, struct content_entry *content)
 Get the flatname associated with content.
PUBLIC struct content_entryprocess_incoming_content (struct ccnr_handle *h, struct fdholder *fdholder, unsigned char *msg, size_t size)
PUBLIC int r_store_content_field_access (struct ccnr_handle *h, struct content_entry *content, enum ccn_dtag dtag, const unsigned char **bufp, size_t *sizep)
PUBLIC int r_store_set_accession_from_offset (struct ccnr_handle *h, struct content_entry *content, struct fdholder *fdholder, off_t offset)
PUBLIC void r_store_send_content (struct ccnr_handle *h, struct fdholder *fdholder, struct content_entry *content)
PUBLIC int r_store_commit_content (struct ccnr_handle *h, struct content_entry *content)
PUBLIC void ccnr_debug_content (struct ccnr_handle *h, int lineno, const char *msg, struct fdholder *fdholder, struct content_entry *content)
static int r_store_index_cleaner (struct ccn_schedule *sched, void *clienth, struct ccn_scheduled_event *ev, int flags)
PUBLIC void r_store_index_needs_cleaning (struct ccnr_handle *h)

Variables

static const unsigned char * bogon = NULL
const ccnr_accession r_store_mark_repoFile1 = ((ccnr_accession)1) << 48


Detailed Description

Part of ccnr - CCNx Repository Daemon.

Definition in file ccnr_store.c.


Define Documentation

#define CCN_BT_CLEAN_BATCH   3

Number of btree index writes to do in a batch.

Definition at line 1351 of file ccnr_store.c.

Referenced by r_store_index_cleaner().

#define CCN_BT_CLEAN_TICK_MICROS   65536

Approximate delay between batches of btree index writes.

Definition at line 1353 of file ccnr_store.c.

Referenced by r_store_index_cleaner(), and r_store_index_needs_cleaning().

#define CHKPTR (  )     FAILIF((p) == NULL)

Definition at line 93 of file ccnr_store.c.

#define CHKRES ( res   )     FAILIF((res) < 0)

Definition at line 92 of file ccnr_store.c.

#define CHKSYS ( res   )     FAILIF((res) == -1)

Definition at line 91 of file ccnr_store.c.

#define FAILIF ( cond   )     do {} while ((cond) && r_store_fatal(h, __func__, __LINE__))

Definition at line 90 of file ccnr_store.c.


Function Documentation

PUBLIC void ccnr_debug_content ( struct ccnr_handle h,
int  lineno,
const char *  msg,
struct fdholder fdholder,
struct content_entry content 
)

static unsigned choose_limit ( unsigned  l,
unsigned  m 
) [static]

Select power of 2 between l and m + 1 (if possible).

Definition at line 436 of file ccnr_store.c.

Referenced by r_store_init().

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

Scheduled event that makes content stale when its FreshnessSeconds has expired.

Definition at line 1081 of file ccnr_store.c.

PUBLIC struct content_entry* process_incoming_content ( struct ccnr_handle h,
struct fdholder fdholder,
unsigned char *  msg,
size_t  size 
) [read]

Definition at line 1180 of file ccnr_store.c.

PUBLIC int r_store_commit_content ( struct ccnr_handle h,
struct content_entry content 
)

PUBLIC ccnr_accession r_store_content_accession ( struct ccnr_handle h,
struct content_entry content 
)

Definition at line 108 of file ccnr_store.c.

Referenced by r_sync_enumerate(), r_sync_enumerate_action(), and r_sync_notify_content().

PUBLIC const unsigned char* r_store_content_base ( struct ccnr_handle h,
struct content_entry content 
)

Get the base address of the content object.

This may involve reading the object in. Caller should not assume that the address will stay valid after it relinquishes control, either by returning or by calling routines that might invalidate objects.

Definition at line 265 of file ccnr_store.c.

Referenced by load_policy(), r_match_consume_matching_interests(), r_proto_policy_update(), r_store_content_btree_insert(), r_store_content_field_access(), r_store_content_from_accession(), r_store_send_content(), r_store_set_content_timer(), r_store_set_flatname(), and r_sync_lookup().

static int r_store_content_btree_insert ( struct ccnr_handle h,
struct content_entry content,
struct ccn_parsed_ContentObject pco,
ccnr_accession accp 
) [static]

Returns:
2 if content was added to index, 1 if it was there but had no accession, 0 if it was already there, -1 for error

Definition at line 667 of file ccnr_store.c.

Referenced by process_incoming_content(), and r_store_content_from_accession().

PUBLIC int r_store_content_change_flags ( struct content_entry content,
int  set,
int  clear 
)

Definition at line 319 of file ccnr_store.c.

Referenced by r_store_commit_content().

PUBLIC ccnr_cookie r_store_content_cookie ( struct ccnr_handle h,
struct content_entry content 
)

PUBLIC int r_store_content_field_access ( struct ccnr_handle h,
struct content_entry content,
enum ccn_dtag  dtag,
const unsigned char **  bufp,
size_t *  sizep 
)

Definition at line 1226 of file ccnr_store.c.

PUBLIC int r_store_content_flags ( struct content_entry content  ) 

PUBLIC struct ccn_charbuf* r_store_content_flatname ( struct ccnr_handle h,
struct content_entry content 
) [read]

Get the flatname associated with content.

Returns:
flatname in a charbuf, which should be treated as read-only.

Definition at line 1174 of file ccnr_store.c.

Referenced by r_sync_enumerate_action().

PUBLIC struct content_entry* r_store_content_from_accession ( struct ccnr_handle h,
ccnr_accession  accession 
) [read]

Definition at line 578 of file ccnr_store.c.

Referenced by process_incoming_content(), r_store_lookup(), and r_sync_enumerate_action().

PUBLIC struct content_entry* r_store_content_from_cookie ( struct ccnr_handle h,
ccnr_cookie  cookie 
) [read]

static const unsigned char* r_store_content_mapped ( struct ccnr_handle h,
struct content_entry content 
) [static]

Definition at line 140 of file ccnr_store.c.

Referenced by r_store_content_base().

PUBLIC int r_store_content_matches_interest_prefix ( struct ccnr_handle h,
struct content_entry content,
const unsigned char *  interest_msg,
size_t  interest_size 
)

PUBLIC struct content_entry* r_store_content_next ( struct ccnr_handle h,
struct content_entry content 
) [read]

Definition at line 904 of file ccnr_store.c.

Referenced by r_store_lookup(), and r_sync_enumerate_action().

static const unsigned char* r_store_content_read ( struct ccnr_handle h,
struct content_entry content 
) [static]

Definition at line 146 of file ccnr_store.c.

Referenced by r_store_content_base().

PUBLIC size_t r_store_content_size ( struct ccnr_handle h,
struct content_entry content 
)

PUBLIC int r_store_content_trim ( struct ccnr_handle h,
struct content_entry content 
)

If the content appears to be safely stored in the repository, removes any buffered copy.

Returns:
0 if buffer was removed, -1 if not.

Definition at line 216 of file ccnr_store.c.

Referenced by r_store_trim().

PUBLIC ccnr_cookie r_store_enroll_content ( struct ccnr_handle h,
struct content_entry content 
)

This makes a cookie for content, and, if it has an accession number already, enters it into the content_by_accession_tab.

Does not index by name.

Definition at line 636 of file ccnr_store.c.

Referenced by process_incoming_content(), r_store_content_from_accession(), and r_store_look().

static int r_store_fatal ( struct ccnr_handle h,
const char *  fn,
int  lineno 
) [static]

Definition at line 96 of file ccnr_store.c.

PUBLIC int r_store_final ( struct ccnr_handle h,
int  stable 
)

Definition at line 566 of file ccnr_store.c.

Referenced by r_init_destroy().

PUBLIC struct content_entry* r_store_find_first_match_candidate ( struct ccnr_handle h,
const unsigned char *  interest_msg,
const struct ccn_parsed_interest pi 
) [read]

Definition at line 825 of file ccnr_store.c.

Referenced by r_proto_begin_enumeration(), r_store_lookup(), and r_sync_enumerate().

PUBLIC void r_store_forget_content ( struct ccnr_handle h,
struct content_entry **  pentry 
)

Remove internal representation of a content object.

Definition at line 730 of file ccnr_store.c.

Referenced by process_incoming_content(), r_store_content_from_accession(), and r_store_enroll_content().

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

Definition at line 1355 of file ccnr_store.c.

Referenced by r_store_index_needs_cleaning().

PUBLIC void r_store_index_needs_cleaning ( struct ccnr_handle h  ) 

Definition at line 1450 of file ccnr_store.c.

Referenced by r_store_content_btree_insert(), r_store_init(), and r_store_trim().

PUBLIC void r_store_init ( struct ccnr_handle h  ) 

Definition at line 448 of file ccnr_store.c.

Referenced by r_init_create().

static struct content_entry* r_store_look ( struct ccnr_handle h,
const unsigned char *  key,
size_t  size 
) [static, read]

Get a handle on the content object that matches key, or if there is no match, the one that would come just after it.

The key is in flatname format.

Definition at line 780 of file ccnr_store.c.

Referenced by r_store_content_next(), r_store_find_first_match_candidate(), r_store_lookup_ccnb(), and r_store_next_child_at_level().

PUBLIC struct content_entry* r_store_lookup ( struct ccnr_handle h,
const unsigned char *  msg,
const struct ccn_parsed_interest pi,
struct ccn_indexbuf comps 
) [read]

Definition at line 956 of file ccnr_store.c.

Referenced by r_proto_answer_req(), r_proto_start_write_checked(), and r_sync_lookup().

PUBLIC struct content_entry* r_store_lookup_ccnb ( struct ccnr_handle h,
const unsigned char *  namish,
size_t  size 
) [read]

Find the first content handle that matches the prefix given by the namish, which may be a Name, Interest, ContentObject, .

..

Does not check the other parts of namish, in particular, does not generate the digest component of a ContentObject.

Definition at line 1030 of file ccnr_store.c.

Referenced by load_policy(), and r_proto_policy_update().

PUBLIC void r_store_mark_stale ( struct ccnr_handle h,
struct content_entry content 
)

Mark content as stale.

Definition at line 1061 of file ccnr_store.c.

Referenced by expire_content().

PUBLIC int r_store_name_append_components ( struct ccn_charbuf dst,
struct ccnr_handle h,
struct content_entry content,
int  skip,
int  count 
)

PUBLIC struct content_entry* r_store_next_child_at_level ( struct ccnr_handle h,
struct content_entry content,
int  level 
) [read]

Definition at line 915 of file ccnr_store.c.

Referenced by r_proto_continue_enumeration(), and r_store_lookup().

static off_t r_store_offset_from_accession ( struct ccnr_handle h,
ccnr_accession  a 
) [static]

Definition at line 126 of file ccnr_store.c.

Referenced by r_store_content_read().

static void r_store_read_stable_point ( struct ccnr_handle h  )  [static]

Read the former size of repoFile1 from index/stable, and remove the latter.

Definition at line 366 of file ccnr_store.c.

Referenced by r_store_init().

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

Log a bit if we are taking a while to re-index.

Definition at line 411 of file ccnr_store.c.

Referenced by r_store_init().

static unsigned r_store_repofile_from_accession ( struct ccnr_handle h,
ccnr_accession  a 
) [static]

Definition at line 132 of file ccnr_store.c.

Referenced by r_store_content_read().

PUBLIC void r_store_send_content ( struct ccnr_handle h,
struct fdholder fdholder,
struct content_entry content 
)

Definition at line 1297 of file ccnr_store.c.

Referenced by r_link_send_content(), and r_store_commit_content().

PUBLIC int r_store_set_accession_from_offset ( struct ccnr_handle h,
struct content_entry content,
struct fdholder fdholder,
off_t  offset 
)

Definition at line 1252 of file ccnr_store.c.

Referenced by process_input_message(), and r_store_send_content().

PUBLIC void r_store_set_content_timer ( struct ccnr_handle h,
struct content_entry content,
struct ccn_parsed_ContentObject pco 
)

Schedules content expiration based on its FreshnessSeconds.

Definition at line 1102 of file ccnr_store.c.

Referenced by process_incoming_content().

static int r_store_set_flatname ( struct ccnr_handle h,
struct content_entry content,
struct ccn_parsed_ContentObject pco 
) [static]

Parses content object and sets content->flatname.

Definition at line 1133 of file ccnr_store.c.

Referenced by process_incoming_content(), and r_store_content_from_accession().

PUBLIC void r_store_trim ( struct ccnr_handle h,
unsigned long  limit 
)

Evict recoverable content from in-memory buffers.

Definition at line 230 of file ccnr_store.c.

Referenced by r_dispatch_run(), and r_init_create().

static int r_store_write_stable_point ( struct ccnr_handle h  )  [static]

Write a file named index/stable that contains the size of repoFile1 when the repository is shut down.

Definition at line 332 of file ccnr_store.c.

Referenced by r_store_final().


Variable Documentation

const unsigned char* bogon = NULL [static]

Definition at line 79 of file ccnr_store.c.

Referenced by r_store_content_base().

Definition at line 1249 of file ccnr_store.c.

Referenced by r_store_set_accession_from_offset().


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