Unable to attache : upperlimit_cpsv_test.c
#include <saCkpt.h>
#include <opensaf/cpsv_papi.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
#include <unistd.h>
#include <pthread.h>
SaCkptHandleT ckptHandle;
static int ckptcreate_flag;
pthread_mutex_t ckptcreate_mutex;
pthread_cond_t ckptcreate_cond;
static int ckpt_cont = 0;
void writer_loop(unsigned int thread_number) {
SaAisErrorT result;
unsigned int iteration = 1;
char wdata[] = "data";
char initialData[] = "initial data";
int initialDataSize = strlen(initialData);
SaNameT checkpointName = {0, ""};
const SaCkptCheckpointCreationAttributesT checkpointCreationAttributes
= {
.creationFlags = SA_CKPT_WR_ALL_REPLICAS, // synchronous
.checkpointSize = 500,
.retentionDuration = 30 * 1000L * SA_TIME_ONE_MILLISECOND,
.maxSections = 5,
.maxSectionSize = 100,
.maxSectionIdSize = 256
};
const SaCkptCheckpointOpenFlagsT checkpointOpenFlags =
SA_CKPT_CHECKPOINT_CREATE |
SA_CKPT_CHECKPOINT_WRITE |
SA_CKPT_CHECKPOINT_READ;
const SaTimeT timeout = SA_TIME_ONE_SECOND;
SaCkptCheckpointHandleT checkpointHandle;
SaCkptSectionIdT sectionId = {
.id = (unsigned char *)"section_100_100",
.idLen = strlen("section_100_100"),
};
sectionId.id = (unsigned char *)calloc(50,sizeof(unsigned char));
SaCkptSectionCreationAttributesT sectionCreationAttributes = {
.sectionId = §ionId,
.expirationTime = SA_TIME_ONE_SECOND,
};
SaUint32T dummy;
while(iteration < 50) {
ckpt_cont++;
checkpointName.length = snprintf((char*)checkpointName.value,
sizeof(checkpointName.value),
"safCkpt=checkpoint_%d_test_%u_%u",ckpt_cont,thread_number,iteration);
if(checkpointName.length >= sizeof(checkpointName.value)) {
checkpointName.length = sizeof(checkpointName.value) -
1;
}
result = saCkptCheckpointOpen(ckptHandle,
&checkpointName,
&checkpointCreationAttributes,
checkpointOpenFlags,
timeout,
&checkpointHandle);
if(result == SA_AIS_OK) {
fprintf(stderr,
"Attempt %u-%u: saCkptCheckpointOpen
returned %lld.\n",
thread_number, iteration, (long long
int)result);
pthread_mutex_lock(&ckptcreate_mutex);
ckptcreate_flag = 1;
pthread_cond_broadcast(&ckptcreate_cond);
pthread_mutex_unlock(&ckptcreate_mutex);
} else {
fprintf(stderr,
"Attempt %u-%u: saCkptCheckpointOpen
returned %lld.\n",
thread_number, iteration, (long long
int)result);
}
sprintf((char
*)sectionId.id,"section_%u_%u",thread_number,iteration);
sectionId.idLen = strlen((char *)sectionId.id);
SaCkptIOVectorElementT writeVector[] = {
{
.sectionId = sectionId,
.dataBuffer = wdata,
.dataSize = strlen(wdata),
.dataOffset = 0,
.readSize = 0
}
};
pthread_mutex_lock(&ckptcreate_mutex);
if(ckptcreate_flag != 1) {
pthread_cond_wait(&ckptcreate_cond,&ckptcreate_mutex);
fprintf(stderr,
"Attempt %u-%u: ckpt is created.\n",
thread_number, iteration);
}
pthread_mutex_unlock(&ckptcreate_mutex);
if(result == SA_AIS_OK) {
result = saCkptSectionCreate(checkpointHandle,
§ionCreationAttributes,
initialData,
initialDataSize);
if(result != SA_AIS_OK) {
fprintf(stderr,
"Attempt %u-%u:
saCkptSectionCreate returned %lld.\n",
thread_number, iteration, (long
long int)result);
} else {
/*fprintf(stderr,"I am writer
%u-%u.\n",thread_number,iteration);*/
result = saCkptCheckpointWrite(checkpointHandle,
writeVector,
1,
&dummy);
if(result != SA_AIS_OK) {
fprintf(stderr,
"Attempt %u-%u:
saCkptCheckpointWrite returned %lld.\n",
thread_number,
iteration, (long long int)result);
}
}
} else {
fprintf(stderr,
"Attempt %u-%u: saCkptCheckpointOpen
returned %lld.\n",
thread_number, iteration, (long long
int)result);
}
sleep(1);
iteration++;
}
sleep(1);
}
void* writer_thread(void* nump) {
writer_loop(*(unsigned int*)nump);
pthread_exit(NULL);
}
int main(int argc, char** argv) {
SaVersionT version = {'B', 1, 0};
int result;
pthread_t thread[101];
ckptcreate_flag=0;
pthread_mutex_init(&ckptcreate_mutex,NULL);
pthread_cond_init(&ckptcreate_cond,NULL);
result = saCkptInitialize(&ckptHandle, NULL, &version);
if(result != SA_AIS_OK) {
fprintf(stderr, "saCkptInitialize failed with code %d.\n",
result);
} else {
unsigned int number;
for(number = 1; number < 100; number++) {
unsigned int* nump = malloc(sizeof(unsigned int));
*nump = number;
result = pthread_create(&thread[number-1], NULL,
writer_thread, nump);
if(result != 0) {
fprintf(stderr, "pthread_create failed with
code %d.\n", result);
}
sleep(2);
}
fprintf(stderr,"Waiting for all the threads to complete \n");
for(number = 1; number < 100; number++)
(void) pthread_join(thread[number-1],NULL);
}
pthread_mutex_destroy(&ckptcreate_mutex);
pthread_cond_destroy(&ckptcreate_cond);
return result;
}
---
** [tickets:#559] cpsv: Unnecessary ckpt run-time IMM object is getting created
after exceeding the maximum number of allowed replicas**
**Status:** assigned
**Created:** Fri Aug 30, 2013 06:42 AM UTC by A V Mahesh (AVM)
**Last Updated:** Fri Aug 30, 2013 06:42 AM UTC
**Owner:** nobody
When trying to test upper limit of Max checkpoint replicas , some stale
checkpoint IMM objects
are getting created and not getting deleted after retention time .
Steps to Reproduce the Problem
Run the attached upperlimit_cpsv_test.c application on a two controller node
cluster .
---
Sent from sourceforge.net because [email protected] is
subscribed to https://sourceforge.net/p/opensaf/tickets/
To unsubscribe from further messages, a project admin can change settings at
https://sourceforge.net/p/opensaf/admin/tickets/options. Or, if this is a
mailing list, you can unsubscribe from the mailing list.------------------------------------------------------------------------------
Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
Discover the easy way to master current and previous Microsoft technologies
and advance your career. Get an incredible 1,500+ hours of step-by-step
tutorial videos with LearnDevNow. Subscribe today and save!
http://pubads.g.doubleclick.net/gampad/clk?id=58040911&iu=/4140/ostg.clktrk
_______________________________________________
Opensaf-tickets mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensaf-tickets