OmniSciDB  a987f07e93
 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(
234  Option.builder("nprg")
235  .desc("Do not assign Render Groups to Polygons (faster import, but not renderable)")
236  .longOpt("noPolyRenderGroups")
237  .build());
238  }

Member Function Documentation

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

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

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

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

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

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