OmniSciDB  a667adc9c8
 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 66 of file SQLImporter.java.

Constructor & Destructor Documentation

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

Definition at line 99 of file SQLImporter.java.

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

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 73 of file SQLImporter.java.

References com.mapd.utility.SQLImporter_args.options.

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

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

+ Here is the caller graph for this function:

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

Definition at line 69 of file SQLImporter.java.

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

69  {
70  System.out.println("SQLImporter Version 4.6.0");
71  }

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