9 #include <sys/socket.h>
10 #include <sys/select.h>
12 #include <arpa/inet.h>
21 SaVersionT version
= { 'B', 1, 1 };
23 SaCkptCallbacksT callbacks
= {
28 SaCkptCheckpointCreationAttributesT checkpointCreationAttributes
= {
29 SA_CKPT_WR_ALL_REPLICAS
,
37 SaCkptSectionIdT sectionId
= {
39 (SaUint8T
*)"section ID #1"
42 SaCkptSectionCreationAttributesT sectionCreationAttributes
= {
47 char* getPayload(int psize
) {
49 char* retVal
= new char[psize
];
54 for (i
= 0; i
< psize
; i
++)
56 if (i
== (psize
- 1)) {
64 retVal
= retVal
- psize
;
68 SaCkptCheckpointHandleT WriteCheckpointHandle
;
70 static long sendCount
= 0;
71 void process_message()
77 SaCkptIOVectorElementT writeElement
; // KJS
79 SaUint32T erroroneousVectorIndex
= 0;
82 writeElement
.sectionId
= sectionId
;
83 writeElement
.dataBuffer
= getPayload(200);
84 writeElement
.dataSize
= 200;
85 writeElement
.dataOffset
= 0;
86 writeElement
.readSize
= 0;
88 gettimeofday(&tv
, NULL
);
93 error
= saCkptCheckpointWrite (WriteCheckpointHandle
,
96 &erroroneousVectorIndex
);
98 if (error
!= SA_AIS_OK
) {
99 fprintf(stderr
,"saCkptCheckpointWrite result %d (should be 1)\n", error
);
102 fprintf(stderr
,"sendCount = %d",(int)sendCount
);
103 } while (error
== SA_AIS_ERR_TRY_AGAIN
);
105 gettimeofday(&tv
, NULL
);
107 fprintf(stderr
," ,RTT::%d.%d\n",(long)tv
.tv_sec
- told
, t2
-t1
);
112 SaNameT
* WriteCheckpointName
= (SaNameT
*) malloc(sizeof(SaNameT
));
114 SaCkptHandleT ckptHandle
;
116 sprintf(name
,"ckpt%d",1);
117 int namelen
= strlen(name
) + 1;
118 memcpy(WriteCheckpointName
->value
, name
, namelen
);
119 WriteCheckpointName
->length
= namelen
;
121 error
= saCkptInitialize (&ckptHandle
, &callbacks
, &version
);
123 error
= saCkptCheckpointOpen (
126 &checkpointCreationAttributes
,
127 SA_CKPT_CHECKPOINT_WRITE
,
128 1000000000, /* 1 Second */
129 &WriteCheckpointHandle
);
131 if (error
!= SA_AIS_OK
) {
132 fprintf(stderr
,"saCkptCheckpointOpen result %d (should be 1)\n", error
);
136 error
= saCkptSectionCreate ( WriteCheckpointHandle
,
137 §ionCreationAttributes
,
139 strlen ("Initial Data #0") + 1);
140 if (error
!= SA_AIS_OK
) {
141 fprintf(stderr
,"saCkptSectionCreate result = %d\n", error
);
147 tv
.tv_nsec
= 15000000; //15 milliseconds