OmniSciDB  a987f07e93
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
com.mapd.parser.server.CalciteServerCaller Class Reference
+ Collaboration diagram for com.mapd.parser.server.CalciteServerCaller:

Static Public Member Functions

static void main (String[] args)
 

Private Member Functions

void doWork (String[] args)
 
void help (Options options)
 

Static Private Member Functions

static Properties readPropertyFile (String fileName)
 

Private Attributes

SockTransportProperties client_skT = null
 
SockTransportProperties server_skT = null
 
CommandLine cmd = null
 

Static Private Attributes

static final Logger HEAVYDBLOGGER
 

Detailed Description

Definition at line 41 of file CalciteServerCaller.java.

Member Function Documentation

void com.mapd.parser.server.CalciteServerCaller.doWork ( String[]  args)
inlineprivate

Definition at line 53 of file CalciteServerCaller.java.

References run_benchmark_import.args, com.mapd.parser.server.CalciteServerCaller.client_skT, com.mapd.parser.server.CalciteServerCaller.cmd, com.mapd.parser.server.CalciteServerCaller.help(), run_benchmark_import.parser, run_benchmark_import.required, com.mapd.parser.server.CalciteServerCaller.server_skT, and com.mapd.parser.server.CalciteServerWrapper.shutdown.

53  {
54  CalciteServerWrapper calciteServerWrapper = null;
55 
56  // create Options object
57  Options options = new Options();
58 
59  Option port =
60  Option.builder("p").hasArg().desc("port number").longOpt("port").build();
61 
62  Option ssl_trust_store = Option.builder("T")
63  .hasArg()
64  .desc("SSL_trust_store")
65  .longOpt("trust_store")
66  .build();
67 
68  Option ssl_trust_passwd = Option.builder("P")
69  .hasArg()
70  .desc("SSL_trust_password")
71  .longOpt("trust_store_pw")
72  .build();
73 
74  Option ssl_keystore =
75  Option.builder("Y").hasArg().desc("SSL keystore").longOpt("keystore").build();
76 
77  Option ssl_keystore_password = Option.builder("Z")
78  .hasArg()
79  .desc("SSL keystore password")
80  .longOpt("keystore_password")
81  .build();
82 
83  Option dbPort = Option.builder("m")
84  .hasArg()
85  .desc("HEAVY.AI port number")
86  .longOpt("db_port")
87  .build();
88 
89  Option data = Option.builder("d")
90  .hasArg()
91  .desc("data directory")
92  .required()
93  .longOpt("data")
94  .build();
95 
96  Option extensions = Option.builder("e")
97  .hasArg()
98  .desc("extension signatures directory")
99  .longOpt("extensions")
100  .build();
101 
102  Option udf_file = Option.builder("u")
103  .hasArg()
104  .desc("User Defined Functions file path")
105  .longOpt("udf")
106  .build();
107 
108  Option config_file = Option.builder("c")
109  .hasArg()
110  .desc("Configuration file")
111  .longOpt("config")
112  .build();
113  options.addOption(port);
114  options.addOption(data);
115  options.addOption(extensions);
116  options.addOption(dbPort);
117  options.addOption(ssl_trust_store);
118  options.addOption(ssl_trust_passwd);
119  options.addOption(ssl_keystore);
120  options.addOption(ssl_keystore_password);
121  options.addOption(udf_file);
122  options.addOption(config_file);
123 
124  CommandLineParser parser = new DefaultParser();
125 
126  try {
127  cmd = parser.parse(options, args);
128  } catch (ParseException ex) {
129  HEAVYDBLOGGER.error(ex.getLocalizedMessage());
130  help(options);
131  exit(0);
132  }
133 
134  int portNum = Integer.valueOf(cmd.getOptionValue("port", "6279"));
135  int dbPortNum = Integer.valueOf(cmd.getOptionValue("db_port", "6274"));
136  String dataDir = cmd.getOptionValue("data", "data");
137  String extensionsDir = cmd.getOptionValue("extensions", "build/QueryEngine");
138  String trust_store = cmd.getOptionValue("trust_store", "");
139  String trust_store_pw = cmd.getOptionValue("trust_store_pw", "");
140  String key_store = cmd.getOptionValue("keystore", "");
141  String key_store_pw = cmd.getOptionValue("keystore_password", "");
142  String udfName = cmd.getOptionValue("udf", "");
143  String configuration_file = cmd.getOptionValue("config", "");
144 
145  final Path extensionFunctionsAstFile =
146  Paths.get(extensionsDir, "ExtensionFunctions.ast");
147 
148  // Add logging to our log files directories
149  Properties p = new Properties();
150  try {
151  p.load(getClass().getResourceAsStream("/log4j2.properties"));
152  } catch (IOException ex) {
153  HEAVYDBLOGGER.error(
154  "Could not load log4j property file from resources " + ex.getMessage());
155  }
156  p.put("log.dir", dataDir); // overwrite "log.dir"
157 
158  try {
159  Properties properties = null;
160  if (!configuration_file.isEmpty()) {
161  properties = CalciteServerCaller.readPropertyFile(configuration_file);
162  }
163  if (trust_store == null || trust_store.isEmpty()) {
164  client_skT = SockTransportProperties.getUnencryptedClient();
165  // client_skT = new SockTransportProperties(load_trust_store);
166  } else {
167  if (properties != null && trust_store_pw.isEmpty()) {
168  // If a configuration file was supplied and trust password is empty read
169  // properties it to get the trust store password
170  trust_store_pw = properties.getProperty("ssl-trust-password");
171  if (trust_store_pw == null) {
172  HEAVYDBLOGGER.warn("Failed to load trust store password from config file ["
173  + configuration_file + "] for trust store [" + trust_store + "]");
174  }
175  }
176  try {
177  client_skT = SockTransportProperties.getEncryptedClientSpecifiedTrustStore(
178  trust_store, trust_store_pw);
179  } catch (Exception eX) {
180  String error =
181  "Loading encrypted client SockTransportProperties failed. Error - "
182  + eX.toString();
183  throw new RuntimeException(error);
184  }
185  }
186  if (key_store != null && !key_store.isEmpty()) {
187  // If suppled a key store load a server transport, otherwise server_skT can stay
188  // as null If a configuration file was supplied read and password is empty read
189  // properties for key store password
190  if (properties != null && key_store_pw.isEmpty()) {
191  key_store_pw = properties.getProperty("ssl-keystore-password");
192  if (key_store_pw == null) {
193  String err = "Failed to load key store password from config file ["
194  + configuration_file + "] for key store [" + key_store + "]";
195  throw new RuntimeException(err);
196  }
197  }
198  try {
199  server_skT =
200  SockTransportProperties.getEncryptedServer(key_store, key_store_pw);
201  } catch (Exception eX) {
202  String error =
203  "Loading encrypted Server SockTransportProperties failed. Error - "
204  + eX.toString();
205  throw eX;
206  }
207  } else {
208  server_skT = SockTransportProperties.getUnecryptedServer();
209  }
210  } catch (Exception ex) {
211  HEAVYDBLOGGER.error("Error opening SocketTransport. " + ex.getMessage());
212  exit(0);
213  }
214 
215  Path udfPath;
216 
217  try {
218  if (!udfName.isEmpty()) {
219  udfPath = Paths.get(udfName);
220  }
221  } catch (FileSystemNotFoundException ex1) {
222  HEAVYDBLOGGER.error("Could not load udf file " + ex1.getMessage());
223  }
224 
225  calciteServerWrapper = new CalciteServerWrapper(portNum,
226  dbPortNum,
227  dataDir,
228  extensionFunctionsAstFile.toString(),
229  client_skT,
230  server_skT,
231  udfName);
232 
233  while (true) {
234  try {
235  calciteServerWrapper.run();
236  if (calciteServerWrapper.shutdown()) {
237  break;
238  }
239  try {
240  // wait for 4 secs before retry
241  Thread.sleep(4000);
242  } catch (InterruptedException ex) {
243  // noop
244  }
245  } catch (Exception x) {
246  x.printStackTrace();
247  }
248  }
249  }

