OmniSciDB  06b3bd477c
 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("Inseure 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  options.addOption(Option.builder("i")
212  .hasArg()
213  .desc("File containing init command for DB")
214  .longOpt("initializeFile")
215  .build());
216  }

Member Function Documentation

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

Definition at line 223 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().

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

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

218  {
219  option.setRequired(true);
220  return option;
221  }

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