use of org.apache.accumulo.server.conf.ServerConfigurationFactory in project accumulo by apache.
the class Admin method execute.
@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);
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;
}
AccumuloConfiguration siteConf = SiteConfiguration.getInstance();
// Login as the server on secure HDFS
if (siteConf.getBoolean(Property.INSTANCE_RPC_SASL_ENABLED)) {
SecurityUtil.serverLogin(siteConf);
}
Instance instance = opts.getInstance();
ServerConfigurationFactory confFactory = new ServerConfigurationFactory(instance);
try {
ClientContext context = new AccumuloServerContext(instance, confFactory);
int rc = 0;
if (cl.getParsedCommand().equals("listInstances")) {
ListInstances.listInstances(instance.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")) {
rc = RandomizeVolumes.randomize(context.getConnector(), randomizeVolumesOpts.tableName);
} 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);
}
}
use of org.apache.accumulo.server.conf.ServerConfigurationFactory in project accumulo by apache.
the class TabletServer method main.
public static void main(String[] args) throws IOException {
try {
final String app = "tserver";
ServerOpts opts = new ServerOpts();
opts.parseArgs(app, args);
SecurityUtil.serverLogin(SiteConfiguration.getInstance());
String hostname = opts.getAddress();
Instance instance = HdfsZooInstance.getInstance();
ServerConfigurationFactory conf = new ServerConfigurationFactory(instance);
VolumeManager fs = VolumeManagerImpl.get();
MetricsSystemHelper.configure(TabletServer.class.getSimpleName());
Accumulo.init(fs, instance, conf, app);
final TabletServer server = new TabletServer(instance, conf, fs);
server.config(hostname);
DistributedTrace.enable(hostname, app, conf.getSystemConfiguration());
if (UserGroupInformation.isSecurityEnabled()) {
UserGroupInformation loginUser = UserGroupInformation.getLoginUser();
loginUser.doAs(new PrivilegedExceptionAction<Void>() {
@Override
public Void run() {
server.run();
return null;
}
});
} else {
server.run();
}
} catch (Exception ex) {
log.error("Uncaught exception in TabletServer.main, exiting", ex);
System.exit(1);
} finally {
DistributedTrace.disable();
}
}
use of org.apache.accumulo.server.conf.ServerConfigurationFactory in project accumulo by apache.
the class TraceServer method main.
public static void main(String[] args) throws Exception {
final String app = "tracer";
ServerOpts opts = new ServerOpts();
opts.parseArgs(app, args);
loginTracer(SiteConfiguration.getInstance());
Instance instance = HdfsZooInstance.getInstance();
ServerConfigurationFactory conf = new ServerConfigurationFactory(instance);
VolumeManager fs = VolumeManagerImpl.get();
MetricsSystemHelper.configure(TraceServer.class.getSimpleName());
Accumulo.init(fs, instance, conf, app);
String hostname = opts.getAddress();
TraceServer server = new TraceServer(instance, conf, hostname);
try {
server.run();
} finally {
log.info("tracer stopping");
ZooReaderWriter.getInstance().getZooKeeper().close();
}
}
use of org.apache.accumulo.server.conf.ServerConfigurationFactory in project accumulo by apache.
the class ListBulkCommand method execute.
@Override
public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws Exception {
List<String> tservers;
MasterMonitorInfo stats;
MasterClientService.Iface client = null;
Instance instance = shellState.getInstance();
AccumuloServerContext context = new AccumuloServerContext(instance, new ServerConfigurationFactory(instance));
while (true) {
try {
client = MasterClient.getConnectionWithRetry(context);
stats = client.getMasterStats(Tracer.traceInfo(), context.rpcCreds());
break;
} catch (ThriftNotActiveServiceException e) {
// Let it loop, fetching a new location
sleepUninterruptibly(100, TimeUnit.MILLISECONDS);
} finally {
if (client != null)
MasterClient.close(client);
}
}
final boolean paginate = !cl.hasOption(disablePaginationOpt.getOpt());
if (cl.hasOption(tserverOption.getOpt())) {
tservers = new ArrayList<>();
tservers.add(cl.getOptionValue(tserverOption.getOpt()));
} else {
tservers = Collections.emptyList();
}
shellState.printLines(new BulkImportListIterator(tservers, stats), paginate);
return 0;
}
use of org.apache.accumulo.server.conf.ServerConfigurationFactory in project accumulo by apache.
the class NullTserver method main.
public static void main(String[] args) throws Exception {
Opts opts = new Opts();
opts.parseArgs(NullTserver.class.getName(), args);
// modify metadata
ZooKeeperInstance zki = new ZooKeeperInstance(ClientConfiguration.create().withInstance(opts.iname).withZkHosts(opts.keepers));
Instance inst = HdfsZooInstance.getInstance();
AccumuloServerContext context = new AccumuloServerContext(inst, new ServerConfigurationFactory(zki));
TransactionWatcher watcher = new TransactionWatcher();
ThriftClientHandler tch = new ThriftClientHandler(new AccumuloServerContext(inst, new ServerConfigurationFactory(inst)), watcher);
Processor<Iface> processor = new Processor<>(tch);
TServerUtils.startTServer(context.getConfiguration(), ThriftServerType.CUSTOM_HS_HA, processor, "NullTServer", "null tserver", 2, 1, 1000, 10 * 1024 * 1024, null, null, -1, HostAndPort.fromParts("0.0.0.0", opts.port));
HostAndPort addr = HostAndPort.fromParts(InetAddress.getLocalHost().getHostName(), opts.port);
Table.ID tableId = Tables.getTableId(zki, opts.tableName);
// read the locations for the table
Range tableRange = new KeyExtent(tableId, null, null).toMetadataRange();
List<Assignment> assignments = new ArrayList<>();
try (MetaDataTableScanner s = new MetaDataTableScanner(context, tableRange)) {
long randomSessionID = opts.port;
TServerInstance instance = new TServerInstance(addr, randomSessionID);
while (s.hasNext()) {
TabletLocationState next = s.next();
assignments.add(new Assignment(next.extent, instance));
}
}
// point them to this server
MetaDataStateStore store = new MetaDataStateStore(context);
store.setLocations(assignments);
while (true) {
sleepUninterruptibly(10, TimeUnit.SECONDS);
}
}
Aggregations