stasis-bLSM/util/change_log_mode.cpp
michim 49b4d4ebdb added some option to daemontools run script.
git-svn-id: svn+ssh://svn.corp.yahoo.com/yahoo/yrl/labs/pnuts/code/logstore@2548 8dad8b1f-cf64-0410-95b6-bcf113ffbcfe
2011-05-12 21:03:09 +00:00

45 lines
945 B
C++

/*
* 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 mode [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 = strtol(argv[1], &end, 10);
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;
}