54 CalciteServerWrapper calciteServerWrapper = null;
57 Options options =
new Options();
60 Option.builder(
"p").hasArg().desc(
"port number").longOpt(
"port").build();
62 Option ssl_trust_store = Option.builder(
"T")
64 .desc(
"SSL_trust_store")
65 .longOpt(
"trust_store")
68 Option ssl_trust_passwd = Option.builder(
"P")
70 .desc(
"SSL_trust_password")
71 .longOpt(
"trust_store_pw")
75 Option.builder(
"Y").hasArg().desc(
"SSL keystore").longOpt(
"keystore").build();
77 Option ssl_keystore_password = Option.builder(
"Z")
79 .desc(
"SSL keystore password")
80 .longOpt(
"keystore_password")
83 Option dbPort = Option.builder(
"m")
85 .desc(
"HEAVY.AI port number")
89 Option data = Option.builder(
"d")
91 .desc(
"data directory")
96 Option extensions = Option.builder(
"e")
98 .desc(
"extension signatures directory")
99 .longOpt(
"extensions")
102 Option udf_file = Option.builder(
"u")
104 .desc(
"User Defined Functions file path")
108 Option config_file = Option.builder(
"c")
110 .desc(
"Configuration file")
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);
124 CommandLineParser
parser =
new DefaultParser();
127 cmd = parser.parse(options,
args);
128 }
catch (ParseException ex) {
129 HEAVYDBLOGGER.error(ex.getLocalizedMessage());
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",
"");
145 final Path extensionFunctionsAstFile =
146 Paths.get(extensionsDir,
"ExtensionFunctions.ast");
149 Properties p =
new Properties();
151 p.load(getClass().getResourceAsStream(
"/log4j2.properties"));
152 }
catch (IOException ex) {
154 "Could not load log4j property file from resources " + ex.getMessage());
156 p.put(
"log.dir", dataDir);
159 Properties properties = null;
160 if (!configuration_file.isEmpty()) {
161 properties = CalciteServerCaller.readPropertyFile(configuration_file);
163 if (trust_store == null || trust_store.isEmpty()) {
164 client_skT = SockTransportProperties.getUnencryptedClient();
167 if (properties != null && trust_store_pw.isEmpty()) {
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 +
"]");
177 client_skT = SockTransportProperties.getEncryptedClientSpecifiedTrustStore(
178 trust_store, trust_store_pw);
179 }
catch (Exception eX) {
181 "Loading encrypted client SockTransportProperties failed. Error - "
183 throw new RuntimeException(error);
186 if (key_store != null && !key_store.isEmpty()) {
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);
200 SockTransportProperties.getEncryptedServer(key_store, key_store_pw);
201 }
catch (Exception eX) {
203 "Loading encrypted Server SockTransportProperties failed. Error - "
208 server_skT = SockTransportProperties.getUnecryptedServer();
210 }
catch (Exception ex) {
211 HEAVYDBLOGGER.error(
"Error opening SocketTransport. " + ex.getMessage());
218 if (!udfName.isEmpty()) {
219 udfPath = Paths.get(udfName);
221 }
catch (FileSystemNotFoundException ex1) {
222 HEAVYDBLOGGER.error(
"Could not load udf file " + ex1.getMessage());
225 calciteServerWrapper =
new CalciteServerWrapper(portNum,
228 extensionFunctionsAstFile.toString(),
235 calciteServerWrapper.run();
236 if (calciteServerWrapper.shutdown()) {
242 }
catch (InterruptedException ex) {
245 }
catch (Exception x) {
void help(Options options)
SockTransportProperties server_skT
SockTransportProperties client_skT