forgot to commit change_log_mode utility
git-svn-id: svn+ssh://svn.corp.yahoo.com/yahoo/yrl/labs/pnuts/code/logstore@2438 8dad8b1f-cf64-0410-95b6-bcf113ffbcfe
This commit is contained in:
parent
c42a275ab4
commit
65efc768a4
1 changed files with 45 additions and 0 deletions
45
util/change_log_mode.cpp
Normal file
45
util/change_log_mode.cpp
Normal file
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* change_log_mode.cpp
|
||||
*
|
||||
* Created on: Apr 20, 2011
|
||||
* Author: sears
|
||||
*/
|
||||
|
||||
|
||||
#include "../tcpclient.h"
|
||||
#include "../network.h"
|
||||
#include "../datatuple.h"
|
||||
|
||||
void usage(char * argv[]) {
|
||||
fprintf(stderr, "usage %s [host [port]]\n", argv[0]);
|
||||
}
|
||||
#include "util_main.h"
|
||||
int main(int argc, char * argv[]) {
|
||||
int mode = -1;
|
||||
char ** orig_argv = argv;
|
||||
if(argc > 1) {
|
||||
char * end;
|
||||
int n = strtod(argv[1], &end);
|
||||
if(argv[1][0] && !*end) {
|
||||
mode = n;
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
}
|
||||
if(mode == -1) { usage(orig_argv); return 1; }
|
||||
|
||||
logstore_handle_t * l = util_open_conn(argc, argv);
|
||||
|
||||
datatuple * tup = datatuple::create(&mode, sizeof(mode));
|
||||
|
||||
datatuple * ret = logstore_client_op(l, OP_DBG_SET_LOG_MODE, tup);
|
||||
|
||||
if(ret == NULL) {
|
||||
perror("Changing log mode failed.."); return 3;
|
||||
} else {
|
||||
datatuple::freetuple(ret);
|
||||
}
|
||||
logstore_client_close(l);
|
||||
printf("Log mode changed.\n");
|
||||
return 0;
|
||||
}
|
Loading…
Reference in a new issue