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);
}
}
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);
}
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);
}
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;
}
}
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);
}
Aggregations