OmniSciDB  8a228a1076
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 MAPDLOGGER
 

Detailed Description

Definition at line 41 of file CalciteServerCaller.java.

Member Function Documentation

◆ doWork()

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

Definition at line 53 of file CalciteServerCaller.java.

References com.mapd.parser.server.CalciteServerCaller.client_skT, com.mapd.common.SockTransportProperties.getEncryptedClientSpecifiedTrustStore(), com.mapd.common.SockTransportProperties.getEncryptedServer(), com.mapd.common.SockTransportProperties.getUnecryptedServer(), com.mapd.common.SockTransportProperties.getUnencryptedClient(), com.mapd.parser.server.CalciteServerCaller.help(), run_benchmark_import.parser, com.mapd.parser.server.CalciteServerCaller.readPropertyFile(), com.mapd.parser.server.CalciteServerWrapper.run(), com.mapd.parser.server.CalciteServerCaller.server_skT, and com.mapd.parser.server.CalciteServerWrapper.shutdown.

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

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 mapdPort = Option.builder("m")
84  .hasArg()
85  .desc("mapd port number")
86  .longOpt("mapd_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(mapdPort);
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  MAPDLOGGER.error(ex.getLocalizedMessage());
130  help(options);
131  exit(0);
132  }
133 
134  int portNum = Integer.valueOf(cmd.getOptionValue("port", "6279"));
135  int mapdPortNum = Integer.valueOf(cmd.getOptionValue("mapd_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("/log4j.properties"));
152  } catch (IOException ex) {
153  MAPDLOGGER.error(
154  "Could not load log4j property file from resources " + ex.getMessage());
155  }
156  p.put("log.dir", dataDir); // overwrite "log.dir"
157  PropertyConfigurator.configure(p);
158 
159  try {
160  Properties properties = null;
161  if (!configuration_file.isEmpty()) {
162  properties = CalciteServerCaller.readPropertyFile(configuration_file);
163  }
164  if (trust_store == null || trust_store.isEmpty()) {
165  client_skT = SockTransportProperties.getUnencryptedClient();
166  // client_skT = new SockTransportProperties(load_trust_store);
167  } else {
168  if (properties != null && trust_store_pw.isEmpty()) {
169  // If a configuration file was supplied and trust password is empty read
170  // properties it to get the trust store password
171  trust_store_pw = properties.getProperty("ssl-trust-password");
172  if (trust_store_pw == null) {
173  MAPDLOGGER.warn("Failed to load trust store password from config file ["
174  + configuration_file + "] for trust store [" + trust_store + "]");
175  }
176  }
177  try {
178  client_skT = SockTransportProperties.getEncryptedClientSpecifiedTrustStore(
179  trust_store, trust_store_pw);
180  } catch (Exception eX) {
181  String error =
182  "Loading encrypted client SockTransportProperties failed. Error - "
183  + eX.toString();
184  throw new RuntimeException(error);
185  }
186  }
187  if (key_store != null && !key_store.isEmpty()) {
188  // If suppled a key store load a server transport, otherwise server_skT can stay
189  // as null If a configuration file was supplied read and password is empty read
190  // properties for key store password
191  if (properties != null && key_store_pw.isEmpty()) {
192  key_store_pw = properties.getProperty("ssl-keystore-password");
193  if (key_store_pw == null) {
194  String err = "Failed to load key store password from config file ["
195  + configuration_file + "] for key store [" + key_store + "]";
196  throw new RuntimeException(err);
197  }
198  }
199  try {
200  server_skT =
201  SockTransportProperties.getEncryptedServer(key_store, key_store_pw);
202  } catch (Exception eX) {
203  String error =
204  "Loading encrypted Server SockTransportProperties failed. Error - "
205  + eX.toString();
206  throw eX;
207  }
208  } else {
209  server_skT = SockTransportProperties.getUnecryptedServer();
210  }
211  } catch (Exception ex) {
212  MAPDLOGGER.error("Error opening SocketTransport. " + ex.getMessage());
213  exit(0);
214  }
215 
216  Path udfPath;
217 
218  try {
219  if (!udfName.isEmpty()) {
220  udfPath = Paths.get(udfName);
221  }
222  } catch (FileSystemNotFoundException ex1) {
223  MAPDLOGGER.error("Could not load udf file " + ex1.getMessage());
224  }
225 
226  calciteServerWrapper = new CalciteServerWrapper(portNum,
227  mapdPortNum,
228  dataDir,
229  extensionFunctionsAstFile.toString(),
230  client_skT,
231  server_skT,
232  udfName);
233 
234  while (true) {
235  try {
236  calciteServerWrapper.run();
237  if (calciteServerWrapper.shutdown()) {
238  break;
239  }
240  try {
241  // wait for 4 secs before retry
242  Thread.sleep(4000);
243  } catch (InterruptedException ex) {
244  // noop
245  }
246  } catch (Exception x) {
247  x.printStackTrace();
248  }
249  }
250  }
static SockTransportProperties getEncryptedClientSpecifiedTrustStore(String trustStoreName, String trustStorePassword)
static SockTransportProperties getUnecryptedServer()
static SockTransportProperties getEncryptedServer(String keyStoreName, String keyStorePassword)
static SockTransportProperties getUnencryptedClient()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ help()

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

Definition at line 252 of file CalciteServerCaller.java.

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

252  {
253  // automatically generate the help statement
254  HelpFormatter formatter = new HelpFormatter();
255  formatter.printHelp("CalciteServerCaller", options);
256  }
+ Here is the caller graph for this function:

◆ main()

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

Definition at line 48 of file CalciteServerCaller.java.

References com.mapd.parser.server.CalciteServerCaller.doWork().

48  {
49  CalciteServerCaller csc = new CalciteServerCaller();
50  csc.doWork(args);
51  }
+ Here is the call graph for this function:

◆ readPropertyFile()

static Properties com.mapd.parser.server.CalciteServerCaller.readPropertyFile ( String  fileName)
inlinestaticprivate

Definition at line 258 of file CalciteServerCaller.java.

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

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

Member Data Documentation

◆ client_skT

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

◆ cmd

CommandLine com.mapd.parser.server.CalciteServerCaller.cmd = null
private

Definition at line 46 of file CalciteServerCaller.java.

◆ MAPDLOGGER

final Logger com.mapd.parser.server.CalciteServerCaller.MAPDLOGGER
staticprivate
Initial value:
=
LoggerFactory.getLogger(CalciteServerCaller.class)

Definition at line 44 of file CalciteServerCaller.java.

◆ server_skT

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

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