use of org.apache.accumulo.core.conf.Property in project accumulo by apache.
the class ConfigCommand method registerCompletion.
@Override
public void registerCompletion(final Token root, final Map<Command.CompletionSet, Set<String>> completionSet) {
final Token cmd = new Token(getName());
final Token sub = new Token("-" + setOpt.getOpt());
for (Property p : Property.values()) {
if (!(p.getKey().endsWith(".")) && !p.isExperimental()) {
sub.addSubcommand(new Token(p.toString()));
}
}
cmd.addSubcommand(sub);
root.addSubcommand(cmd);
}
use of org.apache.accumulo.core.conf.Property in project accumulo by apache.
the class EmbeddedWebServer method getConnectionFactories.
private static AbstractConnectionFactory[] getConnectionFactories(AccumuloConfiguration conf) {
HttpConnectionFactory httpFactory = new HttpConnectionFactory();
EnumSet<Property> requireForSecure = EnumSet.of(Property.MONITOR_SSL_KEYSTORE, Property.MONITOR_SSL_KEYSTOREPASS, Property.MONITOR_SSL_TRUSTSTORE, Property.MONITOR_SSL_TRUSTSTOREPASS);
if (requireForSecure.stream().map(p -> conf.get(p)).anyMatch(s -> s == null || s.isEmpty())) {
return new AbstractConnectionFactory[] { httpFactory };
} else {
SslContextFactory sslContextFactory = new SslContextFactory();
sslContextFactory.setKeyStorePath(conf.get(Property.MONITOR_SSL_KEYSTORE));
sslContextFactory.setKeyStorePassword(conf.get(Property.MONITOR_SSL_KEYSTOREPASS));
sslContextFactory.setKeyStoreType(conf.get(Property.MONITOR_SSL_KEYSTORETYPE));
sslContextFactory.setTrustStorePath(conf.get(Property.MONITOR_SSL_TRUSTSTORE));
sslContextFactory.setTrustStorePassword(conf.get(Property.MONITOR_SSL_TRUSTSTOREPASS));
sslContextFactory.setTrustStoreType(conf.get(Property.MONITOR_SSL_TRUSTSTORETYPE));
final String includedCiphers = conf.get(Property.MONITOR_SSL_INCLUDE_CIPHERS);
if (!Property.MONITOR_SSL_INCLUDE_CIPHERS.getDefaultValue().equals(includedCiphers)) {
sslContextFactory.setIncludeCipherSuites(StringUtils.split(includedCiphers, ','));
}
final String excludedCiphers = conf.get(Property.MONITOR_SSL_EXCLUDE_CIPHERS);
if (!Property.MONITOR_SSL_EXCLUDE_CIPHERS.getDefaultValue().equals(excludedCiphers)) {
sslContextFactory.setExcludeCipherSuites(StringUtils.split(excludedCiphers, ','));
}
final String includeProtocols = conf.get(Property.MONITOR_SSL_INCLUDE_PROTOCOLS);
if (null != includeProtocols && !includeProtocols.isEmpty()) {
sslContextFactory.setIncludeProtocols(StringUtils.split(includeProtocols, ','));
}
SslConnectionFactory sslFactory = new SslConnectionFactory(sslContextFactory, httpFactory.getProtocol());
return new AbstractConnectionFactory[] { sslFactory, httpFactory };
}
}
use of org.apache.accumulo.core.conf.Property in project accumulo by apache.
the class WriteExportFiles method exportConfig.
private static void exportConfig(AccumuloServerContext context, Table.ID tableID, ZipOutputStream zipOut, DataOutputStream dataOut) throws AccumuloException, AccumuloSecurityException, TableNotFoundException, IOException {
Connector conn = context.getConnector();
DefaultConfiguration defaultConfig = DefaultConfiguration.getInstance();
Map<String, String> siteConfig = conn.instanceOperations().getSiteConfiguration();
Map<String, String> systemConfig = conn.instanceOperations().getSystemConfiguration();
TableConfiguration tableConfig = context.getServerConfigurationFactory().getTableConfiguration(tableID);
OutputStreamWriter osw = new OutputStreamWriter(dataOut, UTF_8);
// only put props that are different than defaults and higher level configurations
zipOut.putNextEntry(new ZipEntry(Constants.EXPORT_TABLE_CONFIG_FILE));
for (Entry<String, String> prop : tableConfig) {
if (prop.getKey().startsWith(Property.TABLE_PREFIX.getKey())) {
Property key = Property.getPropertyByKey(prop.getKey());
if (key == null || !defaultConfig.get(key).equals(prop.getValue())) {
if (!prop.getValue().equals(siteConfig.get(prop.getKey())) && !prop.getValue().equals(systemConfig.get(prop.getKey()))) {
osw.append(prop.getKey() + "=" + prop.getValue() + "\n");
}
}
}
}
osw.flush();
}
use of org.apache.accumulo.core.conf.Property in project accumulo by apache.
the class FileOutputConfigurator method getAccumuloConfiguration.
/**
* This helper method provides an AccumuloConfiguration object constructed from the Accumulo defaults, and overridden with Accumulo properties that have been
* stored in the Job's configuration.
*
* @param implementingClass
* the class whose name will be used as a prefix for the property configuration key
* @param conf
* the Hadoop configuration object to configure
* @since 1.6.0
*/
public static AccumuloConfiguration getAccumuloConfiguration(Class<?> implementingClass, Configuration conf) {
String prefix = enumToConfKey(implementingClass, Opts.ACCUMULO_PROPERTIES) + ".";
ConfigurationCopy acuConf = new ConfigurationCopy(DefaultConfiguration.getInstance());
for (Entry<String, String> entry : conf) if (entry.getKey().startsWith(prefix)) {
String propString = entry.getKey().substring(prefix.length());
Property prop = Property.getPropertyByKey(propString);
if (prop != null) {
acuConf.set(prop, entry.getValue());
} else if (Property.isValidTablePropertyKey(propString)) {
acuConf.set(propString, entry.getValue());
} else {
throw new IllegalArgumentException("Unknown accumulo file property " + propString);
}
}
return acuConf;
}
use of org.apache.accumulo.core.conf.Property in project accumulo by apache.
the class TraceServer method ensureTraceTableExists.
/**
* Exceptions thrown out of here should be things that cause service failure (e.g. misconfigurations that aren't likely to change on retry).
*
* @return a working Connection that can be reused
* @throws ClassNotFoundException
* if TRACE_TOKEN_TYPE is set to a class that we can't load.
* @throws InstantiationException
* if we fail to create an instance of TRACE_TOKEN_TYPE.
* @throws IllegalAccessException
* if the class pointed to by TRACE_TOKEN_TYPE is private.
* @throws AccumuloSecurityException
* if the trace user has the wrong permissions
*/
private Connector ensureTraceTableExists(final AccumuloConfiguration conf) throws AccumuloSecurityException, ClassNotFoundException, InstantiationException, IllegalAccessException {
Connector connector = null;
while (true) {
try {
final boolean isDefaultTokenType = conf.get(Property.TRACE_TOKEN_TYPE).equals(Property.TRACE_TOKEN_TYPE.getDefaultValue());
String principal = conf.get(Property.TRACE_USER);
if (conf.getBoolean(Property.INSTANCE_RPC_SASL_ENABLED)) {
// Make sure that we replace _HOST if it exists in the principal
principal = SecurityUtil.getServerPrincipal(principal);
}
AuthenticationToken at;
Map<String, String> loginMap = conf.getAllPropertiesWithPrefix(Property.TRACE_TOKEN_PROPERTY_PREFIX);
if (loginMap.isEmpty() && isDefaultTokenType) {
// Assume the old type of user/password specification
Property p = Property.TRACE_PASSWORD;
at = new PasswordToken(conf.get(p).getBytes(UTF_8));
} else {
Properties props = new Properties();
AuthenticationToken token = AccumuloVFSClassLoader.getClassLoader().loadClass(conf.get(Property.TRACE_TOKEN_TYPE)).asSubclass(AuthenticationToken.class).newInstance();
int prefixLength = Property.TRACE_TOKEN_PROPERTY_PREFIX.getKey().length();
for (Entry<String, String> entry : loginMap.entrySet()) {
props.put(entry.getKey().substring(prefixLength), entry.getValue());
}
token.init(props);
at = token;
}
connector = instance.getConnector(principal, at);
if (!connector.tableOperations().exists(tableName)) {
connector.tableOperations().create(tableName);
IteratorSetting setting = new IteratorSetting(10, "ageoff", AgeOffFilter.class.getName());
AgeOffFilter.setTTL(setting, 7 * 24 * 60 * 60 * 1000l);
connector.tableOperations().attachIterator(tableName, setting);
}
connector.tableOperations().setProperty(tableName, Property.TABLE_FORMATTER_CLASS.getKey(), TraceFormatter.class.getName());
break;
} catch (AccumuloException | TableExistsException | TableNotFoundException | IOException | RuntimeException ex) {
log.info("Waiting to checking/create the trace table.", ex);
sleepUninterruptibly(1, TimeUnit.SECONDS);
}
}
return connector;
}
Aggregations