keith-turner commented on code in PR #5028:
URL: https://github.com/apache/accumulo/pull/5028#discussion_r1835769576
##########
server/base/src/main/java/org/apache/accumulo/server/util/Admin.java:
##########
@@ -910,50 +939,111 @@ private void executeFateOpsCommand(ServerContext
context, FateOpsCommand fateOps
AdminUtil<Admin> admin = new AdminUtil<>(true);
final String zkRoot = context.getZooKeeperRoot();
- var zLockManagerPath = context.getServerPaths().createManagerPath();
var zTableLocksPath = context.getServerPaths().createTableLocksPath();
String fateZkPath = zkRoot + Constants.ZFATE;
ZooReaderWriter zk = context.getZooReaderWriter();
- MetaFateStore<Admin> mfs = new MetaFateStore<>(fateZkPath, zk,
createDummyLockID(), null);
- UserFateStore<Admin> ufs = new UserFateStore<>(context,
createDummyLockID(), null);
- Map<FateInstanceType,FateStore<Admin>> fateStores =
- Map.of(FateInstanceType.META, mfs, FateInstanceType.USER, ufs);
- Map<FateInstanceType,ReadOnlyFateStore<Admin>> readOnlyFateStores =
- Map.of(FateInstanceType.META, mfs, FateInstanceType.USER, ufs);
-
- if (fateOpsCommand.cancel) {
- cancelSubmittedFateTxs(context, fateOpsCommand.fateIdList);
- } else if (fateOpsCommand.fail) {
- for (String fateIdStr : fateOpsCommand.fateIdList) {
- if (!admin.prepFail(fateStores, zk, zLockManagerPath, fateIdStr)) {
- throw new AccumuloException("Could not fail transaction: " +
fateIdStr);
+ ServiceLock adminLock = null;
+ Map<FateInstanceType,FateStore<Admin>> fateStores;
+ Map<FateInstanceType,ReadOnlyFateStore<Admin>> readOnlyFateStores = null;
+
+ try {
+ if (fateOpsCommand.cancel) {
+ cancelSubmittedFateTxs(context, fateOpsCommand.fateIdList);
+ } else if (fateOpsCommand.fail) {
+ adminLock = createAdminLock(context);
+ fateStores = createFateStores(context, zk, fateZkPath, adminLock);
+ for (String fateIdStr : fateOpsCommand.fateIdList) {
+ if (!admin.prepFail(fateStores, fateIdStr)) {
+ throw new AccumuloException("Could not fail transaction: " +
fateIdStr);
+ }
}
+ } else if (fateOpsCommand.delete) {
+ adminLock = createAdminLock(context);
+ fateStores = createFateStores(context, zk, fateZkPath, adminLock);
+ for (String fateIdStr : fateOpsCommand.fateIdList) {
+ if (!admin.prepDelete(fateStores, fateIdStr)) {
+ throw new AccumuloException("Could not delete transaction: " +
fateIdStr);
+ }
+ admin.deleteLocks(zk, zTableLocksPath, fateIdStr);
+ }
+ }
+
+ if (fateOpsCommand.print) {
+ final Set<FateId> fateIdFilter = new TreeSet<>();
+ fateOpsCommand.fateIdList.forEach(fateIdStr ->
fateIdFilter.add(FateId.from(fateIdStr)));
+ EnumSet<ReadOnlyFateStore.TStatus> statusFilter =
+ getCmdLineStatusFilters(fateOpsCommand.states);
+ EnumSet<FateInstanceType> typesFilter =
+ getCmdLineInstanceTypeFilters(fateOpsCommand.instanceTypes);
+ readOnlyFateStores = createReadOnlyFateStores(context, zk, fateZkPath);
+ admin.print(readOnlyFateStores, zk, zTableLocksPath, new
Formatter(System.out),
+ fateIdFilter, statusFilter, typesFilter);
+ // print line break at the end
+ System.out.println();
}
- } else if (fateOpsCommand.delete) {
- for (String fateIdStr : fateOpsCommand.fateIdList) {
- if (!admin.prepDelete(fateStores, zk, zLockManagerPath, fateIdStr)) {
- throw new AccumuloException("Could not delete transaction: " +
fateIdStr);
+
+ if (fateOpsCommand.summarize) {
+ if (readOnlyFateStores == null) {
+ readOnlyFateStores = createReadOnlyFateStores(context, zk,
fateZkPath);
}
- admin.deleteLocks(zk, zTableLocksPath, fateIdStr);
+ summarizeFateTx(context, fateOpsCommand, admin, readOnlyFateStores,
zTableLocksPath);
+ }
+ } finally {
+ if (adminLock != null) {
+ adminLock.unlock();
}
}
+ }
- if (fateOpsCommand.print) {
- final Set<FateId> fateIdFilter = new TreeSet<>();
- fateOpsCommand.fateIdList.forEach(fateIdStr ->
fateIdFilter.add(FateId.from(fateIdStr)));
- EnumSet<ReadOnlyFateStore.TStatus> statusFilter =
- getCmdLineStatusFilters(fateOpsCommand.states);
- EnumSet<FateInstanceType> typesFilter =
- getCmdLineInstanceTypeFilters(fateOpsCommand.instanceTypes);
- admin.print(readOnlyFateStores, zk, zTableLocksPath, new
Formatter(System.out), fateIdFilter,
- statusFilter, typesFilter);
- // print line break at the end
- System.out.println();
- }
+ private Map<FateInstanceType,FateStore<Admin>>
createFateStores(ServerContext context,
+ ZooReaderWriter zk, String fateZkPath, ServiceLock adminLock)
+ throws InterruptedException, KeeperException {
+ var lockId = adminLock.getLockID();
+ MetaFateStore<Admin> mfs = new MetaFateStore<>(fateZkPath, zk, lockId,
null);
+ UserFateStore<Admin> ufs =
+ new UserFateStore<>(context, AccumuloTable.FATE.tableName(), lockId,
null);
+ return Map.of(FateInstanceType.META, mfs, FateInstanceType.USER, ufs);
+ }
- if (fateOpsCommand.summarize) {
- summarizeFateTx(context, fateOpsCommand, admin, readOnlyFateStores,
zTableLocksPath);
+ private Map<FateInstanceType,ReadOnlyFateStore<Admin>>
+ createReadOnlyFateStores(ServerContext context, ZooReaderWriter zk,
String fateZkPath)
+ throws InterruptedException, KeeperException {
+ MetaFateStore<Admin> readOnlyMFS = new MetaFateStore<>(fateZkPath, zk,
null, null);
+ UserFateStore<Admin> readOnlyUFS =
+ new UserFateStore<>(context, AccumuloTable.FATE.tableName(), null,
null);
+ return Map.of(FateInstanceType.META, readOnlyMFS, FateInstanceType.USER,
readOnlyUFS);
+ }
+
+ private ServiceLock createAdminLock(ServerContext context) throws
InterruptedException {
+ var zk = context.getZooReaderWriter().getZooKeeper();
+ UUID uuid = UUID.randomUUID();
+ ServiceLockPath slp = context.getServerPaths().createAdminLockPath();
+ ServiceLock adminLock = new
ServiceLock(context.getZooReaderWriter().getZooKeeper(), slp, uuid);
+ AdminLockWatcher lw = new AdminLockWatcher();
+ ServiceLockData.ServiceDescriptors descriptors = new
ServiceLockData.ServiceDescriptors();
+ descriptors.addService(new ServiceLockData.ServiceDescriptor(uuid,
+ ServiceLockData.ThriftService.NONE, "localhost",
Constants.DEFAULT_RESOURCE_GROUP_NAME));
Review Comment:
Could use something that is more distinct than localhost like
`fake_admin_util_host`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]