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