csqlcacheserver reconnect, logger rotate, monitor_server
[csql.git] / src / tools / repltable.cxx
blobd4bc574ccc3599ebc175c650583f6f39fbc847fb
1 /***************************************************************************
2 * Copyright (C) 2007 by www.databasecache.com *
3 * Contact: praba_tuty@databasecache.com *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 ***************************************************************************/
16 #include <CSql.h>
17 #include <Network.h>
19 void printUsage()
21 printf("Usage: repltable [-U username] [-P passwd] -t tablename \n"
22 " [-m TSYNC|ASYNC>][-u] [-r] \n");
23 printf(" username -> username to connect with csql.\n");
24 printf(" passwd -> password for the above username to connect with csql.\n");
25 printf(" tablename -> table name to be replicated in csql with peers.\n");
26 printf(" u -> unreplicate the table\n");
27 printf(" r -> replicate and load all the records from peer site\n");
28 printf(" m -> replication mode for the table\n");
29 printf(" -> Modes could be one of TSYNC|ASYNC\n");
30 printf(" no option -> replicates with default mode ASYNC\n");
31 printf(" Note:Table should not have any records for this command to succeed\n");
32 return;
35 int main(int argc, char **argv)
37 char username[IDENTIFIER_LENGTH];
38 username [0] = '\0';
39 char password[IDENTIFIER_LENGTH];
40 password [0] = '\0';
41 int c = 0, opt = 10;
42 char tablename[IDENTIFIER_LENGTH];
43 char syncModeStr[IDENTIFIER_LENGTH];
44 bool tableNameSpecified = false;
45 while ((c = getopt(argc, argv, "U:P:t:l:m:u?")) != EOF)
47 switch (c)
49 case 'U' : { strcpy(username, argv[optind - 1]); opt=10; break; }
50 case 'P' : { strcpy(password, argv[optind - 1]); opt=10; break; }
51 case 't' : { strcpy(tablename, argv[optind - 1]);
52 if (opt==10) opt = 2;
53 tableNameSpecified = true;
54 break;
56 case '?' : { opt = 10; break; } //print help
57 case 'r' : { opt = 4; break; } //replicate the table
58 case 'u' : { opt = 5; break; } //unreplicate the table
59 default: opt=10;
62 }//while options
63 if (opt == 10) {
64 printUsage();
65 return 0;
68 //printf("%s %s \n", username, password);
69 if (username[0] == '\0' )
71 strcpy(username, "root");
72 strcpy(password, "manager");
74 DbRetVal rv = OK;
75 if (opt==2) {
77 return 0;