diff --git a/test/ckpt-rd.c b/test/ckpt-rd.c index cf3587ca..b0c78588 100644 --- a/test/ckpt-rd.c +++ b/test/ckpt-rd.c @@ -41,7 +41,7 @@ #include #include #include -#include +#include #include "ais_types.h" #include "saCkpt.h" @@ -68,7 +68,7 @@ SaCkptCheckpointCreationAttributesT checkpointCreationAttributes = { 100000, 5000000000LL, 5, - 20000, + 2000, 10 }; @@ -131,7 +131,11 @@ int main (void) { SaCkptHandleT ckptHandle; SaCkptCheckpointHandleT checkpointHandle; SaAisErrorT error; - SaUint32T erroroneousVectorIndex = 0; + SaUint32T erroroneousVectorIndex = 0; + struct timespec delay; + delay.tv_sec = 1; + delay.tv_nsec = 0; + error = saCkptInitialize (&ckptHandle, &callbacks, &version); @@ -144,20 +148,21 @@ int main (void) { &checkpointHandle); printf ("%s: initial open of checkpoint\n", get_test_output (error, SA_AIS_OK)); + + while (1) { + error = saCkptCheckpointRead (checkpointHandle, + ReadVectorElements, + 1, + &erroroneousVectorIndex); + if (error != SA_AIS_OK) { + printf ("%s: read checkpoint\n", + get_test_output (error, SA_AIS_OK)); + return (0); + } - error = saCkptSectionCreate (checkpointHandle, - §ionCreationAttributes1, - "Initial Data #0", - strlen ("Initial Data #0") + 1); - - error = saCkptCheckpointRead (checkpointHandle, - ReadVectorElements, - 1, - &erroroneousVectorIndex); - printf ("%s: read checkpoint\n", - get_test_output (error, SA_AIS_OK)); - - printf ("Checkpoint contains %s\n", (char *)ReadVectorElements->dataBuffer); + printf ("Checkpoint contains %s\n", (char *)ReadVectorElements->dataBuffer); + nanosleep(&delay,0); + } return (0); } diff --git a/test/ckpt-wr.c b/test/ckpt-wr.c index 537a0c5a..a3a4be67 100644 --- a/test/ckpt-wr.c +++ b/test/ckpt-wr.c @@ -40,7 +40,7 @@ #include #include #include -#include +#include #include "ais_types.h" #include "saCkpt.h" @@ -65,7 +65,7 @@ SaNameT checkpointName = { 16, "checkpoint-sync\0" }; SaCkptCheckpointCreationAttributesT checkpointCreationAttributes = { SA_CKPT_WR_ALL_REPLICAS, 100000, - SA_TIME_END, + 2000, 5, 20000, 10 @@ -138,26 +138,74 @@ SaCkptCallbacksT callbacks = { 0 }; +#define MAX_DATA_SIZE 100 + int main (void) { SaCkptHandleT ckptHandle; SaCkptCheckpointHandleT checkpointHandle; SaAisErrorT error; - + char data[MAX_DATA_SIZE]; + struct timespec delay; + struct timespec delay2; + delay.tv_sec = 1; + delay.tv_nsec = 0; + SaCkptIOVectorElementT writeElement; + long count = 0; + SaUint32T erroroneousVectorIndex = 0; + error = saCkptInitialize (&ckptHandle, &callbacks, &version); - + error = saCkptCheckpointOpen (ckptHandle, - &checkpointName, - &checkpointCreationAttributes, - SA_CKPT_CHECKPOINT_READ|SA_CKPT_CHECKPOINT_WRITE, - 0, - &checkpointHandle); + &checkpointName, + &checkpointCreationAttributes, + SA_CKPT_CHECKPOINT_READ|SA_CKPT_CHECKPOINT_WRITE, + 0, + &checkpointHandle); printf ("%s: initial open of checkpoint\n", get_test_output (error, SA_AIS_OK)); - error = saCkptSectionCreate (checkpointHandle, - §ionCreationAttributes1, - "Initial Data #0", - strlen ("Initial Data #0") + 1); + + error = saCkptSectionCreate (checkpointHandle, + §ionCreationAttributes1, + "0", + strlen ("0") + 1); + + do{ + error = saCkptCheckpointRead (checkpointHandle, + ReadVectorElements, + 1, + &erroroneousVectorIndex); + if (error != SA_AIS_OK) { + if (error == SA_AIS_ERR_TRY_AGAIN) { + continue; + } + return (0); + } + + count = atol((char *)ReadVectorElements->dataBuffer); + + count++; + sprintf((char*)&data, "%d",(int)count); + writeElement.sectionId = (const SaCkptSectionIdT)*sectionCreationAttributes1.sectionId; + writeElement.dataBuffer = data; + writeElement.dataSize = strlen (data) + 1; + writeElement.dataOffset = 0; + writeElement.readSize = 0; + + do { + error = saCkptCheckpointWrite (checkpointHandle, + &writeElement, + 1, + &erroroneousVectorIndex); + + printf ("%s: checkpoint write with data %s\n", + get_test_output (error, SA_AIS_OK), (char*)data); + }while (error == SA_AIS_ERR_TRY_AGAIN); + + + nanosleep(&delay,&delay2); + }while (1); return (0); + }