Search in sources :

Example 11 with Property

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);
}
Also used : Token(org.apache.accumulo.shell.Token) Property(org.apache.accumulo.core.conf.Property)

Example 12 with Property

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 };
    }
}
Also used : ServletContextHandler(org.eclipse.jetty.servlet.ServletContextHandler) AbstractConnectionFactory(org.eclipse.jetty.server.AbstractConnectionFactory) HttpConnectionFactory(org.eclipse.jetty.server.HttpConnectionFactory) SslConnectionFactory(org.eclipse.jetty.server.SslConnectionFactory) StringUtils(org.apache.commons.lang.StringUtils) ServerConnector(org.eclipse.jetty.server.ServerConnector) SslContextFactory(org.eclipse.jetty.util.ssl.SslContextFactory) ServletHolder(org.eclipse.jetty.servlet.ServletHolder) Server(org.eclipse.jetty.server.Server) EnumSet(java.util.EnumSet) Property(org.apache.accumulo.core.conf.Property) AccumuloConfiguration(org.apache.accumulo.core.conf.AccumuloConfiguration) SslContextFactory(org.eclipse.jetty.util.ssl.SslContextFactory) AbstractConnectionFactory(org.eclipse.jetty.server.AbstractConnectionFactory) HttpConnectionFactory(org.eclipse.jetty.server.HttpConnectionFactory) SslConnectionFactory(org.eclipse.jetty.server.SslConnectionFactory) Property(org.apache.accumulo.core.conf.Property)

Example 13 with Property

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();
}
Also used : Connector(org.apache.accumulo.core.client.Connector) ZipEntry(java.util.zip.ZipEntry) DefaultConfiguration(org.apache.accumulo.core.conf.DefaultConfiguration) OutputStreamWriter(java.io.OutputStreamWriter) Property(org.apache.accumulo.core.conf.Property) TableConfiguration(org.apache.accumulo.server.conf.TableConfiguration)

Example 14 with Property

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;
}
Also used : ConfigurationCopy(org.apache.accumulo.core.conf.ConfigurationCopy) Property(org.apache.accumulo.core.conf.Property)

Example 15 with Property

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;
}
Also used : Connector(org.apache.accumulo.core.client.Connector) AccumuloException(org.apache.accumulo.core.client.AccumuloException) AuthenticationToken(org.apache.accumulo.core.client.security.tokens.AuthenticationToken) IOException(java.io.IOException) Properties(org.apache.accumulo.core.client.security.tokens.AuthenticationToken.Properties) TableNotFoundException(org.apache.accumulo.core.client.TableNotFoundException) PasswordToken(org.apache.accumulo.core.client.security.tokens.PasswordToken) IteratorSetting(org.apache.accumulo.core.client.IteratorSetting) TableExistsException(org.apache.accumulo.core.client.TableExistsException) Property(org.apache.accumulo.core.conf.Property) AgeOffFilter(org.apache.accumulo.core.iterators.user.AgeOffFilter)

Aggregations

Property (org.apache.accumulo.core.conf.Property)40 Test (org.junit.Test)19 HashMap (java.util.HashMap)11 AccumuloConfiguration (org.apache.accumulo.core.conf.AccumuloConfiguration)11 File (java.io.File)8 Path (org.apache.hadoop.fs.Path)7 IOException (java.io.IOException)6 Map (java.util.Map)6 Predicate (java.util.function.Predicate)5 ConfigurationCopy (org.apache.accumulo.core.conf.ConfigurationCopy)5 VolumeManager (org.apache.accumulo.server.fs.VolumeManager)5 AccumuloException (org.apache.accumulo.core.client.AccumuloException)4 DefaultConfiguration (org.apache.accumulo.core.conf.DefaultConfiguration)4 TableConfiguration (org.apache.accumulo.server.conf.TableConfiguration)4 AccumuloSecurityException (org.apache.accumulo.core.client.AccumuloSecurityException)3 TableNotFoundException (org.apache.accumulo.core.client.TableNotFoundException)3 AccumuloServerContext (org.apache.accumulo.server.AccumuloServerContext)3 NamespaceConfiguration (org.apache.accumulo.server.conf.NamespaceConfiguration)3 TServerInstance (org.apache.accumulo.server.master.state.TServerInstance)3 ArrayList (java.util.ArrayList)2