use of org.apache.accumulo.server.ServerContext in project accumulo by apache.
the class Manager method onlineTables.
@Override
public Set<TableId> onlineTables() {
Set<TableId> result = new HashSet<>();
if (getManagerState() != ManagerState.NORMAL) {
if (getManagerState() != ManagerState.UNLOAD_METADATA_TABLETS) {
result.add(MetadataTable.ID);
}
if (getManagerState() != ManagerState.UNLOAD_ROOT_TABLET) {
result.add(RootTable.ID);
}
return result;
}
ServerContext context = getContext();
TableManager manager = context.getTableManager();
for (TableId tableId : context.getTableIdToNameMap().keySet()) {
TableState state = manager.getTableState(tableId);
if ((state != null) && (state == TableState.ONLINE)) {
result.add(tableId);
}
}
return result;
}
use of org.apache.accumulo.server.ServerContext in project accumulo by apache.
the class CompactorTest method testCompactionInterrupted.
@Test
public void testCompactionInterrupted() throws Exception {
UUID uuid = UUID.randomUUID();
Supplier<UUID> supplier = () -> uuid;
ExternalCompactionId eci = ExternalCompactionId.generate(supplier.get());
PowerMock.resetAll();
PowerMock.suppress(PowerMock.methods(Halt.class, "halt"));
PowerMock.suppress(PowerMock.constructor(AbstractServer.class));
ServerAddress client = PowerMock.createNiceMock(ServerAddress.class);
HostAndPort address = HostAndPort.fromString("localhost:10240");
EasyMock.expect(client.getAddress()).andReturn(address);
TExternalCompactionJob job = PowerMock.createNiceMock(TExternalCompactionJob.class);
TKeyExtent extent = PowerMock.createNiceMock(TKeyExtent.class);
EasyMock.expect(job.isSetExternalCompactionId()).andReturn(true).anyTimes();
EasyMock.expect(job.getExternalCompactionId()).andReturn(eci.toString()).anyTimes();
EasyMock.expect(job.getExtent()).andReturn(extent).anyTimes();
EasyMock.expect(extent.getTable()).andReturn("testTable".getBytes()).anyTimes();
AccumuloConfiguration conf = PowerMock.createNiceMock(AccumuloConfiguration.class);
EasyMock.expect(conf.getTimeInMillis(Property.INSTANCE_ZK_TIMEOUT)).andReturn(86400000L);
ServerContext context = PowerMock.createNiceMock(ServerContext.class);
EasyMock.expect(context.getConfiguration()).andReturn(conf);
ZooReaderWriter zrw = PowerMock.createNiceMock(ZooReaderWriter.class);
ZooKeeper zk = PowerMock.createNiceMock(ZooKeeper.class);
EasyMock.expect(context.getZooReaderWriter()).andReturn(zrw).anyTimes();
EasyMock.expect(zrw.getZooKeeper()).andReturn(zk).anyTimes();
VolumeManagerImpl vm = PowerMock.createNiceMock(VolumeManagerImpl.class);
EasyMock.expect(context.getVolumeManager()).andReturn(vm);
vm.close();
PowerMock.replayAll();
InterruptedCompactor c = new InterruptedCompactor(supplier, client, job, conf, context, eci);
c.run();
PowerMock.verifyAll();
c.close();
assertFalse(c.isCompletedCalled());
assertTrue(c.isFailedCalled());
assertEquals(TCompactionState.CANCELLED, c.getLatestState());
}
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();
}
}
}
Aggregations