Search in sources :

Example 6 with ServerConfigurationFactory

use of org.apache.accumulo.server.conf.ServerConfigurationFactory in project accumulo by apache.

the class AccumuloReplicaSystem method replicate.

@Override
public Status replicate(final Path p, final Status status, final ReplicationTarget target, final ReplicaSystemHelper helper) {
    final Instance localInstance = HdfsZooInstance.getInstance();
    final AccumuloConfiguration localConf = new ServerConfigurationFactory(localInstance).getSystemConfiguration();
    log.debug("Replication RPC timeout is {}", localConf.get(Property.REPLICATION_RPC_TIMEOUT.getKey()));
    final String principal = getPrincipal(localConf, target);
    final File keytab;
    final String password;
    if (localConf.getBoolean(Property.INSTANCE_RPC_SASL_ENABLED)) {
        String keytabPath = getKeytab(localConf, target);
        keytab = new File(keytabPath);
        if (!keytab.exists() || !keytab.isFile()) {
            log.error("{} is not a regular file. Cannot login to replicate", keytabPath);
            return status;
        }
        password = null;
    } else {
        keytab = null;
        password = getPassword(localConf, target);
    }
    if (null != keytab) {
        try {
            final UserGroupInformation accumuloUgi = UserGroupInformation.getCurrentUser();
            // Get a UGI with the principal + keytab
            UserGroupInformation ugi = UserGroupInformation.loginUserFromKeytabAndReturnUGI(principal, keytab.getAbsolutePath());
            // Run inside a doAs to avoid nuking the Tserver's user
            return ugi.doAs(new PrivilegedAction<Status>() {

                @Override
                public Status run() {
                    KerberosToken token;
                    try {
                        // Do *not* replace the current user
                        token = new KerberosToken(principal, keytab);
                    } catch (IOException e) {
                        log.error("Failed to create KerberosToken", e);
                        return status;
                    }
                    ClientContext peerContext = getContextForPeer(localConf, target, principal, token);
                    return _replicate(p, status, target, helper, localConf, peerContext, accumuloUgi);
                }
            });
        } catch (IOException e) {
            // Can't log in, can't replicate
            log.error("Failed to perform local login", e);
            return status;
        }
    } else {
        // Simple case: make a password token, context and then replicate
        PasswordToken token = new PasswordToken(password);
        ClientContext peerContext = getContextForPeer(localConf, target, principal, token);
        return _replicate(p, status, target, helper, localConf, peerContext, null);
    }
}
Also used : Status(org.apache.accumulo.server.replication.proto.Replication.Status) Instance(org.apache.accumulo.core.client.Instance) ZooKeeperInstance(org.apache.accumulo.core.client.ZooKeeperInstance) HdfsZooInstance(org.apache.accumulo.server.client.HdfsZooInstance) KerberosToken(org.apache.accumulo.core.client.security.tokens.KerberosToken) ClientContext(org.apache.accumulo.core.client.impl.ClientContext) ServerConfigurationFactory(org.apache.accumulo.server.conf.ServerConfigurationFactory) IOException(java.io.IOException) PasswordToken(org.apache.accumulo.core.client.security.tokens.PasswordToken) File(java.io.File) RFile(org.apache.accumulo.core.file.rfile.RFile) AccumuloConfiguration(org.apache.accumulo.core.conf.AccumuloConfiguration) UserGroupInformation(org.apache.hadoop.security.UserGroupInformation)

Example 7 with ServerConfigurationFactory

use of org.apache.accumulo.server.conf.ServerConfigurationFactory 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 8 with ServerConfigurationFactory

use of org.apache.accumulo.server.conf.ServerConfigurationFactory in project accumulo by apache.

the class PerTableVolumeChooser method loadConfFactory.

// visible (not private) for testing
ServerConfigurationFactory loadConfFactory() {
    // This local variable is an intentional component of the single-check idiom.
    ServerConfigurationFactory localConf = lazyConfFactory;
    if (localConf == null) {
        // If we're under contention when first getting here we'll throw away some initializations.
        localConf = new ServerConfigurationFactory(HdfsZooInstance.getInstance());
        lazyConfFactory = localConf;
    }
    return localConf;
}
Also used : ServerConfigurationFactory(org.apache.accumulo.server.conf.ServerConfigurationFactory)

