OpenClovis Logo

clCachedCkpt.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2002-2012 OpenClovis Solutions Inc. All Rights Reserved.
3  *
4  * This file is available under a commercial license from the
5  * copyright holder or the GNU General Public License Version 2.0.
6  *
7  * The source code for this program is not published or otherwise
8  * divested of its trade secrets, irrespective of what has been
9  * deposited with the U.S. Copyright office.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * General Public License for more details.
15  *
16  * For more information, see the file COPYING provided with this
17  * material.
18  */
19 
20 /*******************************************************************************
21  * ModuleName : ckpt
22  * File : clCachedCkpt.h
23  *******************************************************************************/
24 
25 /*******************************************************************************
26  * Description :
27  * This file contains essential definitions for the Cached Checkpoint
28  * which provides a fast lookup for a P2P generated database.
29  *
30  *
31  *******************************************************************************/
32 
45 #ifndef _CL_CACHED_CKPT_H_
46 #define _CL_CACHED_CKPT_H_
47 
48 #include <clCommon.h>
49 #include <clCommonErrors.h>
50 #include <clHash.h>
51 #include <clIocApi.h>
52 #include <clOsalApi.h>
53 #include <saCkpt.h>
54 #include <clCkptApi.h>
55 
56 #ifdef __cplusplus
57 extern "C"
58 {
59 #endif
60 
61 /*******************************************************************************/
62 #define CL_CACHED_CKPT_MAX_SECTION 1024
63 
64 #define CL_CACHED_CKPT_SHM_MODE (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)
65 #define CL_CACHED_CKPT_SHM_OPEN_FLAGS (O_RDWR)
66 #define CL_CACHED_CKPT_SHM_CREATE_FLAGS (O_RDWR | O_CREAT)
67 #define CL_CACHED_CKPT_SHM_EXCL_CREATE_FLAGS (O_RDWR | O_CREAT | O_EXCL)
68 #define CL_CACHED_CKPT_MMAP_FLAGS (MAP_SHARED)
69 #define CL_CACHED_CKPT_MMAP_PROT_FLAGS (PROT_READ | PROT_WRITE)
70 
74 typedef struct {
86  ClUint32T dataSize;
90  ClUint8T *data;
91 
93 
94 
95 
99 typedef struct {
103  ClInt32T fd;
111  SaCkptHandleT ckptSvcHandle;
115  SaCkptCheckpointHandleT ckptHandle;
119  ClUint32T cachSize;
123  ClUint8T *cache;
124 
128  ClCharT cacheName[CL_MAX_NAME_LENGTH];
129 
131 
132 /*******************************************************************************/
133 
134 /************************* CACHED CHECKPOINT APIs ******************************/
135 
174  const SaNameT *ckptName,
175  const SaCkptCheckpointCreationAttributesT *ckptAttributes,
176  SaCkptCheckpointOpenFlagsT openFlags,
177  ClUint32T cachSize);
178 /*******************************************************************************/
179 
180 
207 /*******************************************************************************/
208 
209 
242  const ClCachedCkptDataT *sectionData);
243 /*******************************************************************************/
244 
245 
277  const ClCachedCkptDataT *sectionData);
278 /*******************************************************************************/
279 
280 
311  const ClNameT *sectionName);
312 /*******************************************************************************/
313 
338  const ClNameT *sectionName,
339  ClCachedCkptDataT **sectionData);
340 
366  ClCachedCkptDataT **sectionData,
367  ClUint32T *sectionOffset);
368 
393  ClCachedCkptDataT **sectionData,
394  ClUint32T *sectionOffset);
395 
396 /*******************************************************************************/
397 
419 ClRcT clCachedCkptSynch(ClCachedCkptSvcInfoT *serviceInfo, ClBoolT isEmpty);
420 /*******************************************************************************/
421 
422 /* Functions to update cache */
423 ClRcT clCacheEntryAdd (ClCachedCkptSvcInfoT *serviceInfo,
424  const ClCachedCkptDataT *sectionData);
425 ClRcT clCacheEntryUpdate (ClCachedCkptSvcInfoT *serviceInfo,
426  const ClCachedCkptDataT *sectionData);
427 ClRcT clCacheEntryDelete (ClCachedCkptSvcInfoT *serviceInfo,
428  const ClNameT *sectionName);
429 
430 /*
431  * Append the data chunk to the last section
432  */
433 ClRcT clCacheEntryDataAppend(ClCachedCkptSvcInfoT *serviceInfo,
434  ClPtrT data,
435  ClUint32T dataSize);
436 
437 /*
438  * Delete a chunk from the last section matching a data chunk of dataSize
439  */
440 ClRcT clCacheEntryDataDelete(ClCachedCkptSvcInfoT *serviceInfo,
441  ClPtrT data,
442  ClUint32T dataSize);
443 
444 /* Functions to update checkpoint */
445 ClRcT clCkptEntryUpdate(ClCachedCkptSvcInfoT *serviceInfo,
446  const ClCachedCkptDataT *sectionData);
447 ClRcT clCkptEntryDelete(ClCachedCkptSvcInfoT *serviceInfo, const ClNameT *sectionName);
448 
449 /****************************Client Side APIs**************************/
453 typedef struct {
457  ClInt32T fd;
465  ClUint32T cachSize;
469  ClUint8T *cache;
471 
472 void clCachedCkptClientLookup(ClCachedCkptClientSvcInfoT *serviceInfo,
473  const ClNameT *sectionName,
474  ClCachedCkptDataT **sectionData);
475 ClRcT clCachedCkptClientInitialize(ClCachedCkptClientSvcInfoT *serviceInfo,
476  const ClNameT *ckptName,
477  ClUint32T cachSize);
478 ClRcT clCachedCkptClientFinalize(ClCachedCkptClientSvcInfoT *serviceInfo);
479 
480 
481 
482 #ifdef __cplusplus
483 }
484 #endif
485 
486 #endif /* _CL_CACHED_CKPT_H_ */
487 
Typical defines found in any software project.
Common Error Codes shared across multiple Clovis ASP Components.
Header file of Server based Checkpoint Service Related APIs.
Header file of Ioc Data Structures and APIs.
Operating System Abstraction Layer API.
ClUint32T ClRcT
Clovis return code type.
Definition: clCommon.h:168
#define CL_MAX_NAME_LENGTH
The Maximum length of most string names in the OpenClovis ASP framework.
Definition: clCommon.h:194
ClHandleT ClOsalSemIdT
The type of an identifier to the OSAL Semaphore ID.
Definition: clOsalApi.h:235
void clCachedCkptSectionGetNext(ClCachedCkptSvcInfoT *serviceInfo, ClCachedCkptDataT **sectionData, ClUint32T *sectionOffset)
Gets next section of the checkpoint.
void clCachedCkptSectionRead(ClCachedCkptSvcInfoT *serviceInfo, const ClNameT *sectionName, ClCachedCkptDataT **sectionData)
Reads a single section.
ClRcT clCachedCkptSectionUpdate(ClCachedCkptSvcInfoT *serviceInfo, const ClCachedCkptDataT *sectionData)
Updates a checkpoint section.
ClRcT clCachedCkptSectionCreate(ClCachedCkptSvcInfoT *serviceInfo, const ClCachedCkptDataT *sectionData)
Creates a section in the checkpoint.
ClRcT clCachedCkptInitialize(ClCachedCkptSvcInfoT *serviceInfo, const SaNameT *ckptName, const SaCkptCheckpointCreationAttributesT *ckptAttributes, SaCkptCheckpointOpenFlagsT openFlags, ClUint32T cachSize)
Initializes the Cached Checkpoint service.
void clCachedCkptSectionGetFirst(ClCachedCkptSvcInfoT *serviceInfo, ClCachedCkptDataT **sectionData, ClUint32T *sectionOffset)
Gets the first section of the checkpoint.
ClRcT clCachedCkptSectionDelete(ClCachedCkptSvcInfoT *serviceInfo, const ClNameT *sectionName)
Deletes a section in the checkpoint.
ClRcT clCachedCkptFinalize(ClCachedCkptSvcInfoT *serviceInfo)
Finalizes the Cached Checkpoint service.
ClRcT clCachedCkptSynch(ClCachedCkptSvcInfoT *serviceInfo, ClBoolT isEmpty)
Synchronizes the cache (local copy) with the checkpoint.
A name.
Definition: clCommon.h:197
The type of the CachedCkpt section data.
Definition: clCachedCkpt.h:74
ClIocAddressT sectionAddress
IOC address of the component "responsible" for this section.
Definition: clCachedCkpt.h:82
ClNameT sectionName
Name of the checkpoint section.
Definition: clCachedCkpt.h:78
ClUint8T * data
Data of the section.
Definition: clCachedCkpt.h:90
ClUint32T dataSize
Size of the section data.
Definition: clCachedCkpt.h:86
Cached Checkpoint global data structure.
Definition: clCachedCkpt.h:99
SaCkptHandleT ckptSvcHandle
Service handle used for checkpoint service.
Definition: clCachedCkpt.h:111
ClUint32T cachSize
Shared buffer size.
Definition: clCachedCkpt.h:119
ClUint8T * cache
Shared buffer.
Definition: clCachedCkpt.h:123
SaCkptCheckpointHandleT ckptHandle
Checkpoint handle.
Definition: clCachedCkpt.h:115
ClInt32T fd
File descriptor that refers to an open shared memory.
Definition: clCachedCkpt.h:103
ClOsalSemIdT cacheSem
Semaphore to protect Cached Checkpoint shared data.
Definition: clCachedCkpt.h:107
Client side data structure.
Definition: clCachedCkpt.h:453
ClUint32T cachSize
Shared buffer size.
Definition: clCachedCkpt.h:465
ClUint8T * cache
Shared buffer.
Definition: clCachedCkpt.h:469
ClInt32T fd
File descriptor that refers to an open shared memory.
Definition: clCachedCkpt.h:457
ClOsalSemIdT cacheSem
Semaphore to protect the shared memory.
Definition: clCachedCkpt.h:461
IOC address.
Definition: clIocApi.h:401

Generated on Tue Jan 10 10:29:15 PST 2012 for OpenClovis SDK using Doxygen