@SuppressWarnings("deprecation") public static Properties toProperties( org.apache.accumulo.core.client.ClientConfiguration clientConf) { Properties props = new Properties(); Iterator<String> clientConfIter = clientConf.getKeys(); while (clientConfIter.hasNext()) { String confKey = clientConfIter.next(); String val = clientConf.getString(confKey); String propKey = confProps.get(confKey); if (propKey == null) { if (!confKey.equals( org.apache.accumulo.core.client.ClientConfiguration.ClientProperty.INSTANCE_RPC_SSL_CLIENT_AUTH .getKey())) { props.setProperty(confKey, val); } } else { props.setProperty(propKey, val); } } return props; }
/** * Gets all properties under the given prefix in this configuration. * * @param property * prefix property, must be of type PropertyType.PREFIX * @return a map of property keys to values * @throws IllegalArgumentException * if property is not a prefix */ public Map<String,String> getAllPropertiesWithPrefix(ClientProperty property) { checkType(property, PropertyType.PREFIX); Map<String,String> propMap = new HashMap<>(); String prefix = property.getKey(); if (prefix.endsWith(".")) { prefix = prefix.substring(0, prefix.length() - 1); } Iterator<?> iter = compositeConfig.getKeys(prefix); while (iter.hasNext()) { String p = (String) iter.next(); propMap.put(p, compositeConfig.getString(p)); } return propMap; }
public static ClientProperty getPropertyByKey(String key) { for (ClientProperty prop : ClientProperty.values()) if (prop.getKey().equals(key)) return prop; return null; } }
/** * Gets all properties under the given prefix in this configuration. * * @param property * prefix property, must be of type PropertyType.PREFIX * @return a map of property keys to values * @throws IllegalArgumentException * if property is not a prefix */ public Map<String,String> getAllPropertiesWithPrefix(ClientProperty property) { checkType(property, PropertyType.PREFIX); Map<String,String> propMap = new HashMap<>(); String prefix = property.getKey(); if (prefix.endsWith(".")) { prefix = prefix.substring(0, prefix.length() - 1); } Iterator<?> iter = this.getKeys(prefix); while (iter.hasNext()) { String p = (String) iter.next(); propMap.put(p, getString(p)); } return propMap; }
/** * Get the ZooKeepers. Use the value passed in (if there was one), then fall back to the * ClientConf, finally trying the accumulo-site.xml. * * @param keepers * ZooKeepers passed to the shell * @param clientConfig * ClientConfiguration instance * @return The ZooKeepers to connect to */ static String getZooKeepers(String keepers, ClientConfiguration clientConfig) { if (null != keepers) { return keepers; } if (clientConfig.containsKey(ClientProperty.INSTANCE_ZK_HOST.getKey())) { return clientConfig.get(ClientProperty.INSTANCE_ZK_HOST); } return SiteConfiguration.getInstance().get(Property.INSTANCE_ZK_HOST); }
public String getZooKeepers() { if (clientConf.containsKey(ClientProperty.INSTANCE_ZK_HOST.getKey())) { return clientConf.get(ClientProperty.INSTANCE_ZK_HOST); } String zookeepers = conf.get(ACCUMULO_STANDALONE_ZOOKEEPERS_KEY); if (null == zookeepers) { zookeepers = ACCUMULO_STANDALONE_ZOOKEEPERS_DEFAULT; } return zookeepers; }
/** * Same as {@link #setProperty(ClientProperty, String)} but returns the ClientConfiguration for * chaining purposes */ public ClientConfiguration with(ClientProperty prop, String value) { return with(prop.getKey(), value); }
public String getInstanceName() { if (clientConf.containsKey(ClientProperty.INSTANCE_NAME.getKey())) { return clientConf.get(ClientProperty.INSTANCE_NAME); } String instanceName = conf.get(ACCUMULO_STANDALONE_INSTANCE_NAME_KEY); if (null == instanceName) { instanceName = ACCUMULO_STANDALONE_INSTANCE_NAME_DEFAULT; } return instanceName; }
/** * Show whether SASL has been set on this configuration. * * @since 1.9.0 */ public boolean hasSasl() { return getBoolean(ClientProperty.INSTANCE_RPC_SASL_ENABLED.getKey(), Boolean.parseBoolean(ClientProperty.INSTANCE_RPC_SASL_ENABLED.getDefaultValue())); }
private void checkType(ClientProperty property, PropertyType type) { if (!property.getType().equals(type)) { String msg = "Configuration method intended for type " + type + " called with a " + property.getType() + " argument (" + property.getKey() + ")"; throw new IllegalArgumentException(msg); } }
public static ClientProperty getPropertyByKey(String key) { for (ClientProperty prop : ClientProperty.values()) if (prop.getKey().equals(key)) return prop; return null; } }
propsConf.put(ClientProperty.INSTANCE_ZOOKEEPERS.getKey(), org.apache.accumulo.core.client.ClientConfiguration.ClientProperty.INSTANCE_ZK_HOST .getKey()); propsConf.put(ClientProperty.INSTANCE_ZOOKEEPERS_TIMEOUT.getKey(), org.apache.accumulo.core.client.ClientConfiguration.ClientProperty.INSTANCE_ZK_TIMEOUT .getKey()); propsConf.put(ClientProperty.SSL_ENABLED.getKey(), org.apache.accumulo.core.client.ClientConfiguration.ClientProperty.INSTANCE_RPC_SSL_ENABLED .getKey()); propsConf.put(ClientProperty.SSL_KEYSTORE_PATH.getKey(), org.apache.accumulo.core.client.ClientConfiguration.ClientProperty.RPC_SSL_KEYSTORE_PATH .getKey()); propsConf.put(ClientProperty.SSL_KEYSTORE_TYPE.getKey(), org.apache.accumulo.core.client.ClientConfiguration.ClientProperty.RPC_SSL_KEYSTORE_TYPE .getKey()); propsConf.put(ClientProperty.SSL_KEYSTORE_PASSWORD.getKey(), org.apache.accumulo.core.client.ClientConfiguration.ClientProperty.RPC_SSL_KEYSTORE_PASSWORD .getKey()); propsConf.put(ClientProperty.SSL_TRUSTSTORE_PATH.getKey(), org.apache.accumulo.core.client.ClientConfiguration.ClientProperty.RPC_SSL_TRUSTSTORE_PATH .getKey()); propsConf.put(ClientProperty.SSL_TRUSTSTORE_TYPE.getKey(), org.apache.accumulo.core.client.ClientConfiguration.ClientProperty.RPC_SSL_TRUSTSTORE_TYPE .getKey()); propsConf.put(ClientProperty.SSL_TRUSTSTORE_PASSWORD.getKey(), org.apache.accumulo.core.client.ClientConfiguration.ClientProperty.RPC_SSL_TRUSTSTORE_PASSWORD .getKey()); propsConf.put(ClientProperty.SSL_USE_JSSE.getKey(), org.apache.accumulo.core.client.ClientConfiguration.ClientProperty.RPC_USE_JSSE.getKey());
for (org.apache.accumulo.core.client.ClientConfiguration.ClientProperty prop : org.apache.accumulo.core.client.ClientConfiguration.ClientProperty .values()) { clientKeys.add(prop.getKey());
private void checkType(ClientProperty property, PropertyType type) { if (!property.getType().equals(type)) { String msg = "Configuration method intended for type " + type + " called with a " + property.getType() + " argument (" + property.getKey() + ")"; throw new IllegalArgumentException(msg); } }
/** * Show whether SASL has been set on this configuration. * * @since 1.9.0 */ public boolean hasSasl() { return compositeConfig.getBoolean(ClientProperty.INSTANCE_RPC_SASL_ENABLED.getKey(), Boolean.parseBoolean(ClientProperty.INSTANCE_RPC_SASL_ENABLED.getDefaultValue())); }
/** * Same as {@link #setProperty(ClientProperty, String)} but returns the ClientConfiguration for * chaining purposes */ public ClientConfiguration with(ClientProperty prop, String value) { return with(prop.getKey(), value); }