Example 9 with ServerConfigurationFactory

use of org.apache.accumulo.server.conf.ServerConfigurationFactory in project accumulo by apache.

the class ProblemReports method main.

public static void main(String[] args) throws Exception {
    Instance instance = HdfsZooInstance.getInstance();
    getInstance(new AccumuloServerContext(instance, new ServerConfigurationFactory(instance))).printProblems();
}
Also used : AccumuloServerContext(org.apache.accumulo.server.AccumuloServerContext) Instance(org.apache.accumulo.core.client.Instance) HdfsZooInstance(org.apache.accumulo.server.client.HdfsZooInstance) ServerConfigurationFactory(org.apache.accumulo.server.conf.ServerConfigurationFactory)

Example 10 with ServerConfigurationFactory

use of org.apache.accumulo.server.conf.ServerConfigurationFactory in project accumulo by apache.

the class Monitor method main.

public static void main(String[] args) throws Exception {
    final String app = "monitor";
    ServerOpts opts = new ServerOpts();
    opts.parseArgs(app, args);
    String hostname = opts.getAddress();
    SecurityUtil.serverLogin(SiteConfiguration.getInstance());
    VolumeManager fs = VolumeManagerImpl.get();
    instance = HdfsZooInstance.getInstance();
    config = new ServerConfigurationFactory(instance);
    context = new AccumuloServerContext(instance, config);
    log.info("Version " + Constants.VERSION);
    log.info("Instance " + instance.getInstanceID());
    MetricsSystemHelper.configure(Monitor.class.getSimpleName());
    Accumulo.init(fs, instance, config, app);
    Monitor monitor = new Monitor();
    // Servlets need access to limit requests when the monitor is not active, but Servlets are instantiated
    // via reflection. Expose the service this way instead.
    Monitor.HA_SERVICE_INSTANCE = monitor;
    DistributedTrace.enable(hostname, app, config.getSystemConfiguration());
    try {
        monitor.run(hostname);
    } finally {
        DistributedTrace.disable();
    }
}
Also used : VolumeManager(org.apache.accumulo.server.fs.VolumeManager) AccumuloServerContext(org.apache.accumulo.server.AccumuloServerContext) ServerOpts(org.apache.accumulo.server.ServerOpts) ServerConfigurationFactory(org.apache.accumulo.server.conf.ServerConfigurationFactory)

Aggregations

ServerConfigurationFactory (org.apache.accumulo.server.conf.ServerConfigurationFactory)30 Instance (org.apache.accumulo.core.client.Instance)23 AccumuloServerContext (org.apache.accumulo.server.AccumuloServerContext)17 HdfsZooInstance (org.apache.accumulo.server.client.HdfsZooInstance)13 IOException (java.io.IOException)8 AccumuloConfiguration (org.apache.accumulo.core.conf.AccumuloConfiguration)8 VolumeManager (org.apache.accumulo.server.fs.VolumeManager)8 AccumuloSecurityException (org.apache.accumulo.core.client.AccumuloSecurityException)7 SiteConfiguration (org.apache.accumulo.core.conf.SiteConfiguration)6 TServerInstance (org.apache.accumulo.server.master.state.TServerInstance)6 KeyExtent (org.apache.accumulo.core.data.impl.KeyExtent)5 ServerOpts (org.apache.accumulo.server.ServerOpts)5 KeeperException (org.apache.zookeeper.KeeperException)5 ArrayList (java.util.ArrayList)4 AccumuloException (org.apache.accumulo.core.client.AccumuloException)4 Connector (org.apache.accumulo.core.client.Connector)4 TableNotFoundException (org.apache.accumulo.core.client.TableNotFoundException)4 ClientContext (org.apache.accumulo.core.client.impl.ClientContext)4 Table (org.apache.accumulo.core.client.impl.Table)4 ThriftSecurityException (org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException)4