use of org.apache.accumulo.manager.Manager in project accumulo by apache.
the class FateAdmin method main.
public static void main(String[] args) throws Exception {
Help opts = new Help();
JCommander jc = new JCommander(opts);
jc.setProgramName(FateAdmin.class.getName());
LinkedHashMap<String, TxOpts> txOpts = new LinkedHashMap<>(2);
txOpts.put("fail", new FailOpts());
txOpts.put("delete", new DeleteOpts());
for (Entry<String, TxOpts> entry : txOpts.entrySet()) {
jc.addCommand(entry.getKey(), entry.getValue());
}
jc.addCommand("print", new PrintOpts());
jc.parse(args);
if (opts.help || jc.getParsedCommand() == null) {
jc.usage();
System.exit(1);
}
System.err.printf("This tool has been deprecated%nFATE administration now" + " available within 'accumulo shell'%n$ fate fail <txid>... | delete" + " <txid>... | print [<txid>...]%n%n");
AdminUtil<Manager> admin = new AdminUtil<>();
try (var context = new ServerContext(SiteConfiguration.auto())) {
final String zkRoot = context.getZooKeeperRoot();
String path = zkRoot + Constants.ZFATE;
var zLockManagerPath = ServiceLock.path(zkRoot + Constants.ZMANAGER_LOCK);
ZooReaderWriter zk = context.getZooReaderWriter();
ZooStore<Manager> zs = new ZooStore<>(path, zk);
if (jc.getParsedCommand().equals("fail")) {
for (String txid : txOpts.get(jc.getParsedCommand()).txids) {
if (!admin.prepFail(zs, zk, zLockManagerPath, txid)) {
System.exit(1);
}
}
} else if (jc.getParsedCommand().equals("delete")) {
for (String txid : txOpts.get(jc.getParsedCommand()).txids) {
if (!admin.prepDelete(zs, zk, zLockManagerPath, txid)) {
System.exit(1);
}
admin.deleteLocks(zk, zkRoot + Constants.ZTABLE_LOCKS, txid);
}
} else if (jc.getParsedCommand().equals("print")) {
admin.print(new ReadOnlyStore<>(zs), zk, zkRoot + Constants.ZTABLE_LOCKS);
}
}
}
use of org.apache.accumulo.manager.Manager in project accumulo by apache.
the class CompactRange method call.
@Override
public Repo<Manager> call(final long tid, Manager env) throws Exception {
String zTablePath = Constants.ZROOT + "/" + env.getInstanceID() + Constants.ZTABLES + "/" + tableId + Constants.ZTABLE_COMPACT_ID;
ZooReaderWriter zoo = env.getContext().getZooReaderWriter();
byte[] cid;
try {
cid = zoo.mutateExisting(zTablePath, currentValue -> {
String cvs = new String(currentValue, UTF_8);
String[] tokens = cvs.split(",");
long flushID = Long.parseLong(tokens[0]) + 1;
String txidString = String.format("%016x", tid);
for (int i = 1; i < tokens.length; i++) {
if (tokens[i].startsWith(txidString))
// skip self
continue;
log.debug("txidString : {}", txidString);
log.debug("tokens[{}] : {}", i, tokens[i]);
throw new AcceptableThriftTableOperationException(tableId.canonical(), null, TableOperation.COMPACT, TableOperationExceptionType.OTHER, "Another compaction with iterators and/or a compaction strategy is running");
}
StringBuilder encodedIterators = new StringBuilder();
if (config != null) {
Hex hex = new Hex();
encodedIterators.append(",");
encodedIterators.append(txidString);
encodedIterators.append("=");
encodedIterators.append(new String(hex.encode(config), UTF_8));
}
return (Long.toString(flushID) + encodedIterators).getBytes(UTF_8);
});
return new CompactionDriver(Long.parseLong(new String(cid, UTF_8).split(",")[0]), namespaceId, tableId, startRow, endRow);
} catch (NoNodeException nne) {
throw new AcceptableThriftTableOperationException(tableId.canonical(), null, TableOperation.COMPACT, TableOperationExceptionType.NOTFOUND, null);
}
}
use of org.apache.accumulo.manager.Manager in project accumulo by apache.
the class ManagerReplicationCoordinatorTest method randomServerFromMany.
@Test
public void randomServerFromMany() {
Manager manager = EasyMock.createMock(Manager.class);
ZooReader reader = EasyMock.createMock(ZooReader.class);
ServerContext context = EasyMock.createMock(ServerContext.class);
EasyMock.expect(context.getConfiguration()).andReturn(config).anyTimes();
EasyMock.expect(context.getInstanceID()).andReturn(InstanceId.of("1234")).anyTimes();
EasyMock.expect(context.getZooReaderWriter()).andReturn(null).anyTimes();
EasyMock.expect(manager.getInstanceID()).andReturn(InstanceId.of("1234")).anyTimes();
EasyMock.expect(manager.getContext()).andReturn(context).anyTimes();
EasyMock.replay(manager, context, reader);
ManagerReplicationCoordinator coordinator = new ManagerReplicationCoordinator(manager, reader);
EasyMock.verify(manager, reader);
TreeSet<TServerInstance> instances = new TreeSet<>();
TServerInstance inst1 = new TServerInstance(HostAndPort.fromParts("host1", 1234), "session");
instances.add(inst1);
TServerInstance inst2 = new TServerInstance(HostAndPort.fromParts("host2", 1234), "session");
instances.add(inst2);
assertEquals(inst1, coordinator.getRandomTServer(instances, 0));
assertEquals(inst2, coordinator.getRandomTServer(instances, 1));
}
use of org.apache.accumulo.manager.Manager in project accumulo by apache.
the class CompactionDriverTest method testTableBeingDeleted.
@Test
public void testTableBeingDeleted() throws Exception {
final InstanceId instance = InstanceId.of(UUID.randomUUID());
final long compactId = 123;
final long cancelId = 122;
final NamespaceId namespaceId = NamespaceId.of("14");
final TableId tableId = TableId.of("43");
final byte[] startRow = new byte[0];
final byte[] endRow = new byte[0];
Manager manager = EasyMock.createNiceMock(Manager.class);
ServerContext ctx = EasyMock.createNiceMock(ServerContext.class);
ZooReaderWriter zrw = EasyMock.createNiceMock(ZooReaderWriter.class);
EasyMock.expect(manager.getInstanceID()).andReturn(instance).anyTimes();
EasyMock.expect(manager.getContext()).andReturn(ctx);
EasyMock.expect(ctx.getZooReaderWriter()).andReturn(zrw);
final String zCancelID = CompactionDriver.createCompactionCancellationPath(instance, tableId);
EasyMock.expect(zrw.getData(zCancelID)).andReturn(Long.toString(cancelId).getBytes());
String deleteMarkerPath = PreDeleteTable.createDeleteMarkerPath(instance, tableId);
EasyMock.expect(zrw.exists(deleteMarkerPath)).andReturn(true);
EasyMock.replay(manager, ctx, zrw);
final CompactionDriver driver = new CompactionDriver(compactId, namespaceId, tableId, startRow, endRow);
final long tableIdLong = Long.parseLong(tableId.toString());
var e = assertThrows(AcceptableThriftTableOperationException.class, () -> driver.isReady(tableIdLong, manager));
assertTrue(e.getTableId().equals(tableId.toString()));
assertTrue(e.getOp().equals(TableOperation.COMPACT));
assertTrue(e.getType().equals(TableOperationExceptionType.OTHER));
assertTrue(e.getDescription().equals(TableOperationsImpl.TABLE_DELETED_MSG));
EasyMock.verify(manager, ctx, zrw);
}
use of org.apache.accumulo.manager.Manager in project accumulo by apache.
the class ReplicationMetricsTest method testAddReplicationQueueTimeMetrics.
@Test
public void testAddReplicationQueueTimeMetrics() throws Exception {
Manager manager = EasyMock.createMock(Manager.class);
ServerContext context = EasyMock.createMock(ServerContext.class);
VolumeManager fileSystem = EasyMock.createMock(VolumeManager.class);
ReplicationUtil util = EasyMock.createMock(ReplicationUtil.class);
MeterRegistry meterRegistry = EasyMock.createMock(MeterRegistry.class);
Timer timer = EasyMock.createMock(Timer.class);
Path path1 = new Path("hdfs://localhost:9000/accumulo/wal/file1");
Path path2 = new Path("hdfs://localhost:9000/accumulo/wal/file2");
// First call will initialize the map of paths to modification time
EasyMock.expect(manager.getContext()).andReturn(context).anyTimes();
EasyMock.expect(meterRegistry.timer("replicationQueue")).andReturn(timer).anyTimes();
EasyMock.expect(meterRegistry.gauge(EasyMock.eq("filesPendingReplication"), EasyMock.anyObject(AtomicLong.class))).andReturn(new AtomicLong(0)).anyTimes();
EasyMock.expect(meterRegistry.gauge(EasyMock.eq("numPeers"), EasyMock.anyObject(AtomicInteger.class))).andReturn(new AtomicInteger(0)).anyTimes();
EasyMock.expect(meterRegistry.gauge(EasyMock.eq("maxReplicationThreads"), EasyMock.anyObject(AtomicInteger.class))).andReturn(new AtomicInteger(0)).anyTimes();
EasyMock.expect(util.getPendingReplicationPaths()).andReturn(Set.of(path1, path2));
EasyMock.expect(manager.getVolumeManager()).andReturn(fileSystem);
EasyMock.expect(fileSystem.getFileStatus(path1)).andReturn(createStatus(100));
EasyMock.expect(manager.getVolumeManager()).andReturn(fileSystem);
EasyMock.expect(fileSystem.getFileStatus(path2)).andReturn(createStatus(200));
// Second call will recognize the missing path1 and add the latency stat
EasyMock.expect(util.getPendingReplicationPaths()).andReturn(Set.of(path2));
timer.record(EasyMock.isA(Duration.class));
EasyMock.expectLastCall();
EasyMock.replay(manager, fileSystem, util, meterRegistry, timer);
ReplicationMetrics metrics = new ReplicationMetricsTestMetrics(manager);
// Inject our mock objects
replaceField(metrics, "replicationUtil", util);
replaceField(metrics, "replicationQueueTimer", timer);
// Two calls to this will initialize the map and then add metrics
metrics.addReplicationQueueTimeMetrics();
metrics.addReplicationQueueTimeMetrics();
EasyMock.verify(manager, fileSystem, util, meterRegistry, timer);
}
Aggregations