OmniSciDB  72c90bc290
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
com.mapd.utility.SQLImporter_args Class Reference
+ Collaboration diagram for com.mapd.utility.SQLImporter_args:

Public Member Functions

CommandLine parse (String[] args) throws ParseException
 

Package Functions

void printVersion ()
 
void printHelpMessage ()
 
 SQLImporter_args ()
 

Private Member Functions

Option setOptionRequired (Option option)
 

Private Attributes

Options options = new Options()
 

Detailed Description

Definition at line 68 of file SQLImporter.java.

Constructor & Destructor Documentation

com.mapd.utility.SQLImporter_args.SQLImporter_args ( )
inlinepackage

Definition at line 101 of file SQLImporter.java.

101  {
102  options.addOption("r", true, "Row Load Limit");
103 
104  // HEAVYAI authentication options
105  options.addOption(Option.builder("h").desc("help message").longOpt("help").build());
106  options.addOption(
107  Option.builder("u").hasArg().desc("HEAVYAI User").longOpt("user").build());
108  options.addOption(Option.builder("p")
109  .hasArg()
110  .desc("HEAVYAI Password")
111  .longOpt("passwd")
112  .build());
113  // HEAVYAI transport options
114  OptionGroup transport_grp = new OptionGroup();
115  transport_grp.addOption(Option.builder()
116  .desc("use binary transport to connect to HEAVYAI ")
117  .longOpt("binary")
118  .build());
119  transport_grp.addOption(Option.builder()
120  .desc("use http transport to connect to HEAVYAI ")
121  .longOpt("http")
122  .build());
123  transport_grp.addOption(Option.builder()
124  .desc("use https transport to connect to HEAVYAI ")
125  .longOpt("https")
126  .build());
127  options.addOptionGroup(transport_grp);
128 
129  // HEAVYAI database server details
130  options.addOption(Option.builder("s")
131  .hasArg()
132  .desc("HEAVYAI Server")
133  .longOpt("server")
134  .build());
135  options.addOption(Option.builder("db")
136  .hasArg()
137  .desc("HEAVYAI Database")
138  .longOpt("database")
139  .build());
140  options.addOption(
141  Option.builder().hasArg().desc("HEAVYAI Port").longOpt("port").build());
142 
143  // HEAVYAI server authentication options
144  options.addOption(Option.builder()
145  .hasArg()
146  .desc("CA certificate trust store")
147  .longOpt("ca-trust-store")
148  .build());
149  options.addOption(Option.builder()
150  .hasArg()
151  .desc("CA certificate trust store password")
152  .longOpt("ca-trust-store-passwd")
153  .build());
154  options.addOption(
155  Option.builder()
156  .desc("Insecure TLS - do not validate server HEAVYAI server credentials")
157  .longOpt("insecure")
158  .build());
159 
160  // Other database connection details
161  options.addOption(Option.builder("d")
162  .hasArg()
163  .desc("JDBC driver class")
164  .longOpt("driver")
165  .build());
166  options.addOption(Option.builder("c")
167  .hasArg()
168  .desc("JDBC Connection string")
169  .longOpt("jdbcConnect")
170  .required()
171  .build());
172  options.addOption(Option.builder("su")
173  .hasArg()
174  .desc("Source User")
175  .longOpt("sourceUser")
176  .required()
177  .build());
178  options.addOption(Option.builder("sp")
179  .hasArg()
180  .desc("Source Password")
181  .longOpt("sourcePasswd")
182  .required()
183  .build());
184  options.addOption(Option.builder("ss")
185  .hasArg()
186  .desc("SQL Select statement")
187  .longOpt("sqlStmt")
188  .required()
189  .build());
190 
191  options.addOption(Option.builder("t")
192  .hasArg()
193  .desc("HEAVYAI Target Table")
194  .longOpt("targetTable")
195  .required()
196  .build());
197 
198  options.addOption(Option.builder("b")
199  .hasArg()
200  .desc("transfer buffer size")
201  .longOpt("bufferSize")
202  .build());
203  options.addOption(Option.builder("f")
204  .hasArg()
205  .desc("table fragment size")
206  .longOpt("fragmentSize")
207  .build());
208 
209  options.addOption(Option.builder("tr")
210  .desc("Truncate table if it exists")
211  .longOpt("truncate")
212  .build());
213 
214  options.addOption(Option.builder("i")
215  .hasArg()
216  .desc("File containing init command for DB")
217  .longOpt("initializeFile")
218  .build());
219 
220  options.addOption(
221  Option.builder("adtf")
222  .desc("Allow double to float conversion, note precision will be reduced")
223  .longOpt("AllowDoubleToFloat")
224  .build());
225 
226  options.addOption(
227  Option.builder("ain")
228  .desc("Allow conversion from bigger integer types to smaller. Overflow might occur, "
229  + "use it only when casting is impossible")
230  .longOpt("AllowIntegerNarrowing")
231  .build());
232 
233  options.addOption(Option.builder("nlj")
234  .desc("Omit JDBC connection string from logs.")
235  .longOpt("no-log-jdbc-connection-string")
236  .build());
237  }

Member Function Documentation

CommandLine com.mapd.utility.SQLImporter_args.parse ( String[]  args) throws ParseException
inline

Definition at line 244 of file SQLImporter.java.

