defect 245 - revise checkpoint service to B.01.01.

(Logical change 1.135)


git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@485 fd59a12c-fef9-0310-b244-a6a79926bd2f
This commit is contained in:
Steven Dake 2005-02-08 20:56:38 +00:00
parent c9bdb3aedd
commit c32d4f3fd5
15 changed files with 855 additions and 1132 deletions

File diff suppressed because it is too large Load Diff

View File

@ -32,7 +32,7 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "../include/ais_types.h"
#include "../include/ais_msg.h"
#include "../include/saCkpt.h"
#include "aispoll.h"
#include "parse.h"
@ -70,15 +70,10 @@ struct saCkptSectionIterator {
};
struct libckpt_ci {
struct saCkptCheckpoint *checkpoint;
SaCkptCheckpointOpenFlagsT checkpointOpenFlags;
struct list_head checkpoint_list;
struct saCkptSectionIterator sectionIterator;
};
extern struct service_handler ckpt_service_handler;
extern struct service_handler ckpt_checkpoint_service_handler;
extern struct service_handler ckpt_sectioniterator_service_handler;
#endif /* CKPT_H_DEFINED */

View File

@ -87,12 +87,10 @@ struct service_handler *ais_service_handlers[] = {
&clm_service_handler,
&amf_service_handler,
&ckpt_service_handler,
&ckpt_checkpoint_service_handler,
&ckpt_sectioniterator_service_handler,
&evt_service_handler
};
#define AIS_SERVICE_HANDLERS_COUNT 7
#define AIS_SERVICE_HANDLERS_COUNT 5
#define AIS_SERVICE_HANDLER_AISEXEC_FUNCTIONS_MAX 40
static int poll_handler_libais_deliver (poll_handle handle, int fd, int revent, void *data, unsigned int *prio);

View File

@ -58,8 +58,6 @@ enum socket_service_type {
SOCKET_SERVICE_CLM,
SOCKET_SERVICE_AMF,
SOCKET_SERVICE_CKPT,
SOCKET_SERVICE_CKPT_CHECKPOINT,
SOCKET_SERVICE_CKPT_SECTIONITERATOR,
SOCKET_SERVICE_EVT
};

View File

