OmniSciDB  1dac507f6e
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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 73 of file SQLImporter.java.

Constructor & Destructor Documentation

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

Definition at line 106 of file SQLImporter.java.

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

Member Function Documentation

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

Definition at line 230 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(), com.mapd.utility.SQLImporter_args.setOptionRequired(), and Experimental.String.

230  {
231  CommandLineParser clp = new DefaultParser() {
232  public CommandLine parse(Options options, String[] strings) throws ParseException {
233  Options helpOptions = new Options();
234  helpOptions.addOption(
235  Option.builder("h").desc("help message").longOpt("help").build());
236  try {
237  CommandLine cmd = super.parse(helpOptions, strings);
238  } catch (UnrecognizedOptionException uE) {
239  }
240  if (cmd.hasOption("help")) {
242  exit(0);
243  }
244  if (cmd.hasOption("version")) {
245  printVersion();
246  exit(0);
247  }
248  cmd = super.parse(options, strings);
249  if (!cmd.hasOption("user") && !cmd.hasOption("client-cert")) {
250  throw new MissingArgumentException(
251  "Must supply either an OmniSci db user or a user certificate");
252  }
253  // if user supplied must have password and visa versa
254  if (cmd.hasOption("user") || cmd.hasOption("passwd")) {
255  options.addOption(setOptionRequired(options.getOption("user")));
256  options.addOption(setOptionRequired(options.getOption("passwd")));
257  super.parse(options, strings);
258  }
259 
260  // FUTURE USE FOR USER Auth if user client-cert supplied must have client-key
261  // and
262  // visa versa
263  if (false) {
264  if (cmd.hasOption("client-cert") || cmd.hasOption("client-key")) {
265  options.addOption(setOptionRequired(options.getOption("ca-trust-store")));
266  options.addOption(
267  setOptionRequired(options.getOption("ca-trust-store-password")));
268  super.parse(options, strings);
269  }
270  if (options.getOption("user").isRequired()
271  && options.getOption("client-key").isRequired()) {
272  MutuallyExlusiveOptionsException meo =
273  MutuallyExlusiveOptionsException.create(
274  "user/password can not be use with client-cert/client-key",
275  strings);
276  throw meo;
277  }
278 
279  if (cmd.hasOption("http")
280  || cmd.hasOption("binary")
281  && (cmd.hasOption("client-cert")
282  || cmd.hasOption("client-key"))) {
283  MutuallyExlusiveOptionsException meo = MutuallyExlusiveOptionsException.create(
284  "http|binary can not be use with ca-cert|client-cert|client-key",
285  strings);
286  }
287  }
288 
289  if (cmd.hasOption("insecure") && !cmd.hasOption("https")) {
290  MutuallyExlusiveOptionsException meo = MutuallyExlusiveOptionsException.create(
291  "insecure can only be use with https", strings);
292  throw meo;
293  }
294 
295  return cmd;
296  }
297 
298  public CommandLine parse(Options options, String[] strings, boolean b)
299  throws ParseException {
300  return null;
301  }
302  };
303  return clp.parse(options, args);
304  }
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 80 of file SQLImporter.java.

References com.mapd.utility.SQLImporter_args.options.

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

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

+ Here is the caller graph for this function:

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

Definition at line 76 of file SQLImporter.java.

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

76  {
77  System.out.println("SQLImporter Version 4.6.0");
78  }

+ Here is the caller graph for this function:

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

Definition at line 225 of file SQLImporter.java.

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

225  {
226  option.setRequired(true);
227  return option;
228  }

+ 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: