Search in sources :

Example 31 with AccumuloConfiguration

use of org.apache.accumulo.core.conf.AccumuloConfiguration in project accumulo by apache.

the class Initialize method execute.

@Override
public void execute(final String[] args) {
    Opts opts = new Opts();
    opts.parseArgs("accumulo init", args);
    try {
        zoo = ZooReaderWriter.getInstance();
        AccumuloConfiguration acuConf = SiteConfiguration.getInstance();
        SecurityUtil.serverLogin(acuConf);
        Configuration conf = CachedConfiguration.getInstance();
        VolumeManager fs = VolumeManagerImpl.get(acuConf);
        if (opts.resetSecurity) {
            log.info("Resetting security on accumulo.");
            Instance instance = HdfsZooInstance.getInstance();
            AccumuloServerContext context = new AccumuloServerContext(instance, new ServerConfigurationFactory(instance));
            if (isInitialized(fs)) {
                if (!opts.forceResetSecurity) {
                    ConsoleReader c = getConsoleReader();
                    String userEnteredName = c.readLine("WARNING: This will remove all users from Accumulo! If you wish to proceed enter the instance name: ");
                    if (userEnteredName != null && !instance.getInstanceName().equals(userEnteredName)) {
                        log.error("Aborted reset security: Instance name did not match current instance.");
                        return;
                    }
                }
                final String rootUser = getRootUserName(opts);
                opts.rootpass = getRootPassword(opts, rootUser);
                initSecurity(context, opts, HdfsZooInstance.getInstance().getInstanceID(), rootUser);
            } else {
                log.error("FATAL: Attempted to reset security on accumulo before it was initialized");
            }
        }
        if (opts.addVolumes) {
            addVolumes(fs);
        }
        if (!opts.resetSecurity && !opts.addVolumes)
            if (!doInit(opts, conf, fs))
                System.exit(-1);
    } catch (Exception e) {
        log.error("Fatal exception", e);
        throw new RuntimeException(e);
    }
}
Also used : VolumeManager(org.apache.accumulo.server.fs.VolumeManager) AccumuloServerContext(org.apache.accumulo.server.AccumuloServerContext) Configuration(org.apache.hadoop.conf.Configuration) VolumeConfiguration(org.apache.accumulo.core.volume.VolumeConfiguration) AccumuloConfiguration(org.apache.accumulo.core.conf.AccumuloConfiguration) SiteConfiguration(org.apache.accumulo.core.conf.SiteConfiguration) CachedConfiguration(org.apache.accumulo.core.util.CachedConfiguration) DefaultConfiguration(org.apache.accumulo.core.conf.DefaultConfiguration) ConsoleReader(jline.console.ConsoleReader) Instance(org.apache.accumulo.core.client.Instance) HdfsZooInstance(org.apache.accumulo.server.client.HdfsZooInstance) ServerConfigurationFactory(org.apache.accumulo.server.conf.ServerConfigurationFactory) ThriftSecurityException(org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) KeeperException(org.apache.zookeeper.KeeperException) AccumuloConfiguration(org.apache.accumulo.core.conf.AccumuloConfiguration)

Example 32 with AccumuloConfiguration

use of org.apache.accumulo.core.conf.AccumuloConfiguration in project accumulo by apache.

the class Initialize method getRootUserName.

private String getRootUserName(Opts opts) throws IOException {
    AccumuloConfiguration conf = SiteConfiguration.getInstance();
    final String keytab = conf.get(Property.GENERAL_KERBEROS_KEYTAB);
    if (keytab.equals(Property.GENERAL_KERBEROS_KEYTAB.getDefaultValue()) || !conf.getBoolean(Property.INSTANCE_RPC_SASL_ENABLED)) {
        return DEFAULT_ROOT_USER;
    }
    ConsoleReader c = getConsoleReader();
    c.println("Running against secured HDFS");
    if (null != opts.rootUser) {
        return opts.rootUser;
    }
    do {
        String user = c.readLine("Principal (user) to grant administrative privileges to : ");
        if (user == null) {
            // should not happen
            System.exit(1);
        }
        if (!user.isEmpty()) {
            return user;
        }
    } while (true);
}
Also used : ConsoleReader(jline.console.ConsoleReader) AccumuloConfiguration(org.apache.accumulo.core.conf.AccumuloConfiguration)

Example 33 with AccumuloConfiguration

use of org.apache.accumulo.core.conf.AccumuloConfiguration in project accumulo by apache.

the class Initialize method doInit.

public boolean doInit(Opts opts, Configuration conf, VolumeManager fs) throws IOException {
    if (!checkInit(conf, fs, SiteConfiguration.getInstance())) {
        return false;
    }
    // prompt user for instance name and root password early, in case they
    // abort, we don't leave an inconsistent HDFS/ZooKeeper structure
    String instanceNamePath;
    try {
        instanceNamePath = getInstanceNamePath(opts);
    } catch (Exception e) {
        log.error("FATAL: Failed to talk to zookeeper", e);
        return false;
    }
    String rootUser;
    try {
        rootUser = getRootUserName(opts);
    } catch (Exception e) {
        log.error("FATAL: Failed to obtain user for administrative privileges");
        return false;
    }
    // Don't prompt for a password when we're running SASL(Kerberos)
    final AccumuloConfiguration siteConf = SiteConfiguration.getInstance();
    if (siteConf.getBoolean(Property.INSTANCE_RPC_SASL_ENABLED)) {
        opts.rootpass = UUID.randomUUID().toString().getBytes(UTF_8);
    } else {
        opts.rootpass = getRootPassword(opts, rootUser);
    }
    return initialize(opts, instanceNamePath, fs, rootUser);
}
Also used : ThriftSecurityException(org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) KeeperException(org.apache.zookeeper.KeeperException) AccumuloConfiguration(org.apache.accumulo.core.conf.AccumuloConfiguration)

