|
@@ -88,7 +88,7 @@ void listener(zhandle_t *zzh, int type, int state, const char *path,void* ctx) {
|
|
void create_completion(int rc, const char *name, const void *data) {
|
|
void create_completion(int rc, const char *name, const void *data) {
|
|
incCounter(-1);
|
|
incCounter(-1);
|
|
if(rc!=ZOK){
|
|
if(rc!=ZOK){
|
|
- LOG_ERROR(("Failed to create a node rc=%d",rc));
|
|
|
|
|
|
+ LOG_ERROR(LOGSTREAM, "Failed to create a node rc=%d",rc);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -102,7 +102,7 @@ int doCreateNodes(const char* root, int count){
|
|
rc=zoo_acreate(zh, nodeName, "first", 5, &ZOO_OPEN_ACL_UNSAFE, 0,
|
|
rc=zoo_acreate(zh, nodeName, "first", 5, &ZOO_OPEN_ACL_UNSAFE, 0,
|
|
create_completion, 0);
|
|
create_completion, 0);
|
|
if(i%1000==0){
|
|
if(i%1000==0){
|
|
- LOG_INFO(("Created %s",nodeName));
|
|
|
|
|
|
+ LOG_INFO(LOGSTREAM, "Created %s", nodeName);
|
|
}
|
|
}
|
|
if(rc!=ZOK) return rc;
|
|
if(rc!=ZOK) return rc;
|
|
}
|
|
}
|
|
@@ -116,7 +116,7 @@ int createRoot(const char* root){
|
|
void write_completion(int rc, const struct Stat *stat, const void *data) {
|
|
void write_completion(int rc, const struct Stat *stat, const void *data) {
|
|
incCounter(-1);
|
|
incCounter(-1);
|
|
if(rc!=ZOK){
|
|
if(rc!=ZOK){
|
|
- LOG_ERROR(("Failed to write a node rc=%d",rc));
|
|
|
|
|
|
+ LOG_ERROR(LOGSTREAM, "Failed to write a node rc=%d",rc);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -137,13 +137,13 @@ void read_completion(int rc, const char *value, int value_len,
|
|
const struct Stat *stat, const void *data) {
|
|
const struct Stat *stat, const void *data) {
|
|
incCounter(-1);
|
|
incCounter(-1);
|
|
if(rc!=ZOK){
|
|
if(rc!=ZOK){
|
|
- LOG_ERROR(("Failed to read a node rc=%d",rc));
|
|
|
|
|
|
+ LOG_ERROR(LOGSTREAM, "Failed to read a node rc=%d",rc);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
if(memcmp(value,"second",6)!=0){
|
|
if(memcmp(value,"second",6)!=0){
|
|
char buf[value_len+1];
|
|
char buf[value_len+1];
|
|
memcpy(buf,value,value_len);buf[value_len]=0;
|
|
memcpy(buf,value,value_len);buf[value_len]=0;
|
|
- LOG_ERROR(("Invalid read, expected [second], received [%s]\n",buf));
|
|
|
|
|
|
+ LOG_ERROR(LOGSTREAM, "Invalid read, expected [second], received [%s]\n",buf);
|
|
exit(1);
|
|
exit(1);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -198,7 +198,7 @@ int recursiveDelete(const char* root){
|
|
int rc=zoo_get_children(zh,root,0,&children);
|
|
int rc=zoo_get_children(zh,root,0,&children);
|
|
if(rc!=ZNONODE){
|
|
if(rc!=ZNONODE){
|
|
if(rc!=ZOK){
|
|
if(rc!=ZOK){
|
|
- LOG_ERROR(("Failed to get children of %s, rc=%d",root,rc));
|
|
|
|
|
|
+ LOG_ERROR(LOGSTREAM, "Failed to get children of %s, rc=%d",root,rc);
|
|
return rc;
|
|
return rc;
|
|
}
|
|
}
|
|
for(i=0;i<children.count; i++){
|
|
for(i=0;i<children.count; i++){
|
|
@@ -214,10 +214,10 @@ int recursiveDelete(const char* root){
|
|
free_String_vector(&children);
|
|
free_String_vector(&children);
|
|
}
|
|
}
|
|
if(deletedCounter%1000==0)
|
|
if(deletedCounter%1000==0)
|
|
- LOG_INFO(("Deleting %s",root));
|
|
|
|
|
|
+ LOG_INFO(LOGSTREAM, "Deleting %s",root);
|
|
rc=zoo_delete(zh,root,-1);
|
|
rc=zoo_delete(zh,root,-1);
|
|
if(rc!=ZOK){
|
|
if(rc!=ZOK){
|
|
- LOG_ERROR(("Failed to delete znode %s, rc=%d",root,rc));
|
|
|
|
|
|
+ LOG_ERROR(LOGSTREAM, "Failed to delete znode %s, rc=%d",root,rc);
|
|
}else
|
|
}else
|
|
deletedCounter++;
|
|
deletedCounter++;
|
|
return rc;
|
|
return rc;
|
|
@@ -245,15 +245,15 @@ int main(int argc, char **argv) {
|
|
if (!zh)
|
|
if (!zh)
|
|
return errno;
|
|
return errno;
|
|
|
|
|
|
- LOG_INFO(("Checking server connection..."));
|
|
|
|
|
|
+ LOG_INFO(LOGSTREAM, "Checking server connection...");
|
|
ensureConnected();
|
|
ensureConnected();
|
|
if(cleaning==1){
|
|
if(cleaning==1){
|
|
int rc = 0;
|
|
int rc = 0;
|
|
deletedCounter=0;
|
|
deletedCounter=0;
|
|
rc=recursiveDelete(argv[2]);
|
|
rc=recursiveDelete(argv[2]);
|
|
if(rc==ZOK){
|
|
if(rc==ZOK){
|
|
- LOG_INFO(("Succesfully deleted a subtree starting at %s (%d nodes)",
|
|
|
|
- argv[2],deletedCounter));
|
|
|
|
|
|
+ LOG_INFO(LOGSTREAM, "Succesfully deleted a subtree starting at %s (%d nodes)",
|
|
|
|
+ argv[2],deletedCounter);
|
|
exit(0);
|
|
exit(0);
|
|
}
|
|
}
|
|
exit(1);
|
|
exit(1);
|
|
@@ -262,18 +262,18 @@ int main(int argc, char **argv) {
|
|
createRoot(argv[2]);
|
|
createRoot(argv[2]);
|
|
while(1) {
|
|
while(1) {
|
|
ensureConnected();
|
|
ensureConnected();
|
|
- LOG_INFO(("Creating children for path %s",argv[2]));
|
|
|
|
|
|
+ LOG_INFO(LOGSTREAM, "Creating children for path %s",argv[2]);
|
|
doCreateNodes(argv[2],nodeCount);
|
|
doCreateNodes(argv[2],nodeCount);
|
|
waitCounter();
|
|
waitCounter();
|
|
|
|
|
|
- LOG_INFO(("Starting the write cycle for path %s",argv[2]));
|
|
|
|
|
|
+ LOG_INFO(LOGSTREAM, "Starting the write cycle for path %s",argv[2]);
|
|
doWrites(argv[2],nodeCount);
|
|
doWrites(argv[2],nodeCount);
|
|
waitCounter();
|
|
waitCounter();
|
|
- LOG_INFO(("Starting the read cycle for path %s",argv[2]));
|
|
|
|
|
|
+ LOG_INFO(LOGSTREAM, "Starting the read cycle for path %s",argv[2]);
|
|
doReads(argv[2],nodeCount);
|
|
doReads(argv[2],nodeCount);
|
|
waitCounter();
|
|
waitCounter();
|
|
|
|
|
|
- LOG_INFO(("Starting the delete cycle for path %s",argv[2]));
|
|
|
|
|
|
+ LOG_INFO(LOGSTREAM, "Starting the delete cycle for path %s",argv[2]);
|
|
doDeletes(argv[2],nodeCount);
|
|
doDeletes(argv[2],nodeCount);
|
|
waitCounter();
|
|
waitCounter();
|
|
}
|
|
}
|