kevinrr888 commented on code in PR #4524:
URL: https://github.com/apache/accumulo/pull/4524#discussion_r1688551699
##########
core/src/main/java/org/apache/accumulo/core/fate/FateStore.java:
##########
@@ -107,11 +118,155 @@ interface FateTxStore<T> extends ReadOnlyFateTxStore<T> {
void unreserve(Duration deferTime);
}
+ /**
+ * The value stored to indicate a FATE transaction ID ({@link FateId}) has
been reserved
+ */
+ class FateReservation {
+
+ // The LockID (provided by the Manager running the FATE which uses this
store) which is used for
+ // identifying dead Managers, so their reservations can be deleted and
picked up again since
+ // they can no longer be worked on.
+ private final ZooUtil.LockID lockID; // TODO 4131 not sure if this is the
best type for this
+ // The UUID generated on a reservation attempt (tryReserve()) used to
uniquely identify that
+ // attempt. This is useful for the edge case where the reservation is sent
to the server
+ // (Tablet Server for UserFateStore and the ZooKeeper Server for
MetaFateStore), but the server
+ // dies before the store receives the response. It allows us to determine
if the reservation
+ // was successful and was written by this reservation attempt (could have
been successfully
+ // reserved by another attempt or not reserved at all, in which case, we
wouldn't want to
+ // expose a FateTxStore).
+ private final UUID reservationUUID;
+ private final byte[] serialized;
+ private static final Pattern UUID_PATTERN =
+
Pattern.compile("^[0-9a-fA-F]{8}-([0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12}$");
+ private static final Pattern LOCKID_PATTERN =
Pattern.compile("^.+/.+\\$[0-9a-fA-F]+$");
+
+ private FateReservation(ZooUtil.LockID lockID, UUID reservationUUID) {
+ this.lockID = Objects.requireNonNull(lockID);
+ this.reservationUUID = Objects.requireNonNull(reservationUUID);
+ this.serialized = serialize(lockID, reservationUUID);
+ }
+
+ public static FateReservation from(ZooUtil.LockID lockID, UUID
reservationUUID) {
+ return new FateReservation(lockID, reservationUUID);
+ }
+
+ public static FateReservation from(byte[] serialized) {
+ try (DataInputBuffer buffer = new DataInputBuffer()) {
+ buffer.reset(serialized, serialized.length);
+ ZooUtil.LockID lockID = new ZooUtil.LockID("", buffer.readUTF());
+ UUID reservationUUID = UUID.fromString(buffer.readUTF());
+ return new FateReservation(lockID, reservationUUID);
+ } catch (IOException e) {
+ throw new UncheckedIOException(e);
+ }
+ }
+
+ public static FateReservation from(String fateReservationStr) {
+ if (isFateReservation(fateReservationStr)) {
+ String[] fields = fateReservationStr.split(":");
+ ZooUtil.LockID lockId = new ZooUtil.LockID("", fields[0]);
+ UUID reservationUUID = UUID.fromString(fields[1]);
+ return new FateReservation(lockId, reservationUUID);
+ } else {
+ throw new IllegalArgumentException(
+ "Tried to create a FateReservation from an invalid string: " +
fateReservationStr);
+ }
+ }
+
+ /**
+ *
+ * @param fateReservationStr the string from a call to {@link
FateReservation#toString()}
+ * @return true if the string represents a valid FateReservation object,
false otherwise
+ */
+ public static boolean isFateReservation(String fateReservationStr) {
+ if (fateReservationStr != null) {
+ String[] fields = fateReservationStr.split(":");
+ if (fields.length == 2) {
+ return LOCKID_PATTERN.matcher(fields[0]).matches()
+ && UUID_PATTERN.matcher(fields[1]).matches();
Review Comment:
No longer applicablevvvvvvvvv
##########
core/src/main/java/org/apache/accumulo/core/fate/FateStore.java:
##########
@@ -107,11 +118,155 @@ interface FateTxStore<T> extends ReadOnlyFateTxStore<T> {
void unreserve(Duration deferTime);
}
+ /**
+ * The value stored to indicate a FATE transaction ID ({@link FateId}) has
been reserved
+ */
+ class FateReservation {
+
+ // The LockID (provided by the Manager running the FATE which uses this
store) which is used for
+ // identifying dead Managers, so their reservations can be deleted and
picked up again since
+ // they can no longer be worked on.
+ private final ZooUtil.LockID lockID; // TODO 4131 not sure if this is the
best type for this
+ // The UUID generated on a reservation attempt (tryReserve()) used to
uniquely identify that
+ // attempt. This is useful for the edge case where the reservation is sent
to the server
+ // (Tablet Server for UserFateStore and the ZooKeeper Server for
MetaFateStore), but the server
+ // dies before the store receives the response. It allows us to determine
if the reservation
+ // was successful and was written by this reservation attempt (could have
been successfully
+ // reserved by another attempt or not reserved at all, in which case, we
wouldn't want to
+ // expose a FateTxStore).
+ private final UUID reservationUUID;
+ private final byte[] serialized;
+ private static final Pattern UUID_PATTERN =
+
Pattern.compile("^[0-9a-fA-F]{8}-([0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12}$");
+ private static final Pattern LOCKID_PATTERN =
Pattern.compile("^.+/.+\\$[0-9a-fA-F]+$");
+
+ private FateReservation(ZooUtil.LockID lockID, UUID reservationUUID) {
+ this.lockID = Objects.requireNonNull(lockID);
+ this.reservationUUID = Objects.requireNonNull(reservationUUID);
+ this.serialized = serialize(lockID, reservationUUID);
+ }
+
+ public static FateReservation from(ZooUtil.LockID lockID, UUID
reservationUUID) {
+ return new FateReservation(lockID, reservationUUID);
+ }
+
+ public static FateReservation from(byte[] serialized) {
+ try (DataInputBuffer buffer = new DataInputBuffer()) {
+ buffer.reset(serialized, serialized.length);
+ ZooUtil.LockID lockID = new ZooUtil.LockID("", buffer.readUTF());
+ UUID reservationUUID = UUID.fromString(buffer.readUTF());
+ return new FateReservation(lockID, reservationUUID);
+ } catch (IOException e) {
+ throw new UncheckedIOException(e);
+ }
+ }
+
+ public static FateReservation from(String fateReservationStr) {
+ if (isFateReservation(fateReservationStr)) {
+ String[] fields = fateReservationStr.split(":");
+ ZooUtil.LockID lockId = new ZooUtil.LockID("", fields[0]);
+ UUID reservationUUID = UUID.fromString(fields[1]);
+ return new FateReservation(lockId, reservationUUID);
+ } else {
+ throw new IllegalArgumentException(
+ "Tried to create a FateReservation from an invalid string: " +
fateReservationStr);
+ }
+ }
+
+ /**
+ *
+ * @param fateReservationStr the string from a call to {@link
FateReservation#toString()}
+ * @return true if the string represents a valid FateReservation object,
false otherwise
+ */
+ public static boolean isFateReservation(String fateReservationStr) {
+ if (fateReservationStr != null) {
+ String[] fields = fateReservationStr.split(":");
+ if (fields.length == 2) {
+ return LOCKID_PATTERN.matcher(fields[0]).matches()
+ && UUID_PATTERN.matcher(fields[1]).matches();
Review Comment:
No longer applicable
--
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]