use of org.apache.accumulo.server.ServerContext in project accumulo by apache.
the class ServerUtilOpts method getServerContext.
public synchronized ServerContext getServerContext() {
if (context == null) {
if (getClientConfigFile() == null) {
context = new ServerContext(SiteConfiguration.auto());
} else {
ClientInfo info = ClientInfo.from(getClientProps());
context = ServerContext.override(SiteConfiguration.auto(), info.getInstanceName(), info.getZooKeepers(), info.getZooKeepersSessionTimeOut());
}
}
return context;
}
use of org.apache.accumulo.server.ServerContext in project accumulo by apache.
the class Admin method execute.
@SuppressFBWarnings(value = "DM_EXIT", justification = "System.exit okay for CLI tool")
@Override
public void execute(final String[] args) {
boolean everything;
AdminOpts opts = new AdminOpts();
JCommander cl = new JCommander(opts);
cl.setProgramName("accumulo admin");
CheckTabletsCommand checkTabletsCommand = new CheckTabletsCommand();
cl.addCommand("checkTablets", checkTabletsCommand);
ListInstancesCommand listIntancesOpts = new ListInstancesCommand();
cl.addCommand("listInstances", listIntancesOpts);
PingCommand pingCommand = new PingCommand();
cl.addCommand("ping", pingCommand);
DumpConfigCommand dumpConfigCommand = new DumpConfigCommand();
cl.addCommand("dumpConfig", dumpConfigCommand);
VolumesCommand volumesCommand = new VolumesCommand();
cl.addCommand("volumes", volumesCommand);
StopCommand stopOpts = new StopCommand();
cl.addCommand("stop", stopOpts);
StopAllCommand stopAllOpts = new StopAllCommand();
cl.addCommand("stopAll", stopAllOpts);
StopManagerCommand stopManagerOpts = new StopManagerCommand();
cl.addCommand("stopManager", stopManagerOpts);
StopMasterCommand stopMasterOpts = new StopMasterCommand();
cl.addCommand("stopMaster", stopMasterOpts);
RandomizeVolumesCommand randomizeVolumesOpts = new RandomizeVolumesCommand();
cl.addCommand("randomizeVolumes", randomizeVolumesOpts);
cl.parse(args);
if (opts.help || cl.getParsedCommand() == null) {
cl.usage();
return;
}
ServerContext context = opts.getServerContext();
AccumuloConfiguration conf = context.getConfiguration();
// Login as the server on secure HDFS
if (conf.getBoolean(Property.INSTANCE_RPC_SASL_ENABLED)) {
SecurityUtil.serverLogin(conf);
}
try {
int rc = 0;
if (cl.getParsedCommand().equals("listInstances")) {
ListInstances.listInstances(context.getZooKeepers(), listIntancesOpts.printAll, listIntancesOpts.printErrors);
} else if (cl.getParsedCommand().equals("ping")) {
if (ping(context, pingCommand.args) != 0)
rc = 4;
} else if (cl.getParsedCommand().equals("checkTablets")) {
System.out.println("\n*** Looking for offline tablets ***\n");
if (FindOfflineTablets.findOffline(context, checkTabletsCommand.tableName) != 0)
rc = 5;
System.out.println("\n*** Looking for missing files ***\n");
if (checkTabletsCommand.tableName == null) {
if (RemoveEntriesForMissingFiles.checkAllTables(context, checkTabletsCommand.fixFiles) != 0)
rc = 6;
} else {
if (RemoveEntriesForMissingFiles.checkTable(context, checkTabletsCommand.tableName, checkTabletsCommand.fixFiles) != 0)
rc = 6;
}
} else if (cl.getParsedCommand().equals("stop")) {
stopTabletServer(context, stopOpts.args, opts.force);
} else if (cl.getParsedCommand().equals("dumpConfig")) {
printConfig(context, dumpConfigCommand);
} else if (cl.getParsedCommand().equals("volumes")) {
ListVolumesUsed.listVolumes(context);
} else if (cl.getParsedCommand().equals("randomizeVolumes")) {
System.out.println(RV_DEPRECATION_MSG);
} else {
everything = cl.getParsedCommand().equals("stopAll");
if (everything)
flushAll(context);
stopServer(context, everything);
}
if (rc != 0)
System.exit(rc);
} catch (AccumuloException e) {
log.error("{}", e.getMessage(), e);
System.exit(1);
} catch (AccumuloSecurityException e) {
log.error("{}", e.getMessage(), e);
System.exit(2);
} catch (Exception e) {
log.error("{}", e.getMessage(), e);
System.exit(3);
} finally {
SingletonManager.setMode(Mode.CLOSED);
}
}
use of org.apache.accumulo.server.ServerContext in project accumulo by apache.
the class ChangeSecret method main.
public static void main(String[] args) throws Exception {
var siteConfig = SiteConfiguration.auto();
var hadoopConf = new Configuration();
Opts opts = new Opts();
ServerContext context = opts.getServerContext();
try (var fs = context.getVolumeManager()) {
ServerDirs serverDirs = new ServerDirs(siteConfig, hadoopConf);
verifyHdfsWritePermission(serverDirs, fs);
List<String> argsList = new ArrayList<>(args.length + 2);
argsList.add("--old");
argsList.add("--new");
argsList.addAll(Arrays.asList(args));
opts.parseArgs(ChangeSecret.class.getName(), args);
Span span = TraceUtil.startSpan(ChangeSecret.class, "main");
try (Scope scope = span.makeCurrent()) {
verifyAccumuloIsDown(context, opts.oldPass);
final InstanceId newInstanceId = InstanceId.of(UUID.randomUUID());
updateHdfs(serverDirs, fs, newInstanceId);
rewriteZooKeeperInstance(context, newInstanceId, opts.oldPass, opts.newPass);
if (opts.oldPass != null) {
deleteInstance(context, opts.oldPass);
}
System.out.println("New instance id is " + newInstanceId);
System.out.println("Be sure to put your new secret in accumulo.properties");
} finally {
span.end();
}
}
}
use of org.apache.accumulo.server.ServerContext in project accumulo by apache.
the class ECAdmin method execute.
@SuppressFBWarnings(value = "DM_EXIT", justification = "System.exit okay for CLI tool")
@Override
public void execute(final String[] args) {
ServerUtilOpts opts = new ServerUtilOpts();
JCommander cl = new JCommander(opts);
cl.setProgramName("accumulo ec-admin");
CancelCommand cancelOps = new CancelCommand();
cl.addCommand("cancel", cancelOps);
ListCompactorsCommand listCompactorsOpts = new ListCompactorsCommand();
cl.addCommand("listCompactors", listCompactorsOpts);
RunningCommand runningOpts = new RunningCommand();
cl.addCommand("running", runningOpts);
cl.parse(args);
if (opts.help || cl.getParsedCommand() == null) {
cl.usage();
return;
}
ServerContext context = opts.getServerContext();
try {
if (cl.getParsedCommand().equals("listCompactors")) {
listCompactorsByQueue(context);
} else if (cl.getParsedCommand().equals("cancel")) {
cancelCompaction(context, cancelOps.ecid);
} else if (cl.getParsedCommand().equals("running")) {
runningCompactions(context, runningOpts.details);
} else {
log.error("Unknown command {}", cl.getParsedCommand());
cl.usage();
System.exit(1);
}
} catch (Exception e) {
log.error("{}", e.getMessage(), e);
System.exit(1);
} finally {
SingletonManager.setMode(Mode.CLOSED);
}
}
use of org.apache.accumulo.server.ServerContext in project accumulo by apache.
the class LoginProperties method execute.
@Override
public void execute(String[] args) throws Exception {
try (var context = new ServerContext(SiteConfiguration.auto())) {
AccumuloConfiguration config = context.getConfiguration();
Authenticator authenticator = ClassLoaderUtil.loadClass(config.get(Property.INSTANCE_SECURITY_AUTHENTICATOR), Authenticator.class).getDeclaredConstructor().newInstance();
System.out.println("Supported token types for " + authenticator.getClass().getName() + " are : ");
for (Class<? extends AuthenticationToken> tokenType : authenticator.getSupportedTokenTypes()) {
System.out.println("\t" + tokenType.getName() + ", which accepts the following properties : ");
for (TokenProperty tokenProperty : tokenType.getDeclaredConstructor().newInstance().getProperties()) {
System.out.println("\t\t" + tokenProperty);
}
System.out.println();
}
}
}
Aggregations