References run_benchmark_import.args, com.mapd.utility.SQLImporter_args.options, com.mapd.utility.SQLImporter_args.printHelpMessage(), com.mapd.utility.SQLImporter_args.printVersion(), and com.mapd.utility.SQLImporter_args.setOptionRequired().

244  {
245  CommandLineParser clp = new DefaultParser() {
246  public CommandLine parse(Options options, String[] strings) throws ParseException {
247  Options helpOptions = new Options();
248  helpOptions.addOption(
249  Option.builder("h").desc("help message").longOpt("help").build());
250  try {
251  CommandLine cmd = super.parse(helpOptions, strings);
252  } catch (UnrecognizedOptionException uE) {
253  }
254  if (cmd.hasOption("help")) {
256  exit(0);
257  }
258  if (cmd.hasOption("version")) {
259  printVersion();
260  exit(0);
261  }
262  cmd = super.parse(options, strings);
263  if (!cmd.hasOption("user") && !cmd.hasOption("client-cert")) {
264  throw new MissingArgumentException(
265  "Must supply either an HEAVYAI db user or a user certificate");
266  }
267  // if user supplied must have password and visa versa
268  if (cmd.hasOption("user") || cmd.hasOption("passwd")) {
269  options.addOption(setOptionRequired(options.getOption("user")));
270  options.addOption(setOptionRequired(options.getOption("passwd")));
271  super.parse(options, strings);
272  }
273 
274  // FUTURE USE FOR USER Auth if user client-cert supplied must have client-key
275  // and
276  // visa versa
277  if (false) {
278  if (cmd.hasOption("client-cert") || cmd.hasOption("client-key")) {
279  options.addOption(setOptionRequired(options.getOption("ca-trust-store")));
280  options.addOption(
281  setOptionRequired(options.getOption("ca-trust-store-password")));
282  super.parse(options, strings);
283  }
284  if (options.getOption("user").isRequired()
285  && options.getOption("client-key").isRequired()) {
286  MutuallyExlusiveOptionsException meo =
287  MutuallyExlusiveOptionsException.create(
288  "user/password can not be use with client-cert/client-key",
289  strings);
290  throw meo;
291  }
292 
293  if (cmd.hasOption("http")
294  || cmd.hasOption("binary")
295  && (cmd.hasOption("client-cert")
296  || cmd.hasOption("client-key"))) {
297  MutuallyExlusiveOptionsException meo = MutuallyExlusiveOptionsException.create(
298  "http|binary can not be use with ca-cert|client-cert|client-key",
299  strings);
300  }
301  }
302 
303  if (cmd.hasOption("insecure") && !cmd.hasOption("https")) {
304  MutuallyExlusiveOptionsException meo = MutuallyExlusiveOptionsException.create(
305  "insecure can only be use with https", strings);
306  throw meo;
307  }
308 
309  return cmd;
310  }
311 
312  public CommandLine parse(Options options, String[] strings, boolean b)
313  throws ParseException {
314  return null;
315  }
316  };
317  return clp.parse(options, args);
318  }
Option setOptionRequired(Option option)
CommandLine parse(String[] args)

+ Here is the call graph for this function:

void com.mapd.utility.SQLImporter_args.printHelpMessage ( )
inlinepackage

Definition at line 75 of file SQLImporter.java.

References com.mapd.utility.SQLImporter_args.options.

Referenced by com.mapd.utility.SQLImporter_args.parse().

75  {
76  StringBuffer sb = new StringBuffer("\nSQLImporter ");
77  // Ready for PKI auth
78  // sb.append("(-u <userid> -p <password> | --client-cert <key store filename>
79  sb.append("-u <userid> -p <password> [(--binary|--http|--https [--insecure])]\n");
80  sb.append("-s <omnisci server host> -db <omnisci db> --port <omnisci server port>\n");
81  // sb.append("([--ca-trust-store <ca trust store file name>]
82  // --ca-trust-store-password
83  // <trust store password> | --insecure)\n");
84  sb.append(
85  "[-d <other database JDBC drive class>] -c <other database JDBC connection string>\n");
86  sb.append(
87  "-su <other database user> -sp <other database user password> -ss <other database sql statement>\n");
88  sb.append(
89  "-t <HEAVYAI target table> -b <transfer buffer size> -f <table fragment size>\n");
90  sb.append("[-tr] [-adtf] [-nprg] -i <init commands file>\n");
91  sb.append("\nSQLImporter -h | --help\n\n");
92 
93  HelpFormatter formatter = new HelpFormatter();
94  // Forces help to print out options in order they were added rather
95  // than in alphabetical order
96  formatter.setOptionComparator(null);
97  int help_width = 100;
98  formatter.printHelp(help_width, sb.toString(), "", options, "");
99  }

+ Here is the caller graph for this function:

void com.mapd.utility.SQLImporter_args.printVersion ( )
inlinepackage

Definition at line 71 of file SQLImporter.java.

Referenced by com.mapd.utility.SQLImporter_args.parse().

71  {
72  System.out.println("SQLImporter Version 4.6.0");
73  }

+ Here is the caller graph for this function:

Option com.mapd.utility.SQLImporter_args.setOptionRequired ( Option  option)
inlineprivate

Definition at line 239 of file SQLImporter.java.

Referenced by com.mapd.utility.SQLImporter_args.parse().

239  {
240  option.setRequired(true);
241  return option;
242  }

+ Here is the caller graph for this function:

Member Data Documentation

Options com.mapd.utility.SQLImporter_args.options = new Options()
private

The documentation for this class was generated from the following file: