OmniSciDB  29e35f4d58
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 72 of file SQLImporter.java.

Constructor & Destructor Documentation

◆ SQLImporter_args()

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

Definition at line 105 of file SQLImporter.java.

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

Member Function Documentation

◆ parse()

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

Definition at line 229 of file SQLImporter.java.

References run_benchmark_import.args, com.mapd.utility.MutuallyExlusiveOptionsException.create(), and Experimental.String.

Referenced by com.mapd.utility.SQLImporter.doWork().

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

◆ printHelpMessage()

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

Definition at line 79 of file SQLImporter.java.

Referenced by com.mapd.utility.SQLImporter.doWork().

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

◆ printVersion()

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

Definition at line 75 of file SQLImporter.java.

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

◆ setOptionRequired()

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

Definition at line 224 of file SQLImporter.java.

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

Member Data Documentation

◆ options

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

Definition at line 73 of file SQLImporter.java.


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