+ Here is the call graph for this function:

void com.mapd.parser.server.CalciteServerCaller.help ( Options  options)
inlineprivate

Definition at line 251 of file CalciteServerCaller.java.

Referenced by com.mapd.parser.server.CalciteServerCaller.doWork().

251  {
252  // automatically generate the help statement
253  HelpFormatter formatter = new HelpFormatter();
254  formatter.printHelp("CalciteServerCaller", options);
255  }

+ Here is the caller graph for this function:

static void com.mapd.parser.server.CalciteServerCaller.main ( String[]  args)
inlinestatic

Definition at line 48 of file CalciteServerCaller.java.

References run_benchmark_import.args.

48  {
49  CalciteServerCaller csc = new CalciteServerCaller();
50  csc.doWork(args);
51  }
static Properties com.mapd.parser.server.CalciteServerCaller.readPropertyFile ( String  fileName)
inlinestaticprivate

Definition at line 257 of file CalciteServerCaller.java.

References parse_ast.line.

257  {
258  Properties properties = new Properties();
259  try {
260  BufferedReader bufferedReader = new BufferedReader(new FileReader(fileName));
261  StringBuffer sb = new StringBuffer();
262  for (String line = bufferedReader.readLine(); line != null;
263  line = bufferedReader.readLine()) {
264  if (line.toLowerCase().equals("[web]")) {
265  break;
266  }
267  line = line.replaceAll("[\",']", "");
268  sb.append(line + "\n");
269  }
270  properties.load(new StringReader(sb.toString()));
271  } catch (java.io.IOException iE) {
272  HEAVYDBLOGGER.warn("Could not load configuration file [" + fileName
273  + "] to get keystore/truststore password. Error - " + iE.toString());
274  }
275  return properties;
276  }
tuple line
Definition: parse_ast.py:10

Member Data Documentation

SockTransportProperties com.mapd.parser.server.CalciteServerCaller.client_skT = null
private
CommandLine com.mapd.parser.server.CalciteServerCaller.cmd = null
private
final Logger com.mapd.parser.server.CalciteServerCaller.HEAVYDBLOGGER
staticprivate
Initial value:
=
LoggerFactory.getLogger(CalciteServerCaller.class)

Definition at line 44 of file CalciteServerCaller.java.

SockTransportProperties com.mapd.parser.server.CalciteServerCaller.server_skT = null
private

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