Example 34 with AccumuloConfiguration

use of org.apache.accumulo.core.conf.AccumuloConfiguration in project accumulo by apache.

the class ClientServiceHandler method checkTableClass.

@Override
public boolean checkTableClass(TInfo tinfo, TCredentials credentials, String tableName, String className, String interfaceMatch) throws TException, ThriftTableOperationException, ThriftSecurityException {
    security.authenticateUser(credentials, credentials);
    Table.ID tableId = checkTableId(instance, tableName, null);
    ClassLoader loader = getClass().getClassLoader();
    Class<?> shouldMatch;
    try {
        shouldMatch = loader.loadClass(interfaceMatch);
        AccumuloConfiguration conf = context.getServerConfigurationFactory().getTableConfiguration(tableId);
        String context = conf.get(Property.TABLE_CLASSPATH);
        ClassLoader currentLoader;
        if (context != null && !context.equals("")) {
            currentLoader = AccumuloVFSClassLoader.getContextManager().getClassLoader(context);
        } else {
            currentLoader = AccumuloVFSClassLoader.getClassLoader();
        }
        Class<?> test = currentLoader.loadClass(className).asSubclass(shouldMatch);
        test.newInstance();
        return true;
    } catch (Exception e) {
        log.warn("Error checking object types", e);
        return false;
    }
}
Also used : Table(org.apache.accumulo.core.client.impl.Table) AccumuloVFSClassLoader(org.apache.accumulo.start.classloader.vfs.AccumuloVFSClassLoader) TableNotFoundException(org.apache.accumulo.core.client.TableNotFoundException) NamespaceNotFoundException(org.apache.accumulo.core.client.NamespaceNotFoundException) ThriftSecurityException(org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) TException(org.apache.thrift.TException) IOException(java.io.IOException) AccumuloException(org.apache.accumulo.core.client.AccumuloException) ThriftTableOperationException(org.apache.accumulo.core.client.impl.thrift.ThriftTableOperationException) AccumuloConfiguration(org.apache.accumulo.core.conf.AccumuloConfiguration)

Example 35 with AccumuloConfiguration

use of org.apache.accumulo.core.conf.AccumuloConfiguration in project accumulo by apache.

the class ClientServiceHandler method getNamespaceConfiguration.

@Override
public Map<String, String> getNamespaceConfiguration(TInfo tinfo, TCredentials credentials, String ns) throws ThriftTableOperationException, TException {
    Namespace.ID namespaceId;
    try {
        namespaceId = Namespaces.getNamespaceId(instance, ns);
    } catch (NamespaceNotFoundException e) {
        String why = "Could not find namespace while getting configuration.";
        throw new ThriftTableOperationException(null, ns, null, TableOperationExceptionType.NAMESPACE_NOTFOUND, why);
    }
    AccumuloConfiguration config = context.getServerConfigurationFactory().getNamespaceConfiguration(namespaceId);
    return conf(credentials, config);
}
Also used : ThriftTableOperationException(org.apache.accumulo.core.client.impl.thrift.ThriftTableOperationException) Namespace(org.apache.accumulo.core.client.impl.Namespace) NamespaceNotFoundException(org.apache.accumulo.core.client.NamespaceNotFoundException) AccumuloConfiguration(org.apache.accumulo.core.conf.AccumuloConfiguration)

Aggregations

AccumuloConfiguration (org.apache.accumulo.core.conf.AccumuloConfiguration)117 Test (org.junit.Test)44 Path (org.apache.hadoop.fs.Path)26 ConfigurationCopy (org.apache.accumulo.core.conf.ConfigurationCopy)25 IOException (java.io.IOException)23 Configuration (org.apache.hadoop.conf.Configuration)19 HashMap (java.util.HashMap)17 ClientConfiguration (org.apache.accumulo.core.client.ClientConfiguration)13 Key (org.apache.accumulo.core.data.Key)13 DefaultConfiguration (org.apache.accumulo.core.conf.DefaultConfiguration)12 Property (org.apache.accumulo.core.conf.Property)12 Value (org.apache.accumulo.core.data.Value)12 ByteArrayInputStream (java.io.ByteArrayInputStream)11 DataInputStream (java.io.DataInputStream)11 FileSystem (org.apache.hadoop.fs.FileSystem)11 ArrayList (java.util.ArrayList)10 AccumuloSecurityException (org.apache.accumulo.core.client.AccumuloSecurityException)9 Text (org.apache.hadoop.io.Text)9 ByteArrayOutputStream (java.io.ByteArrayOutputStream)8 AccumuloException (org.apache.accumulo.core.client.AccumuloException)8