@ -101,60 +101,6 @@ enum res_lib_amf_types {
MESSAGE_RES_AMF_RESPONSE
};
enum req_lib_ckpt_checkpoint_types {
MESSAGE_REQ_CKPT_CHECKPOINT_CHECKPOINTOPEN = 1,
MESSAGE_REQ_CKPT_CHECKPOINT_CHECKPOINTOPENASYNC,
MESSAGE_REQ_CKPT_CHECKPOINT_CHECKPOINTUNLINK,
MESSAGE_REQ_CKPT_CHECKPOINT_CHECKPOINTRETENTIONDURATIONSET,
MESSAGE_REQ_CKPT_CHECKPOINT_ACTIVECHECKPOINTSET,
MESSAGE_REQ_CKPT_CHECKPOINT_CHECKPOINTSTATUSGET,
MESSAGE_REQ_CKPT_CHECKPOINT_SECTIONCREATE,
MESSAGE_REQ_CKPT_CHECKPOINT_SECTIONDELETE,
MESSAGE_REQ_CKPT_CHECKPOINT_SECTIONEXPIRATIONTIMESET,
MESSAGE_REQ_CKPT_CHECKPOINT_SECTIONWRITE,
MESSAGE_REQ_CKPT_CHECKPOINT_SECTIONOVERWRITE,
MESSAGE_REQ_CKPT_CHECKPOINT_SECTIONREAD,
MESSAGE_REQ_CKPT_CHECKPOINT_CHECKPOINTSYNCHRONIZE,
MESSAGE_REQ_CKPT_CHECKPOINT_CHECKPOINTSYNCHRONIZEASYNC
};
enum req_lib_ckpt_sectioniterator_types {
MESSAGE_REQ_CKPT_SECTIONITERATOR_SECTIONITERATORINITIALIZE = 1,
MESSAGE_REQ_CKPT_SECTIONITERATOR_SECTIONITERATORNEXT
};
enum res_lib_ckpt_types {
MESSAGE_RES_CKPT_CHECKPOINTOPENASYNC = 1,
MESSAGE_RES_CKPT_CHECKPOINTSYNCHRONIZEASYNC
};
enum res_lib_ckpt_checkpoint_types {
MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTOPEN = 1,
MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTOPENASYNC,
MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTUNLINK,
MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTRETENTIONDURATIONSET,
MESSAGE_RES_CKPT_CHECKPOINT_ACTIVECHECKPOINTSET,
MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTSTATUSGET,
MESSAGE_RES_CKPT_CHECKPOINT_SECTIONCREATE,
MESSAGE_RES_CKPT_CHECKPOINT_SECTIONDELETE,
MESSAGE_RES_CKPT_CHECKPOINT_SECTIONEXPIRATIONTIMESET,
MESSAGE_RES_CKPT_CHECKPOINT_SECTIONWRITE,
MESSAGE_RES_CKPT_CHECKPOINT_SECTIONOVERWRITE,
MESSAGE_RES_CKPT_CHECKPOINT_SECTIONREAD,
MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTSYNCHRONIZE,
MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTSYNCHRONIZEASYNC
};
enum res_lib_ckpt_sectioniterator_types {
MESSAGE_RES_CKPT_SECTIONITERATOR_SECTIONITERATORINITIALIZE = 1,
MESSAGE_RES_CKPT_SECTIONITERATOR_SECTIONITERATORNEXT
};
struct message_source {
struct conn_info *conn_info;
struct in_addr in_addr;
} __attribute__((packed));
struct res_evs_deliver_callback {
struct res_header header;
struct in_addr source_addr;
@ -305,23 +251,6 @@ struct req_exec_amf_hastateset {
SaAmfHAStateT haState;
};
struct req_exec_ckpt_checkpointclose {
struct req_header header;
SaNameT checkpointName;
};
struct req_exec_ckpt_checkpointretentiondurationset {
struct req_header header;
struct message_source source;
SaNameT checkpointName;
SaTimeT retentionDuration;
};
struct req_exec_ckpt_checkpointretentiondurationexpire {
struct req_header header;
SaNameT checkpointName;
};
struct res_lib_amf_componentterminatecallback {
struct res_header header;
SaInvocationT invocation;
@ -462,226 +391,4 @@ struct res_lib_activatepoll {
struct res_header header;
};
struct req_lib_ckpt_checkpointopen {
struct req_header header;
SaNameT checkpointName;
SaCkptCheckpointCreationAttributesT checkpointCreationAttributes;
SaCkptCheckpointOpenFlagsT checkpointOpenFlags;
};
struct res_lib_ckpt_checkpointopen {
struct res_header header;
};
struct req_exec_ckpt_checkpointopen {
struct req_header header;
struct message_source source;
struct req_lib_ckpt_checkpointopen req_lib_ckpt_checkpointopen;
};
struct req_lib_ckpt_checkpointopenasync {
struct req_header header;
SaNameT checkpointName;
SaCkptCheckpointCreationAttributesT checkpointCreationAttributes;
SaCkptCheckpointOpenFlagsT checkpointOpenFlags;
SaInvocationT invocation;
};
struct res_lib_ckpt_checkpointopenasync {
struct res_header header;
SaCkptCheckpointHandleT checkpointHandle;
SaInvocationT invocation;
};
struct req_lib_ckpt_checkpointclose {
struct req_header header;
};
struct res_lib_ckpt_checkpointclose {
struct res_header header;
SaNameT checkpointName;
};
struct req_lib_ckpt_checkpointunlink {
struct req_header header;
SaNameT checkpointName;
};
struct res_lib_ckpt_checkpointunlink {
struct res_header header;
};
struct req_exec_ckpt_checkpointunlink {
struct req_header header;
struct message_source source;
struct req_lib_ckpt_checkpointunlink req_lib_ckpt_checkpointunlink;
};
struct req_lib_ckpt_checkpointretentiondurationset {
struct req_header header;
SaTimeT retentionDuration;
};
struct res_lib_ckpt_checkpointretentiondurationset {
struct res_header header;
};
struct req_lib_ckpt_activecheckpointset {
struct req_header header;
};
struct res_lib_ckpt_activecheckpointset {
struct res_header header;
};
struct req_lib_ckpt_checkpointstatusget {
struct req_header header;
};
struct res_lib_ckpt_checkpointstatusget {
struct res_header header;
SaCkptCheckpointStatusT checkpointStatus;
};
struct req_lib_ckpt_sectioncreate {
struct req_header header;
SaUint32T idLen;
SaTimeT expirationTime;
SaUint32T initialDataSize;
};
struct res_lib_ckpt_sectioncreate {
struct res_header header;
};
struct req_exec_ckpt_sectioncreate {
struct req_header header;
struct message_source source;
SaNameT checkpointName;
struct req_lib_ckpt_sectioncreate req_lib_ckpt_sectioncreate; /* this must be last */
};
struct req_lib_ckpt_sectiondelete {
struct req_header header;
SaUint32T idLen;
};
struct res_lib_ckpt_sectiondelete {
struct res_header header;
};
struct req_exec_ckpt_sectiondelete {
struct req_header header;
struct message_source source;
SaNameT checkpointName;
struct req_lib_ckpt_sectiondelete req_lib_ckpt_sectiondelete; /* this must be last */
};
struct req_lib_ckpt_sectionexpirationtimeset {
struct req_header header;
SaUint32T idLen;
SaTimeT expirationTime;
};
struct res_lib_ckpt_sectionexpirationtimeset {
struct res_header header;
};
struct req_exec_ckpt_sectionexpirationtimeset {
struct req_header header;
struct message_source source;
SaNameT checkpointName;
struct req_lib_ckpt_sectionexpirationtimeset req_lib_ckpt_sectionexpirationtimeset;
};
struct req_lib_ckpt_sectioniteratorinitialize {
struct req_header header;
SaNameT checkpointName;
SaCkptSectionsChosenT sectionsChosen;
SaTimeT expirationTime;
};
struct res_lib_ckpt_sectioniteratorinitialize {
struct res_header header;
};
struct req_lib_ckpt_sectioniteratornext {
struct req_header header;
};
struct res_lib_ckpt_sectioniteratornext {
struct res_header header;
SaCkptSectionDescriptorT sectionDescriptor;
};
struct req_lib_ckpt_sectionwrite {
struct req_header header;
SaUint32T idLen;
SaOffsetT dataOffset;
SaOffsetT dataSize;
};
struct res_lib_ckpt_sectionwrite {
struct res_header header;
};
struct req_exec_ckpt_sectionwrite {
struct req_header header;
struct message_source source;
SaNameT checkpointName;
struct req_lib_ckpt_sectionwrite req_lib_ckpt_sectionwrite;
};
struct req_lib_ckpt_sectionoverwrite {
struct req_header header;
SaUint32T idLen;
SaUint32T dataSize;
};
struct res_lib_ckpt_sectionoverwrite {
struct res_header header;
};
struct req_exec_ckpt_sectionoverwrite {
struct req_header header;
struct message_source source;
SaNameT checkpointName;
struct req_lib_ckpt_sectionoverwrite req_lib_ckpt_sectionoverwrite;
};
struct req_lib_ckpt_sectionread {
struct req_header header;
SaUint32T idLen;
SaOffsetT dataOffset;
SaOffsetT dataSize;
};
struct res_lib_ckpt_sectionread {
struct res_header header;
SaSizeT dataRead;
};
struct req_exec_ckpt_sectionread {
struct req_header header;
struct message_source source;
SaNameT checkpointName;
struct req_lib_ckpt_sectionread req_lib_ckpt_sectionread;
};
struct req_lib_ckpt_checkpointsynchronize {
struct req_header header;
};
struct res_lib_ckpt_checkpointsynchronize {
struct res_header header;
};
struct req_lib_ckpt_checkpointsynchronizeasync {
struct req_header header;
SaInvocationT invocation;
};
struct res_lib_ckpt_checkpointsynchronizeasync {
struct res_header header;
};
#endif /* AIS_MSG_H_DEFINED */

View File

@ -304,95 +304,4 @@ typedef struct {
SaAmfErrorBufferT *additionalInformation;
} SaAmfAdditionalDataT;
typedef SaUint64T SaCkptHandleT;
typedef SaUint64T SaCkptCheckpointHandleT;
typedef SaUint64T SaCkptSectionIteratorT;
#define SA_CKPT_WR_ALL_REPLICAS 0x1
#define SA_CKPT_WR_ACTIVE_REPLICA 0x2
#define SA_CKPT_WR_ACTIVE_REPLICA_WEAK 0x4
typedef SaUint32T SaCkptCheckpointCreationFlagsT;
typedef struct {
SaCkptCheckpointCreationFlagsT creationFlags;
SaSizeT checkpointSize;
SaTimeT retentionDuration;
SaUint32T maxSections;
SaSizeT maxSectionSize;
SaUint32T maxSectionIdSize;
} SaCkptCheckpointCreationAttributesT;
#define SA_CKPT_CHECKPOINT_READ 0x1
#define SA_CKPT_CHECKPOINT_WRITE 0x2
#define SA_CKPT_CHECKPOINT_COLOCATED 0x4
typedef SaUint32T SaCkptCheckpointOpenFlagsT;
#define SA_CKPT_DEFAULT_SECTION_ID { 0, 0 }
#define SA_CKPT_GENERATED_SECTION_ID { 0, 0 }
typedef struct {
SaUint8T *id;
SaUint32T idLen;
} SaCkptSectionIdT;
typedef struct {
SaCkptSectionIdT *sectionId;
SaTimeT expirationTime;
} SaCkptSectionCreationAttributesT;
typedef enum {
SA_CKPT_SECTION_VALID = 1,
SA_CKPT_SECTION_CORRUPTED = 2
} SaCkptSectionStateT;
typedef struct {
SaCkptSectionIdT sectionId;
SaTimeT expirationTime;
SaSizeT sectionSize;
SaCkptSectionStateT sectionState;
SaTimeT lastUpdate;
} SaCkptSectionDescriptorT;
typedef enum {
SA_CKPT_SECTIONS_FOREVER = 1,
SA_CKPT_SECTIONS_LEQ_EXPIRATION_TIME = 2,
SA_CKPT_SECTIONS_GEQ_EXPIRATION_TIME = 3,
SA_CKPT_SECTIONS_CORRUPTED = 4,
SA_CKPT_SECTIONS_ANY = 5
} SaCkptSectionsChosenT;
typedef SaUint32T SaOffsetT;
typedef struct {
SaCkptSectionIdT sectionId;
void *dataBuffer;
SaSizeT dataSize;
SaOffsetT dataOffset;
SaSizeT readSize;
} SaCkptIOVectorElementT;
typedef struct {
SaCkptCheckpointCreationAttributesT checkpointCreationAttributes;
SaUint32T numberOfSections;
SaUint32T memoryUsed;
} SaCkptCheckpointStatusT;
typedef void (*SaCkptCheckpointOpenCallbackT) (
SaInvocationT invocation,
const SaCkptCheckpointHandleT *checkpointHandle,
SaErrorT error);
typedef void (*SaCkptCheckpointSynchronizeCallbackT) (
SaInvocationT invocation,
SaErrorT error);
typedef struct {
SaCkptCheckpointOpenCallbackT saCkptCheckpointOpenCallback;
SaCkptCheckpointSynchronizeCallbackT saCkptCheckpointSynchronizeCallback;
} SaCkptCallbacksT;
#endif /* AIS_TYPES_H_DEFINED */

View File

@ -39,8 +39,6 @@ enum req_init_types {
MESSAGE_REQ_CLM_INIT,
MESSAGE_REQ_AMF_INIT,
MESSAGE_REQ_CKPT_INIT,
MESSAGE_REQ_CKPT_CHECKPOINT_INIT,
MESSAGE_REQ_CKPT_SECTIONITERATOR_INIT,
MESSAGE_REQ_EVT_INIT
};
@ -87,5 +85,9 @@ struct res_header {
SaErrorT error;
};
struct message_source {
struct conn_info *conn_info;
struct in_addr in_addr;
} __attribute__((packed));
#endif /* IPC_GEN_H_DEFINED */

View File

@ -86,7 +86,7 @@ amf.o: ../include/ipc_gen.h util.h
clm.o: ../include/ais_types.h ../include/saClm.h ../include/ais_types.h
clm.o: ../include/ais_msg.h ../include/evs.h ../include/saClm.h
clm.o: ../include/ipc_gen.h ../include/ipc_clm.h util.h
ckpt.o: ../include/list.h ../include/ais_types.h ../include/ais_ckpt.h
ckpt.o: ../include/list.h ../include/ais_types.h ../include/saCkpt.h
ckpt.o: ../include/ais_types.h ../include/ais_msg.h ../include/evs.h
ckpt.o: ../include/saClm.h ../include/ipc_gen.h util.h
evt.o: ../include/ipc_evt.h ../include/ais_types.h ../include/saEvt.h

File diff suppressed because it is too large Load Diff

View File

@ -102,8 +102,8 @@ evsbench: evsbench.o $(LIBS)
testclm: testclm.o $(LIBRARIES)
$(CC) $(LDFLAGS) -o testclm testclm.o $(LIBS)
testckpt: testckpt.o $(LIBRARIES)
$(CC) $(LDFLAGS) -o testckpt testckpt.o $(LIBS)
testckpt: testckpt.o sa_error.o $(LIBRARIES)
$(CC) $(LDFLAGS) -o testckpt testckpt.o sa_error.o $(LIBS)
ckptbench: ckptbench.o $(LIBRARIES)
$(CC) $(LDFLAGS) -o ckptbench ckptbench.o $(LIBS)
@ -149,13 +149,13 @@ testamf5.o: ../include/ais_types.h ../include/ais_amf.h
testamf6.o: ../include/ais_types.h ../include/ais_amf.h
testamfth.o: ../include/ais_types.h ../include/ais_amf.h ../include/ais_msg.h
testamfth.o: ../include/evs.h ../include/saClm.h ../include/ipc_gen.h
testckpt.o: ../include/ais_types.h ../include/ais_ckpt.h
ckptstress.o: ../include/ais_types.h ../include/ais_ckpt.h
testckpt.o: ../include/ais_types.h ../include/saCkpt.h
ckptstress.o: ../include/ais_types.h ../include/saCkpt.h
testparse.o: ../include/ais_types.h ../exec/parse.h ../include/list.h
testparse.o: ../exec/aispoll.h ../exec/totempg.h ../exec/totemsrp.h
testparse.o: ../exec/print.h ../include/saClm.h ../include/ais_types.h
ckptbench.o: ../include/ais_types.h ../include/ais_ckpt.h
ckptbenchth.o: ../include/ais_types.h ../include/ais_ckpt.h
ckptbench.o: ../include/ais_types.h ../include/saCkpt.h
ckptbenchth.o: ../include/ais_types.h ../include/saCkpt.h
testevt.o: ../include/ais_types.h ../include/saEvt.h
testevs.o: ../include/evs.h
evsbench.o: ../include/ais_types.h ../include/evs.h

View File

@ -50,7 +50,7 @@
#include <arpa/inet.h>
#include "ais_types.h"
#include "ais_ckpt.h"
#include "saCkpt.h"
int alarm_notice;
@ -63,7 +63,12 @@ void printSaNameT (SaNameT *name)
}
}
SaVersionT version = { 'A', 1, 1 };
SaVersionT version = { 'B', 1, 1 };
SaCkptCallbacksT callbacks = {
0,
0
};
SaNameT checkpointName = { 5, "abra\0" };
@ -77,13 +82,13 @@ SaCkptCheckpointCreationAttributesT checkpointCreationAttributes = {
};
SaCkptSectionIdT sectionId1 = {
"section ID #1",
14
14,
"section ID #1"
};
SaCkptSectionIdT sectionId2 = {
"section ID #2",
14
14,
"section ID #2"
};
SaCkptSectionCreationAttributesT sectionCreationAttributes1 = {
&sectionId1,
@ -102,8 +107,8 @@ char readBuffer2[1025];
SaCkptIOVectorElementT ReadVectorElements[] = {
{
{
"section ID #1",
14
14,
"section ID #1"
},
readBuffer1,
sizeof (readBuffer1),
@ -112,8 +117,8 @@ SaCkptIOVectorElementT ReadVectorElements[] = {
},
{
{
"section ID #2",
14
14,
"section ID #2"
},
readBuffer2,
sizeof (readBuffer2),
@ -129,8 +134,8 @@ char data[500000];
SaCkptIOVectorElementT WriteVectorElements[] = {
{
{
"section ID #1",
14
14,
"section ID #1"
},
data, /*"written data #1, this should extend past end of old section data", */
DATASIZE, /*sizeof ("data #1, this should extend past end of old section data") + 1, */
@ -140,8 +145,8 @@ SaCkptIOVectorElementT WriteVectorElements[] = {
#ifdef COMPILE_OUT
{
{
"section ID #2",
14
14,
"section ID #2"
},
data, /*"written data #2, this should extend past end of old section data" */
DATASIZE, /*sizeof ("written data #2, this should extend past end of old section data") + 1, */
@ -168,7 +173,7 @@ void ckpt_benchmark (SaCkptCheckpointHandleT checkpointHandle,
/*
* Test checkpoint write
*/
error = saCkptCheckpointWrite (&checkpointHandle,
error = saCkptCheckpointWrite (checkpointHandle,
WriteVectorElements,
1,
&erroroneousVectorIndex);
@ -197,6 +202,7 @@ void sigalrm_handler (int num)
}
int main (void) {
SaCkptHandleT ckptHandle;
SaCkptCheckpointHandleT checkpointHandle;
SaErrorT error;
int size;
@ -204,16 +210,19 @@ int main (void) {
signal (SIGALRM, sigalrm_handler);
error = saCkptCheckpointOpen (&checkpointName,
error = saCkptInitialize (&ckptHandle, &callbacks, &version);
error = saCkptCheckpointOpen (ckptHandle,
&checkpointName,
&checkpointCreationAttributes,
SA_CKPT_CHECKPOINT_READ|SA_CKPT_CHECKPOINT_WRITE,
0,
&checkpointHandle);
error = saCkptSectionCreate (&checkpointHandle,
error = saCkptSectionCreate (checkpointHandle,
&sectionCreationAttributes1,
"Initial Data #0",
strlen ("Initial Data #0") + 1);
error = saCkptSectionCreate (&checkpointHandle,
error = saCkptSectionCreate (checkpointHandle,
&sectionCreationAttributes2,
"Initial Data #0",
strlen ("Initial Data #0") + 1);
@ -224,5 +233,7 @@ int main (void) {
ckpt_benchmark (checkpointHandle, size);
size += 1000;
}
error = saCkptFinalize (ckptHandle);
return (0);
}

View File

@ -46,7 +46,7 @@
#include <pthread.h>
#include "ais_types.h"
#include "ais_ckpt.h"
#include "saCkpt.h"
void printSaNameT (SaNameT *name)
{
@ -57,7 +57,12 @@ void printSaNameT (SaNameT *name)
}
}
SaVersionT version = { 'A', 1, 1 };
SaVersionT version = { 'B', 1, 1 };
SaCkptCallbacksT callbacks = {
0,
0
};
SaCkptCheckpointCreationAttributesT checkpointCreationAttributes = {
SA_CKPT_WR_ALL_REPLICAS,
@ -69,13 +74,13 @@ SaCkptCheckpointCreationAttributesT checkpointCreationAttributes = {
};
SaCkptSectionIdT sectionId1 = {
"section ID #1",
14
14,
"section ID #1"
};
SaCkptSectionIdT sectionId2 = {
"section ID #2",
14
14,
"section ID #2"
};
SaCkptSectionCreationAttributesT sectionCreationAttributes1 = {
&sectionId1,
@ -94,8 +99,8 @@ char readBuffer2[1025];
SaCkptIOVectorElementT ReadVectorElements[] = {
{
{
"section ID #1",
14
14,
"section ID #1"
},
readBuffer1,
sizeof (readBuffer1),
@ -104,8 +109,8 @@ SaCkptIOVectorElementT ReadVectorElements[] = {
},
{
{
"section ID #2",
14
14,
"section ID #2"
},
readBuffer2,
sizeof (readBuffer2),
@ -121,8 +126,8 @@ char data[500000];
SaCkptIOVectorElementT WriteVectorElements[] = {
{
{
"section ID #1",
14
14,
"section ID #1"
},
data, /*"written data #1, this should extend past end of old section data", */
DATASIZE, /*sizeof ("data #1, this should extend past end of old section data") + 1, */
@ -132,8 +137,8 @@ SaCkptIOVectorElementT WriteVectorElements[] = {
#ifdef COMPILE_OUT
{
{
"section ID #2",
14
14,
"section ID #2"
},
data, /*"written data #2, this should extend past end of old section data" */
DATASIZE, /*sizeof ("written data #2, this should extend past end of old section data") + 1, */
@ -146,6 +151,7 @@ SaCkptIOVectorElementT WriteVectorElements[] = {
int runs = 0;
struct threaddata {
SaCkptHandleT ckptHandle;
SaCkptCheckpointHandleT checkpointHandle;
int write_count;
int write_size;
@ -156,6 +162,7 @@ void *benchmark_thread (void *arg)
{
SaCkptCheckpointHandleT checkpointHandle;
SaCkptHandleT ckptHandle;
int write_count;
int write_size;
SaErrorT error;
@ -164,6 +171,7 @@ void *benchmark_thread (void *arg)
int ckptinv;
checkpointHandle = td->checkpointHandle;
ckptHandle = td->ckptHandle;
write_count = td->write_count;
write_size = td->write_size;
@ -174,7 +182,7 @@ void *benchmark_thread (void *arg)
* Test checkpoint write
*/
do {
error = saCkptCheckpointWrite (&checkpointHandle,
error = saCkptCheckpointWrite (checkpointHandle,
WriteVectorElements,
1,
&erroroneousVectorIndex);
@ -193,8 +201,8 @@ printf ("done writing for thread %d\n", td->thread);
}
void threaded_bench (SaCkptCheckpointHandleT *checkpointHandles, int threads, int write_count,
int write_size)
void threaded_bench (SaCkptHandleT *ckptHandles, SaCkptCheckpointHandleT *checkpointHandles,
int threads, int write_count, int write_size)
{
struct timeval tv1, tv2, tv_elapsed;
struct threaddata td[100];
@ -206,6 +214,7 @@ void threaded_bench (SaCkptCheckpointHandleT *checkpointHandles, int threads, in
gettimeofday (&tv1, NULL);
for (i = 0; i < threads; i++) {
td[i].ckptHandle = ckptHandles[i];
td[i].checkpointHandle = checkpointHandles[i];
td[i].write_count = write_count;
td[i].write_size = write_size;
@ -235,6 +244,7 @@ SaNameT checkpointName = { 12, "abra\0" };
#define CHECKPOINT_THREADS 50
int main (void) {
SaCkptHandleT ckptHandles[500];
SaCkptCheckpointHandleT checkpointHandles[500];
SaErrorT error;
int size;
@ -246,16 +256,19 @@ int main (void) {
*/
for (i = 0; i < CHECKPOINT_THREADS; i++) {
sprintf (checkpointName.value, "checkpoint%d \n", i);
error = saCkptCheckpointOpen (&checkpointName,
error = saCkptInitialize (&ckptHandles[i], &callbacks, &version);
error = saCkptCheckpointOpen (ckptHandles[i],
&checkpointName,
&checkpointCreationAttributes,
SA_CKPT_CHECKPOINT_READ|SA_CKPT_CHECKPOINT_WRITE,
0,
&checkpointHandles[i]);
error = saCkptSectionCreate (&checkpointHandles[i],
error = saCkptSectionCreate (checkpointHandles[i],
&sectionCreationAttributes1,
"Initial Data #0",
strlen ("Initial Data #0") + 1);
error = saCkptSectionCreate (&checkpointHandles[i],
error = saCkptSectionCreate (checkpointHandles[i],
&sectionCreationAttributes2,
"Initial Data #0",
strlen ("Initial Data #0") + 1);
@ -266,7 +279,7 @@ int main (void) {
size = 100000; /* initial size */
printf ("THREADS %d\n", i);
for (j = 0; j < 5; j++) { /* number of runs with i threads */
threaded_bench (checkpointHandles, i, count, size);
threaded_bench (ckptHandles, checkpointHandles, i, count, size);
/*
* Adjust count to 95% of previous count
* adjust size upwards by 1500

View File

@ -43,7 +43,7 @@
#include <sys/un.h>
#include "ais_types.h"
#include "ais_ckpt.h"
#include "saCkpt.h"
int ckptinv;
void printSaNameT (SaNameT *name)
@ -55,7 +55,12 @@ void printSaNameT (SaNameT *name)
}
}
SaVersionT version = { 'A', 1, 1 };
SaVersionT version = { 'B', 1, 1 };
SaCkptCallbacksT callbacks = {
0,
0
};
SaNameT checkpointName = { 5, "abra\0" };
@ -69,13 +74,13 @@ SaCkptCheckpointCreationAttributesT checkpointCreationAttributes = {
};
SaCkptSectionIdT sectionId1 = {
"section ID #1",
14
14,
"section ID #1"
};
SaCkptSectionIdT sectionId2 = {
"section ID #2",
14
14,
"section ID #2"
};
SaCkptSectionCreationAttributesT sectionCreationAttributes1 = {
&sectionId1,
@ -94,8 +99,8 @@ char readBuffer2[1025];
SaCkptIOVectorElementT ReadVectorElements[] = {
{
{
"section ID #1",
14
14,
"section ID #1"
},
readBuffer1,
sizeof (readBuffer1),
@ -104,8 +109,8 @@ SaCkptIOVectorElementT ReadVectorElements[] = {
},
{
{
"section ID #2",
14
14,
"section ID #2"
},
readBuffer2,
sizeof (readBuffer2),
@ -119,8 +124,8 @@ char data[DATASIZE];
SaCkptIOVectorElementT WriteVectorElements[] = {
{
{
"section ID #1",
14
14,
"section ID #1"
},
data, /*"written data #1, this should extend past end of old section data", */
DATASIZE, /*sizeof ("written data #1, this should extend past end of old section data") + 1, */
@ -130,8 +135,8 @@ SaCkptIOVectorElementT WriteVectorElements[] = {
#ifdef COMPILE_OUT
{
{
"section ID #2",
14
14,
"section ID #2"
},
data, /*"written data #2, this should extend past end of old section data" */
DATASIZE, /*sizeof ("written data #2, this should extend past end of old section data") + 1, */
@ -144,18 +149,22 @@ SaCkptIOVectorElementT WriteVectorElements[] = {
void *th_dispatch (void *arg)
{
int th = (int)arg;
SaCkptHandleT ckptHandle;
SaCkptCheckpointHandleT handle;
SaErrorT error;
int i;
SaUint32T erroroneousVectorIndex = 0;
error = saCkptCheckpointOpen (&checkpointName,
error = saCkptInitialize (&ckptHandle, &callbacks, &version);
error = saCkptCheckpointOpen (ckptHandle,
&checkpointName,
&checkpointCreationAttributes,
SA_CKPT_CHECKPOINT_READ|SA_CKPT_CHECKPOINT_WRITE,
0,
&handle);
for (i = 0; i < 1000; i++) {
error = saCkptCheckpointWrite (&handle,
error = saCkptCheckpointWrite (handle,
WriteVectorElements,
1,/* placing two here with only one vector element causes an assertion failure !! */
&erroroneousVectorIndex);
@ -164,29 +173,36 @@ void *th_dispatch (void *arg)
printf ("Thread %d: Error from write.\n", th);
}
}
error = saCkptFinalize (ckptHandle);
return (0);
}
int main (void) {
SaCkptHandleT ckptHandle;
SaCkptCheckpointHandleT checkpointHandle;
SaErrorT error;
int i;
pthread_t dispatch_thread;
error = saCkptCheckpointOpen (&checkpointName,
error = saCkptInitialize (&ckptHandle, &callbacks, &version);
error = saCkptCheckpointOpen (ckptHandle,
&checkpointName,
&checkpointCreationAttributes,
SA_CKPT_CHECKPOINT_READ|SA_CKPT_CHECKPOINT_WRITE,
0,
&checkpointHandle);
printf ("first open result %d (should be 1)\n", error);
error = saCkptSectionCreate (&checkpointHandle,
error = saCkptSectionCreate (checkpointHandle,
&sectionCreationAttributes1,
"Initial Data #0",
strlen ("Initial Data #0") + 1);
printf ("create2 error is %d\n", error);
error = saCkptSectionCreate (&checkpointHandle,
error = saCkptSectionCreate (checkpointHandle,
&sectionCreationAttributes2,
"Initial Data #0",
strlen ("Initial Data #0") + 1);
@ -196,5 +212,8 @@ printf ("create2 error is %d\n", error);
pthread_create (&dispatch_thread, NULL, th_dispatch, (void *)i);
}
pthread_join (dispatch_thread, NULL);
error = saCkptInitialize (&ckptHandle, &callbacks, &version);
return (0);
}

View File

@ -1,4 +1,6 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include "ais_types.h"
@ -44,3 +46,20 @@ int get_sa_error(SaErrorT error, char *str, int len)
strncpy(str, sa_error_list[error], len);
return 0;
}
char *get_sa_error_b (SaAisErrorT error) {
return (sa_error_list[error]);
}
char *get_test_output (SaAisErrorT result, SaAisErrorT expected) {
static *test_result[256];
if (result == expected) {
return ("PASSED");
} else {
sprintf (test_result,
"FAILED expected %s got %s",
get_sa_error_b(expected), get_sa_error_b(result));
return (test_result);
}
}

View File

@ -44,7 +44,8 @@
#include <sys/time.h>
#include "ais_types.h"
#include "ais_ckpt.h"
#include "saCkpt.h"
#include "sa_error.h"
#define SECONDS_TO_EXPIRE 4
@ -58,7 +59,7 @@ void printSaNameT (SaNameT *name)
}
}
SaVersionT version = { 'A', 1, 1 };
SaVersionT version = { 'B', 1, 1 };
SaNameT checkpointName = { 5, "abra\0" };
@ -72,14 +73,15 @@ SaCkptCheckpointCreationAttributesT checkpointCreationAttributes = {
};
SaCkptSectionIdT sectionId1 = {
"section ID #1",
14
14,
"section ID #1"
};
SaCkptSectionIdT sectionId2 = {
"section ID #2",
14
14,
"section ID #2"
};
SaCkptSectionCreationAttributesT sectionCreationAttributes1 = {
&sectionId1,
SA_TIME_END
@ -97,8 +99,8 @@ char readBuffer2[1025];
SaCkptIOVectorElementT ReadVectorElements[] = {
{
{
"section ID #1",
14
14,
"section ID #1"
},
readBuffer1,
sizeof (readBuffer1),
@ -107,8 +109,8 @@ SaCkptIOVectorElementT ReadVectorElements[] = {
},
{
{
"section ID #2",
14
14,
"section ID #2"
},
readBuffer2,
sizeof (readBuffer2),
@ -122,8 +124,8 @@ char data[DATASIZE];
SaCkptIOVectorElementT WriteVectorElements[] = {
{
{
"section ID #1",
14
14,
"section ID #1"
},
data, /*"written data #1, this should extend past end of old section data", */
DATASIZE, /*sizeof ("data #1, this should extend past end of old section data") + 1, */
@ -133,8 +135,8 @@ SaCkptIOVectorElementT WriteVectorElements[] = {
#ifdef COMPILE_OUT
{
{
"section ID #2",
14
"section ID #2",
},
data, /*"written data #2, this should extend past end of old section data" */
DATASIZE, /*sizeof ("written data #2, this should extend past end of old section data") + 1, */
@ -144,12 +146,18 @@ SaCkptIOVectorElementT WriteVectorElements[] = {
#endif
};
SaCkptCallbacksT callbacks = {
0,
0
};
int main (void) {
SaCkptHandleT ckptHandle;
SaCkptCheckpointHandleT checkpointHandle;
SaCkptCheckpointHandleT checkpointHandle2;
SaCkptCheckpointHandleT checkpointHandleRead;
SaCkptCheckpointStatusT checkpointStatus;
SaCkptSectionIteratorT sectionIterator;
SaCkptCheckpointDescriptorT checkpointStatus;
SaCkptSectionIterationHandleT sectionIterator;
SaCkptSectionDescriptorT sectionDescriptor;
SaUint32T erroroneousVectorIndex = 0;
SaErrorT error;
@ -157,30 +165,39 @@ int main (void) {
struct timeval tv_end;
struct timeval tv_elapsed;
error = saCkptCheckpointOpen (&checkpointName,
error = saCkptInitialize (&ckptHandle, &callbacks, &version);
error = saCkptCheckpointOpen (ckptHandle,
&checkpointName,
&checkpointCreationAttributes,
SA_CKPT_CHECKPOINT_READ|SA_CKPT_CHECKPOINT_WRITE,
0,
&checkpointHandle);
printf ("first open result %d (should be 1)\n", error);
printf ("%s: initial open of checkpoint\n",
get_test_output (error, SA_AIS_OK));
gettimeofday (&tv_start, 0);
sectionCreationAttributes1.expirationTime = ((unsigned long long)(tv_start.tv_sec + SECONDS_TO_EXPIRE)) * ((unsigned long long)1000000000) + ((unsigned long long)(tv_start.tv_usec) * ((unsigned long long)1000));
error = saCkptSectionCreate (&checkpointHandle,
error = saCkptSectionCreate (checkpointHandle,
&sectionCreationAttributes1,
"Initial Data #0",
strlen ("Initial Data #0") + 1);
printf ("%s: checkpoint section create\n",
get_test_output (error, SA_AIS_OK));
if (error != SA_OK) {
error = saCkptSectionExpirationTimeSet (&checkpointHandle,
error = saCkptSectionExpirationTimeSet (checkpointHandle,
&sectionId1,
sectionCreationAttributes1.expirationTime);
printf ("%s: checkpoint section expiration set\n",
get_test_output (error, SA_AIS_OK));
}
printf ("create1 error is %d\n", error);
printf ("Please wait, testing expiry of checkpoint sections.\n");
do {
error = saCkptCheckpointRead (&checkpointHandle,
error = saCkptCheckpointRead (checkpointHandle,
ReadVectorElements,
1,
&erroroneousVectorIndex);
@ -189,15 +206,18 @@ printf ("Please wait, testing expiry of checkpoint sections.\n");
timersub (&tv_end, &tv_start, &tv_elapsed);
printf ("Elapsed Time to expiry is %ld.%ld (should be about %d seconds)\n", tv_elapsed.tv_sec, tv_elapsed.tv_usec, SECONDS_TO_EXPIRE);
error = saCkptCheckpointRetentionDurationSet (&checkpointHandle,
error = saCkptCheckpointRetentionDurationSet (checkpointHandle,
5000000000LL);
printf ("RetentionDurationSet is %d\n", error);
printf ("%s: RetentionDurationSet\n",
get_test_output (error, SA_AIS_OK));
error = saCkptSectionCreate (&checkpointHandle,
error = saCkptSectionCreate (checkpointHandle,
&sectionCreationAttributes2,
"Initial Data #0",
strlen ("Initial Data #0") + 1);
printf ("create2 error is %d\n", error);
printf ("%s: Section creation\n",
get_test_output (error, SA_AIS_OK));
printf ("saCkptSectionCreate result %d (should be 1)\n", error);
#ifdef cmpout
for (ckptinv = 0; ckptinv < 500000; ckptinv++) {
@ -205,7 +225,7 @@ printf ("Writing checkpoint loop %d\n", ckptinv);
/*
* Test checkpoint write
*/
error = saCkptCheckpointWrite (&checkpointHandle,
error = saCkptCheckpointWrite (checkpointHandle,
WriteVectorElements,
1,
&erroroneousVectorIndex);
@ -217,115 +237,131 @@ if (error != SA_OK) {
exit (1);
#endif
error = saCkptCheckpointUnlink (&checkpointName);
printf ("unlink result %d (should be 1)\n", error);
error = saCkptCheckpointUnlink (ckptHandle, &checkpointName);
printf ("%s: Unlinking checkpoint\n",
get_test_output (error, SA_AIS_OK));
error = saCkptCheckpointOpen (&checkpointName,
error = saCkptCheckpointOpen (ckptHandle,
&checkpointName,
&checkpointCreationAttributes,
SA_CKPT_CHECKPOINT_READ|SA_CKPT_CHECKPOINT_WRITE,
0,
&checkpointHandle2);
printf ("open after unlink result %d (should be 7)\n", error);
printf ("%s: Opening unlinked checkpoint\n",
get_test_output (error, 7));
error = saCkptCheckpointClose (&checkpointHandle);
printf ("close result %d (should be 1)\n", error);
error = saCkptCheckpointClose (checkpointHandle);
printf ("%s: Closing checkpoint\n",
get_test_output (error, SA_AIS_OK));
error = saCkptCheckpointOpen (&checkpointName,
error = saCkptCheckpointOpen (ckptHandle,
&checkpointName,
&checkpointCreationAttributes,
SA_CKPT_CHECKPOINT_READ,
0,
&checkpointHandleRead);
printf ("read only open result %d (should be 1)\n", error);
error = saCkptCheckpointOpen (&checkpointName,
printf ("%s: Open checkpoint read only\n",
get_test_output (error, SA_AIS_OK));
error = saCkptCheckpointOpen (ckptHandle,
&checkpointName,
&checkpointCreationAttributes,
SA_CKPT_CHECKPOINT_READ|SA_CKPT_CHECKPOINT_WRITE,
0,
&checkpointHandle);
printf ("open after unlink/close result %d (should be 1)\n", error);
printf ("%s: open after unlink/close\n",
get_test_output (error, SA_AIS_OK));
error = saCkptCheckpointRetentionDurationSet (&checkpointHandle,
error = saCkptCheckpointRetentionDurationSet (checkpointHandle,
5000000000LL);
printf ("Retention duration set error is %d\n", error);
printf ("set checkpoint retention duration result %d (should be 1)\n", error);
printf ("%s: set checkpoint retention duration\n",
get_test_output (error, SA_AIS_OK));
error = saCkptCheckpointStatusGet (&checkpointHandle,
error = saCkptCheckpointStatusGet (checkpointHandle,
&checkpointStatus);
printf ("saCkptCheckpointStatusGet result %d (should be 1)\n", error);
printf ("%s: Get checkpoint status\n",
get_test_output (error, SA_AIS_OK));
if (error == SA_OK) {
printf ("Memory used %d in %d sections.\n", (int)checkpointStatus.memoryUsed,
(int)checkpointStatus.numberOfSections);
}
error = saCkptSectionCreate (&checkpointHandleRead,
error = saCkptSectionCreate (checkpointHandleRead,
&sectionCreationAttributes1,
"Initial Data #0",
strlen ("Initial Data #0") + 1);
printf ("saCkptSectionCreate result %d (should be 11)\n", error);
printf ("%s: Create checkpoint section on read only checkpoint\n",
get_test_output (error, SA_AIS_ERR_ACCESS));
error = saCkptSectionCreate (&checkpointHandle,
error = saCkptSectionCreate (checkpointHandle,
&sectionCreationAttributes1,
"Initial Data #0",
strlen ("Initial Data #0") + 1);
printf ("saCkptSectionCreate result %d (should be 1)\n", error);
printf ("%s: Create checkpoint section on writeable checkpoint\n",
get_test_output (error, SA_AIS_OK));
error = saCkptSectionCreate (&checkpointHandle,
error = saCkptSectionCreate (checkpointHandle,
&sectionCreationAttributes1,
"Initial Data #0",
strlen ("Initial Data #0") + 1);
printf ("saCkptSectionCreate result %d (should be 14)\n", error);
printf ("%s: Create checkpoint section when one already exists\n",
get_test_output (error, 14));
#ifdef COMPILE_OUT
error = saCkptSectionDelete (&checkpointHandle,
error = saCkptSectionDelete (checkpointHandle,
&sectionId1);
printf ("saCkptSectionDelete result %d (should be 1)\n", error);
printf ("%s: deleting checkpoint handle\n",
get_test_output (error, SA_AIS_OK));
error = saCkptSectionCreate (&checkpointHandle,
error = saCkptSectionCreate (checkpointHandle,
&sectionCreationAttributes1,
"Initial Data #0",
strlen ("Initial Data #0") + 1);
printf ("saCkptSectionCreate result %d (should be 1)\n", error);
#endif
printf ("%s: replacing deleted checkpoint section\n",
get_test_output (error, SA_AIS_OK));
error = saCkptSectionExpirationTimeSet (&checkpointHandle,
error = saCkptSectionExpirationTimeSet (checkpointHandle,
&sectionId2,
SA_TIME_END);
printf ("saCkptSectionExpirationTimeSet result %d (should be 1)\n", error);
printf ("%s: Setting expiration time for section 2\n",
get_test_output (error, SA_AIS_OK));
error = saCkptSectionOverwrite (&checkpointHandle,
error = saCkptSectionOverwrite (checkpointHandle,
&sectionId1,
"Overwrite Data #1",
strlen ("Overwrite Data #1") + 1);
printf ("saCkptSectionOverwrite result %d (should be 1)\n", error);
printf ("%s: overwriting checkpoint section 1\n",
get_test_output (error, SA_AIS_OK));
/*
* Test checkpoint read
*/
memset (readBuffer1, 0, sizeof (readBuffer1));
memset (readBuffer2, 0, sizeof (readBuffer2));
error = saCkptSectionCreate (&checkpointHandle,
error = saCkptSectionCreate (checkpointHandle,
&sectionCreationAttributes2,
"Initial Data #2",
strlen ("Initial Data #2") + 1);
printf ("saCkptSectionCreate result %d (should be 1)\n", error);
printf ("%s: creating checkpoint for read test\n",
get_test_output (error, SA_AIS_OK));
error = saCkptCheckpointRead (&checkpointHandle,
error = saCkptCheckpointRead (checkpointHandle,
ReadVectorElements,
2,
&erroroneousVectorIndex);
printf ("saCkptCheckpointRead result %d (should be 1)\n", error);
printf ("%s: checkpoint read operation",
get_test_output (error, SA_AIS_OK));
printf ("Buffers after checkpoint read\n");
printf (" buffer #1: '%s'\n", readBuffer1);
printf (" buffer #2: '%s'\n", readBuffer2);
//sleep (20);
#ifdef COMPILE_OUT
for (ckptinv = 0; ckptinv < 2000; ckptinv++) {
/*
* Test checkpoint write
*/
error = saCkptCheckpointWrite (&checkpointHandle,
error = saCkptCheckpointWrite (checkpointHandle,
WriteVectorElements,
2,
&erroroneousVectorIndex);
@ -337,7 +373,7 @@ exit (1);
}
exit (1);
#endif
error = saCkptCheckpointRead (&checkpointHandle,
error = saCkptCheckpointRead (checkpointHandle,
ReadVectorElements,
2,
&erroroneousVectorIndex);
@ -346,26 +382,30 @@ exit (1);
// printf (" buffer #1: '%s'\n", readBuffer1);
// printf (" buffer #2: '%s'\n", readBuffer2);
error = saCkptCheckpointStatusGet (&checkpointHandle,
error = saCkptCheckpointStatusGet (checkpointHandle,
&checkpointStatus);
printf ("saCkptCheckpointStatusGet result %d (should be 1)\n", error);
printf ("%s: get checkpoint status\n",
get_test_output (error, SA_AIS_OK));
if (error == SA_OK) {
printf ("Memory used %d in %d sections.\n", (int)checkpointStatus.memoryUsed,
printf ("Memory used %d in %d sections.\n",
(int)checkpointStatus.memoryUsed,
(int)checkpointStatus.numberOfSections);
}
error = saCkptSectionIteratorInitialize (&checkpointHandle,
error = saCkptSectionIterationInitialize (checkpointHandle,
0,
0,
&sectionIterator);
printf ("saCkptSectionIteratorInitialize result %d (should be 1)\n", error);
printf ("%s: initialize section iterator\n",
get_test_output (error, SA_AIS_OK));
/*
* Iterate all sections
*/
do {
error = saCkptSectionIteratorNext (&sectionIterator,
error = saCkptSectionIterationNext (sectionIterator,
&sectionDescriptor);
printf ("saCkptSectionIteratorNext result %d (should be 1)\n", error);
printf ("%s: Get next section in iteartion\n",
get_test_output (error, SA_AIS_OK));
if (error == SA_OK) {
printf ("Section '%s' expires %llx size %d state %x update %llx\n",
sectionDescriptor.sectionId.id,
@ -375,8 +415,10 @@ exit (1);
sectionDescriptor.lastUpdate);
}
} while (error == SA_OK);
printf ("The last iteration should fail\n");
error = saCkptSectionIteratorFinalize (&sectionIterator);
printf ("saCkptSectionIteratorFinalize result %d (should be 1)\n", error);
error = saCkptSectionIterationFinalize (sectionIterator);
printf ("%s: Finalize iteration\n",
get_test_output (error, SA_AIS_OK));
return (0);
}