List of usage examples for java.util Properties stringPropertyNames
public Set<String> stringPropertyNames()
From source file:adalid.commons.velocity.Writer.java
/** * Adds .string, .class, .instance, .programmer and .wrapper properties to the velocity context * *//*from ww w .j a v a2 s . c o m*/ @SuppressWarnings("unchecked") // unchecked cast private void putProperties(VelocityContext context, File propertiesFile) { String hint = HINT + "check property \"{0}\" at file \"{1}\""; String pattern1 = "failed to load {2}" + hint; String pattern2 = "failed to initialise {2}" + hint; String pattern3 = "{2} does not implement {3}" + hint; String pattern4 = "{2} is not a valid wrapper for {3}" + hint; String string1; String string2; String message; String argument; // Object object1; Object object2; Class<?> clazz1; Class<?> clazz2; Class<? extends Wrapper> wrapperClass; Class<? extends Wrappable> wrappableClass; Class<?> parameterType; String velocityKey; Properties properties = PropertiesHandler.loadProperties(propertiesFile); Set<String> stringPropertyNames = properties.stringPropertyNames(); for (String name : stringPropertyNames) { checkPropertyName(name, propertiesFile); if (StringUtils.endsWithIgnoreCase(name, DOT_STRING)) { string1 = StringUtils.removeEndIgnoreCase(name, DOT_STRING); string2 = StringUtils.trimToEmpty(properties.getProperty(name)); velocityKey = StrUtils.getCamelCase(string1, true); context.put(velocityKey, string2); } else if (StringUtils.endsWithIgnoreCase(name, DOT_CLASS)) { string1 = StringUtils.removeEndIgnoreCase(name, DOT_CLASS); string2 = StringUtils.trimToEmpty(properties.getProperty(name)); message = MessageFormat.format(pattern1, name, propertiesFile, string2); object2 = getClassForName(string2, message); if (object2 != null) { velocityKey = StrUtils.getCamelCase(string1, true); context.put(velocityKey, object2); continue; } throw new RuntimeException(message, new IllegalArgumentException(string2)); } else if (StringUtils.endsWithIgnoreCase(name, DOT_INSTANCE)) { string1 = StringUtils.removeEndIgnoreCase(name, DOT_INSTANCE); string2 = StringUtils.trimToEmpty(properties.getProperty(name)); message = MessageFormat.format(pattern2, name, propertiesFile, string2); object2 = getNewInstanceForName(string2, message); if (object2 != null) { velocityKey = StrUtils.getCamelCase(string1, true); context.put(velocityKey, object2); continue; } throw new RuntimeException(message, new IllegalArgumentException(string2)); } else if (StringUtils.endsWithIgnoreCase(name, DOT_PROGRAMMER)) { string1 = StringUtils.removeEndIgnoreCase(name, DOT_PROGRAMMER); string2 = StringUtils.trimToEmpty(properties.getProperty(name)); message = MessageFormat.format(pattern2, name, propertiesFile, string2); object2 = getNewInstanceForName(string2, message); if (object2 != null) { if (object2 instanceof Programmer) { velocityKey = StrUtils.getCamelCase(string1, true); context.put(velocityKey, object2); TLB.setProgrammer(velocityKey, (Programmer) object2); continue; } else { message = MessageFormat.format(pattern3, name, propertiesFile, string2, Programmer.class); } } throw new RuntimeException(message, new IllegalArgumentException(string2)); } else if (StringUtils.endsWithIgnoreCase(name, DOT_WRAPPER)) { string1 = StringUtils.removeEndIgnoreCase(name, DOT_WRAPPER); string2 = StringUtils.trimToEmpty(properties.getProperty(name)); message = MessageFormat.format(pattern1, name, propertiesFile, string1); argument = string1; clazz1 = getClassForName(string1, message); if (clazz1 != null) { if (Wrappable.class.isAssignableFrom(clazz1)) { message = MessageFormat.format(pattern1, name, propertiesFile, string2); argument = string2; clazz2 = getClassForName(string2, message); if (clazz2 != null) { if (Wrapper.class.isAssignableFrom(clazz2)) { wrapperClass = (Class<? extends Wrapper>) clazz2; // unchecked cast wrappableClass = (Class<? extends Wrappable>) clazz1; // unchecked cast parameterType = getConstructorParameterType(wrapperClass, wrappableClass); if (parameterType != null) { TLB.setWrapperClass(wrappableClass, wrapperClass); continue; } else { message = MessageFormat.format(pattern4, name, propertiesFile, wrapperClass, wrappableClass); } } else { message = MessageFormat.format(pattern3, name, propertiesFile, string2, Wrapper.class); } } } else { message = MessageFormat.format(pattern3, name, propertiesFile, string1, Wrappable.class); } } throw new RuntimeException(message, new IllegalArgumentException(argument)); } } }
From source file:com.impetus.ankush2.cassandra.monitor.CassandraClusterMonitor.java
/** * To get the list of configuration parameters. * // w w w . j av a2 s . c om * @throws Exception */ private void nodeparams() throws Exception { try { String host = (String) parameterMap.get(Constant.Keys.HOST); if (host == null || host.isEmpty()) { throw new AnkushException("Hostname is missing."); } Map resultInfo = new HashMap(); // checking Agent status if (!getAgentStatus(dbCluster, host)) { throw new AnkushException(Constant.Agent.AGENT_DOWN_MESSAGE); } // getting configuration directory location String confPath = FileNameUtils .convertToValidPath((String) advanceConf.get(CassandraConstants.ClusterProperties.CONF_DIR)); if (confPath == null) { throw new AnkushException("Could not get configuration path."); } // Reading content of each configuration file for (String file : getCassandraConfFiles(confPath)) { // getting file content String fileContent = SSHUtils.getFileContents(file, host, clusterConf.getAuthConf()); boolean edit = true; Map map = null; if (file.endsWith(Constant.File_Extension.YAML)) { // create yaml object. Yaml yaml = new Yaml(); // create map object by loading from yaml object map = (Map) yaml.load(fileContent); if (map.isEmpty()) { throw new AnkushException("Could not read file content: " + file); } // removing some properties from map removeKeyFromMap("seed_provider", map); removeKeyFromMap("server_encryption_options", map); removeKeyFromMap("client_encryption_options", map); map = prepareMapForYamlProperties(map); } else if (file.endsWith(Constant.File_Extension.PROPERTIES)) { if (file.contains( CassandraConstants.Cassandra_Configuration_Files.CASSANDRA_TOPOLOGY_PROPERTIES)) { edit = false; } Properties properties = new Properties(); // Converting string into Properties. properties.load(new StringReader(fileContent)); map = new HashMap<String, String>(); // Converting Properties into Map. for (final String name : properties.stringPropertyNames()) { List<Object> newParameterValue = new ArrayList<Object>(); newParameterValue.add(properties.getProperty(name)); newParameterValue.add(true); map.put(name, newParameterValue); } } else if (file.endsWith(Constant.File_Extension.XML)) { // TODO: logback.xml file handling map = new HashMap<String, String>(); } resultInfo.put(file.replace(confPath, ""), map); } Map params = new HashMap(); params.put("params", resultInfo); result.putAll(params); } catch (AnkushException e) { addAndLogError(e.getMessage()); } }
From source file:edu.snu.leader.hidden.ResultsReporter.java
/** * Initialize this reporter//from w w w. java2s . c o m * * @param simState */ public void initialize(SimulationState simState) { _LOG.trace("Entering initialize( simState )"); // Save the simulation state _simState = simState; // Grab the properties Properties props = simState.getProps(); // Build some variables int individualCount = _simState.getIndividualCount(); _movementCounts = new int[individualCount + 1]; _finalInitiatorCounts = new int[individualCount + 1]; _finalSuccessfulInitiatorCounts = new int[individualCount + 1]; _finalFailedInitiatorCounts = new int[individualCount + 1]; _maxInitiatorCounts = new int[individualCount + 1]; _maxSuccessfulInitiatorCounts = new int[individualCount + 1]; _maxFailedInitiatorCounts = new int[individualCount + 1]; // Load the results filename String resultsFile = props.getProperty(_RESULTS_FILE_KEY); Validate.notEmpty(resultsFile, "Results file may not be empty"); // Create the statistics writer try { _writer = new PrintWriter(new BufferedWriter(new FileWriter(resultsFile))); } catch (IOException ioe) { _LOG.error("Unable to open results file [" + resultsFile + "]", ioe); throw new RuntimeException("Unable to open results file [" + resultsFile + "]", ioe); } // Log the system properties to the stats file for future reference _writer.println("# Started: " + (new Date())); _writer.println(_SPACER); _writer.println("# Simulation properties"); _writer.println(_SPACER); List<String> keyList = new ArrayList<String>(props.stringPropertyNames()); Collections.sort(keyList); Iterator<String> iter = keyList.iterator(); while (iter.hasNext()) { String key = iter.next(); String value = props.getProperty(key); _writer.println("# " + key + " = " + value); } _writer.println(_SPACER); _writer.println(); _writer.flush(); // Do we log simulations? String useSimLogFileStr = props.getProperty(_USE_SIM_LOG_FILE_FLAG_KEY); if (null != useSimLogFileStr) { _useSimLogFile = Boolean.parseBoolean(useSimLogFileStr); _LOG.info("Using _useSimLogFile=[" + _useSimLogFile + "]"); } if (_useSimLogFile) { // Build the compressed simulation log file int lastDotIdx = resultsFile.lastIndexOf('.'); String simLogFile = resultsFile.substring(0, lastDotIdx) + ".log.gz"; _LOG.warn("Sending simulation log to [" + simLogFile + "]"); // Build the log writer try { _logWriter = new PrintWriter(new BufferedWriter( new OutputStreamWriter(new GZIPOutputStream(new FileOutputStream(simLogFile))))); } catch (IOException ioe) { _LOG.error("Unable to open simulation log file [" + simLogFile + "]", ioe); throw new RuntimeException("Unable to open simulation log file [" + simLogFile + "]", ioe); } } // Do we log locations? String useLocationLogFileStr = props.getProperty(_USE_LOCATION_LOG_FILE_FLAG_KEY); if (null != useLocationLogFileStr) { _useLocationLogFile = Boolean.parseBoolean(useLocationLogFileStr); _LOG.info("Using _useLocationLogFile=[" + _useLocationLogFile + "]"); } if (_useLocationLogFile) { // Build the compressed location log file int lastDotIdx = resultsFile.lastIndexOf('.'); String simLocationFile = resultsFile.substring(0, lastDotIdx) + ".locations"; // + ".locations.gz"; _LOG.warn("Sending location log to [" + simLocationFile + "]"); // Build the location log writer try { _locationWriter = new PrintWriter(new BufferedWriter(new OutputStreamWriter( // new GZIPOutputStream( new FileOutputStream(simLocationFile)))); // ); } catch (IOException ioe) { _LOG.error("Unable to open location log file [" + simLocationFile + "]", ioe); throw new RuntimeException("Unable to open location log file [" + simLocationFile + "]", ioe); } } _LOG.trace("Leaving initialize( simState )"); }
From source file:com.impetus.ankush2.cassandra.monitor.CassandraClusterMonitor.java
private void params() throws Exception { try {// w w w . j ava 2 s .co m Map resultInfo = new HashMap(); // checking Agent status if (!getAgentStatus(dbCluster, null)) { addAndLogError(Constant.Agent.AGENT_DOWN_MESSAGE); return; } // getting first host from the component node list for getting // configuration files content. String hostname = componentConfig.getNodes().keySet().iterator().next(); String confPath = FileNameUtils .convertToValidPath((String) advanceConf.get(CassandraConstants.ClusterProperties.CONF_DIR)); if (confPath == null) { throw new AnkushException("Could not get configuration path."); } // Reading content of each configuration file for (String file : getCassandraConfFiles(confPath)) { // getting file content String fileContent = SSHUtils.getFileContents(file, hostname, clusterConf.getAuthConf()); Map map = null; if (file.endsWith(Constant.File_Extension.YAML)) { // create yaml object. Yaml yaml = new Yaml(); // create map object by loading from yaml object map = (Map) yaml.load(fileContent); if (map.isEmpty()) { throw new AnkushException("Could not read file content: " + file); } // if(map.containsKey("data_file_directories")){ // System.out.println("class: " // + map.get("data_file_directories").getClass()); // // } // removing some properties from map removeKeyFromMap("initial_token", map); removeKeyFromMap("listen_address", map); removeKeyFromMap("rpc_address", map); removeKeyFromMap("num_tokens", map); removeKeyFromMap("seed_provider", map); removeKeyFromMap("server_encryption_options", map); removeKeyFromMap("client_encryption_options", map); map = prepareMapForYamlProperties(map); } else if (file.endsWith(Constant.File_Extension.PROPERTIES)) { Properties properties = new Properties(); // Converting string into Properties. properties.load(new StringReader(fileContent)); map = new HashMap<String, String>(); // Converting Properties into Map. for (final String name : properties.stringPropertyNames()) { List<Object> newParameterValue = new ArrayList<Object>(); newParameterValue.add(properties.getProperty(name)); newParameterValue.add(true); map.put(name, newParameterValue); } } else if (file.endsWith(Constant.File_Extension.XML)) { // TODO: logback.xml file handling map = new HashMap<String, String>(); } // List<String> fileList = new ArrayList<String>( // Arrays.asList(file.split("/"))); // resultInfo.put(fileList.get(fileList.size() - 1), map); resultInfo.put(file.replace(confPath, ""), map); } Map params = new HashMap(); params.put("params", resultInfo); result.putAll(params); } catch (Exception e) { addAndLogError(e.getMessage()); } }
From source file:org.apache.hadoop.hive.jdbc.storagehandler.JdbcStorageHandler.java
private void configureJobProperties(TableDesc tableDesc, Map<String, String> jobProperties) { if (LOG.isDebugEnabled()) { LOG.debug("tabelDesc: " + tableDesc); LOG.debug("jobProperties: " + jobProperties); }//from w w w . j a v a2s . com String tblName = tableDesc.getTableName(); Properties tblProps = tableDesc.getProperties(); String columnNames = tblProps.getProperty(Constants.LIST_COLUMNS); if (columnNames.length() == 0) { tblProps.setProperty(Constants.LIST_COLUMN_TYPES, JdbcSerDeHelper.columnTypeNames); tblProps.setProperty(Constants.LIST_COLUMNS, JdbcSerDeHelper.columnNames); columnNames = tblProps.getProperty(Constants.LIST_COLUMNS); } // Setting both mapred and mapreduce properties jobProperties.put(org.apache.hadoop.mapred.lib.db.DBConfiguration.INPUT_CLASS_PROPERTY, DbRecordWritable.class.getName()); jobProperties.put(org.apache.hadoop.mapred.lib.db.DBConfiguration.INPUT_TABLE_NAME_PROPERTY, tblName); jobProperties.put(org.apache.hadoop.mapred.lib.db.DBConfiguration.OUTPUT_TABLE_NAME_PROPERTY, tblName); jobProperties.put(org.apache.hadoop.mapred.lib.db.DBConfiguration.INPUT_FIELD_NAMES_PROPERTY, columnNames); jobProperties.put(org.apache.hadoop.mapred.lib.db.DBConfiguration.OUTPUT_FIELD_NAMES_PROPERTY, columnNames); jobProperties.put(org.apache.hadoop.mapreduce.lib.db.DBConfiguration.INPUT_CLASS_PROPERTY, DbRecordWritable.class.getName()); jobProperties.put(org.apache.hadoop.mapreduce.lib.db.DBConfiguration.INPUT_TABLE_NAME_PROPERTY, tblName); jobProperties.put(org.apache.hadoop.mapreduce.lib.db.DBConfiguration.OUTPUT_TABLE_NAME_PROPERTY, tblName); jobProperties.put(org.apache.hadoop.mapreduce.lib.db.DBConfiguration.INPUT_FIELD_NAMES_PROPERTY, columnNames); jobProperties.put(org.apache.hadoop.mapreduce.lib.db.DBConfiguration.OUTPUT_FIELD_NAMES_PROPERTY, columnNames); for (String key : tblProps.stringPropertyNames()) { if (key.startsWith("mapred.jdbc.")) { String value = tblProps.getProperty(key); jobProperties.put(key, value); key = key.replaceAll("mapred", "mapreduce"); jobProperties.put(key, value); } } for (String key : tblProps.stringPropertyNames()) { if (key.startsWith("mapreduce.jdbc.")) { String value = tblProps.getProperty(key); jobProperties.put(key, value); key = key.replaceAll("mapreduce", "mapred"); jobProperties.put(key, value); } } }
From source file:org.apache.sqoop.SqoopOptions.java
/** * This method encodes the property key values found in the provided * properties instance <tt>values</tt> into another properties instance * <tt>props</tt>. The specified <tt>prefix</tt> is used as a namespace * qualifier for keys when inserting. This allows easy introspection of the * property key values in <tt>props</tt> instance to later separate out all * the properties that belong to the <tt>values</tt> instance. * @param props the container properties instance * @param prefix the prefix for qualifying contained property keys. * @param values the contained properties instance, all of whose elements will * be added to the container properties instance. * * @see #getPropertiesAsNetstedProperties(Properties, String) *//* w w w . j a va 2 s .c o m*/ private void setPropertiesAsNestedProperties(Properties props, String prefix, Properties values) { String nestedPropertyPrefix = prefix + "."; if (null == values || values.size() == 0) { Iterator<String> it = props.stringPropertyNames().iterator(); while (it.hasNext()) { String name = it.next(); if (name.startsWith(nestedPropertyPrefix)) { props.remove(name); } } } else { Iterator<String> it = values.stringPropertyNames().iterator(); while (it.hasNext()) { String name = it.next(); putProperty(props, nestedPropertyPrefix + name, values.getProperty(name)); } } }
From source file:org.openhab.binding.garadget.internal.Connection.java
/** * Send a command to the Particle REST API (convenience function). * * @param device//from w ww. j a v a2 s . co m * the device context, or <code>null</code> if not needed for this command. * @param funcName * the function name to call, or variable/field to retrieve if <code>command</code> is * <code>null</code>. * @param user * the user name to use in Basic Authentication if the funcName would require Basic Authentication. * @param pass * the password to use in Basic Authentication if the funcName would require Basic Authentication. * @param command * the command to send to the API. * @param proc * a callback object that receives the status code and response body, or <code>null</code> if not * needed. */ public void sendCommand(AbstractDevice device, String funcName, String user, String pass, String command, HttpResponseHandler proc) { String url = null; String httpMethod = null; String content = null; String contentType = null; Properties headers = new Properties(); logger.trace("sendCommand: funcName={}", funcName); switch (funcName) { case "createToken": httpMethod = HTTP_POST; url = TOKEN_URL; content = command; contentType = APPLICATION_FORM_URLENCODED; break; case "deleteToken": httpMethod = HTTP_DELETE; url = String.format(ACCESS_TOKENS_URL, tokens.accessToken); break; case "getDevices": httpMethod = HTTP_GET; url = String.format(GET_DEVICES_URL, tokens.accessToken); break; default: url = String.format(DEVICE_FUNC_URL, device.getId(), funcName, tokens.accessToken); if (command == null) { // retrieve a variable httpMethod = HTTP_GET; } else { // call a function httpMethod = HTTP_POST; content = command; contentType = APPLICATION_JSON; } break; } HttpClient client = new HttpClient(); // Only perform basic authentication when we aren't using OAuth if (!url.contains("access_token=")) { Credentials credentials = new UsernamePasswordCredentials(user, pass); client.getParams().setAuthenticationPreemptive(true); client.getState().setCredentials(AuthScope.ANY, credentials); } HttpMethod method = createHttpMethod(httpMethod, url); method.getParams().setSoTimeout(timeout); method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler(3, false)); for (String httpHeaderKey : headers.stringPropertyNames()) { method.addRequestHeader(new Header(httpHeaderKey, headers.getProperty(httpHeaderKey))); logger.trace("Header key={}, value={}", httpHeaderKey, headers.getProperty(httpHeaderKey)); } try { // add content if a valid method is given ... if (method instanceof EntityEnclosingMethod && content != null) { EntityEnclosingMethod eeMethod = (EntityEnclosingMethod) method; eeMethod.setRequestEntity(new StringRequestEntity(content, contentType, null)); logger.trace("content='{}', contentType='{}'", content, contentType); } if (logger.isDebugEnabled()) { try { logger.debug("About to execute '{}'", method.getURI()); } catch (URIException e) { logger.debug(e.getMessage()); } } int statusCode = client.executeMethod(method); if (statusCode >= HttpStatus.SC_BAD_REQUEST) { logger.debug("Method failed: " + method.getStatusLine()); } String responseBody = IOUtils.toString(method.getResponseBodyAsStream()); if (!responseBody.isEmpty()) { logger.debug("Body of response: {}", responseBody); } if (proc != null) { proc.handleResponse(statusCode, responseBody); } } catch (HttpException he) { logger.warn("{}", he); } catch (IOException ioe) { logger.debug("{}", ioe); } finally { method.releaseConnection(); } }
From source file:org.apache.sqoop.SqoopOptions.java
/** * This method decodes the property key values found in the provided * properties instance <tt>props</tt> that have keys beginning with the * given prefix. Matching elements from this properties instance are modified * so that their prefix is dropped.//from ww w . j a va 2s . c om * @param props the properties container * @param prefix the prefix qualifying properties that need to be removed * @return a new properties instance that contains all matching elements from * the container properties. */ private Properties getPropertiesAsNetstedProperties(Properties props, String prefix) { Properties nestedProps = new Properties(); String nestedPropertyPrefix = prefix + "."; int index = nestedPropertyPrefix.length(); if (props != null && props.size() > 0) { Iterator<String> it = props.stringPropertyNames().iterator(); while (it.hasNext()) { String name = it.next(); if (name.startsWith(nestedPropertyPrefix)) { String shortName = name.substring(index); nestedProps.put(shortName, props.get(name)); } } } return nestedProps; }
From source file:org.tros.utils.PropertiesInitializer.java
/** * Initialize from properties file if possible. *///from ww w. j a v a2 s. co m private void initializeFromProperties() { try { Properties prop = new Properties(); String propFile = this.getClass().getPackage().getName().replace('.', '/') + '/' + this.getClass().getSimpleName() + ".properties"; java.util.Enumeration<URL> resources = ClassLoader.getSystemClassLoader().getResources(propFile); ArrayList<URL> urls = new ArrayList<>(); //HACK: semi sort classpath to put "files" first and "jars" second. //this has an impact once we are workin in tomcat where //the classes in tomcat are not stored in a jar. while (resources.hasMoreElements()) { URL url = resources.nextElement(); if (url.toString().startsWith("file:")) { urls.add(0, url); } else { boolean added = false; for (int ii = 0; !added && ii < urls.size(); ii++) { if (!urls.get(ii).toString().startsWith("file:")) { urls.add(ii, url); added = true; } } if (!added) { urls.add(url); } } } //reverse the list, so that the item found first in the //classpath will be the last one run though and thus //be the one to set the final value Collections.reverse(urls); PropertyDescriptor[] props = Introspector.getBeanInfo(this.getClass()).getPropertyDescriptors(); for (URL url : urls) { try { prop.load(url.openStream()); ArrayList<String> propKeys = new ArrayList<>(prop.stringPropertyNames()); for (PropertyDescriptor p : props) { if (p.getWriteMethod() != null && p.getReadMethod() != null && p.getReadMethod().getDeclaringClass() != Object.class) { boolean success = false; String val = prop.getProperty(p.getName()); if (val != null) { Object o = TypeHandler.fromString(p.getPropertyType(), val); if (o == null) { try { o = readValue(val, p.getPropertyType()); } catch (Exception ex) { o = null; LOGGER.warn(null, ex); LOGGER.warn( MessageFormat.format("PropertyName: {0}", new Object[] { val })); } } if (o != null) { p.getWriteMethod().invoke(this, o); success = true; } } if (!success && val != null) { // if (TypeHandler.isEnumeratedType(p)) { //// success = setEnumerated(p, val); // } else { success = setValueHelper(p, val); // } } if (success) { propKeys.remove(p.getName()); } } } for (String key : propKeys) { String value = prop.getProperty(key); setNameValuePair(key, value); } } catch (NullPointerException | IOException | IllegalArgumentException | InvocationTargetException ex) { } catch (IllegalAccessException ex) { LOGGER.warn(null, ex); } } } catch (IOException ex) { } catch (IntrospectionException ex) { LOGGER.warn(null, ex); } }
From source file:org.apache.hive.beeline.BeeLine.java
private boolean connectUsingArgs(BeelineParser beelineParser, CommandLine cl) { String driver = null, user = null, pass = "", url = null; String auth = null;// w ww . j av a 2 s . c om if (cl.hasOption("help")) { usage(); getOpts().setHelpAsked(true); return true; } Properties hiveVars = cl.getOptionProperties("hivevar"); for (String key : hiveVars.stringPropertyNames()) { getOpts().getHiveVariables().put(key, hiveVars.getProperty(key)); } Properties hiveConfs = cl.getOptionProperties("hiveconf"); for (String key : hiveConfs.stringPropertyNames()) { setHiveConfVar(key, hiveConfs.getProperty(key)); } driver = cl.getOptionValue("d"); auth = cl.getOptionValue("a"); user = cl.getOptionValue("n"); getOpts().setAuthType(auth); if (cl.hasOption("w")) { pass = obtainPasswordFromFile(cl.getOptionValue("w")); } else { if (beelineParser.isPasswordOptionSet) { pass = cl.getOptionValue("p"); } } url = cl.getOptionValue("u"); if ((url == null) && cl.hasOption("reconnect")) { // If url was not specified with -u, but -r was present, use that. url = getOpts().getLastConnectedUrl(); } getOpts().setInitFiles(cl.getOptionValues("i")); getOpts().setScriptFile(cl.getOptionValue("f")); if (url != null) { String com; String comForDebug; if (pass != null) { com = constructCmd(url, user, pass, driver, false); comForDebug = constructCmd(url, user, pass, driver, true); } else { com = constructCmdUrl(url, user, driver, false); comForDebug = constructCmdUrl(url, user, driver, true); } debug(comForDebug); return dispatch(com); } // load property file String propertyFile = cl.getOptionValue("property-file"); if (propertyFile != null) { try { this.consoleReader = new ConsoleReader(); } catch (IOException e) { handleException(e); } if (!dispatch("!properties " + propertyFile)) { exit = true; return false; } } return false; }