This is an automated email from the ASF dual-hosted git repository. kturner pushed a commit to branch elasticity in repository https://gitbox.apache.org/repos/asf/accumulo.git
The following commit(s) were added to refs/heads/elasticity by this push: new b9867c4c8c Deletes FateTxId (#4370) b9867c4c8c is described below commit b9867c4c8cd97b23800b1e129bfa492381ca74c2 Author: Kevin Rathbun <43969518+kevinrr...@users.noreply.github.com> AuthorDate: Fri Mar 15 19:08:52 2024 -0400 Deletes FateTxId (#4370) FateTxId has now been fully replaced by FateId, and can be safely deleted --- .../org/apache/accumulo/core/fate/FateTxId.java | 62 ---------------------- .../apache/accumulo/core/util/FastFormatTest.java | 13 ++--- 2 files changed, 5 insertions(+), 70 deletions(-) diff --git a/core/src/main/java/org/apache/accumulo/core/fate/FateTxId.java b/core/src/main/java/org/apache/accumulo/core/fate/FateTxId.java deleted file mode 100644 index ad0d5740af..0000000000 --- a/core/src/main/java/org/apache/accumulo/core/fate/FateTxId.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.accumulo.core.fate; - -import java.util.regex.Pattern; - -import org.apache.accumulo.core.util.FastFormat; - -import com.google.common.base.Preconditions; - -public class FateTxId { - - private static final String PREFIX = "FATE["; - private static final String SUFFIX = "]"; - - private final static Pattern PATTERN = - Pattern.compile(Pattern.quote(PREFIX) + "[0-9a-fA-F]+" + Pattern.quote(SUFFIX)); - - private static String getHex(String fmtTid) { - return fmtTid.substring(PREFIX.length(), fmtTid.length() - SUFFIX.length()); - } - - /** - * @return true if string was created by {@link #formatTid(long)} and false otherwise. - */ - public static boolean isFormatedTid(String fmtTid) { - return PATTERN.matcher(fmtTid).matches(); - } - - /** - * Reverses {@link #formatTid(long)} - */ - public static long fromString(String fmtTid) { - Preconditions.checkArgument(fmtTid.startsWith(PREFIX) && fmtTid.endsWith(SUFFIX)); - return Long.parseLong(getHex(fmtTid), 16); - } - - /** - * Formats transaction ids in a consistent way that is useful for logging and persisting. - */ - public static String formatTid(long tid) { - // do not change how this formats without considering implications for persistence - return FastFormat.toHexString(PREFIX, tid, SUFFIX); - } - -} diff --git a/core/src/test/java/org/apache/accumulo/core/util/FastFormatTest.java b/core/src/test/java/org/apache/accumulo/core/util/FastFormatTest.java index 40da603e4a..8e68d87a34 100644 --- a/core/src/test/java/org/apache/accumulo/core/util/FastFormatTest.java +++ b/core/src/test/java/org/apache/accumulo/core/util/FastFormatTest.java @@ -24,7 +24,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows; import java.util.Arrays; -import org.apache.accumulo.core.fate.FateTxId; +import org.apache.accumulo.core.fate.FateId; import org.junit.jupiter.api.Test; public class FastFormatTest { @@ -121,13 +121,10 @@ public class FastFormatTest { @Test public void testHexString() { - final String PREFIX = "FATE["; - final String SUFFIX = "]"; - String formattedTxId = FateTxId.formatTid(64L); - String hexStr = FastFormat.toHexString(PREFIX, 64L, SUFFIX); - assertEquals(formattedTxId, hexStr); - long txid = FateTxId.fromString("FATE[2e429160071c63d8]"); - assertEquals("FATE[2e429160071c63d8]", FastFormat.toHexString(PREFIX, txid, SUFFIX)); + String prefix = "FATE:USER:"; + assertEquals(FateId.formatTid(987654321L), FastFormat.toHexString(987654321L)); + long txid = FateId.from(prefix + "2e429160071c63d8").getTid(); + assertEquals(prefix + "2e429160071c63d8", FastFormat.toHexString(prefix, txid, "")); assertEquals(String.format("%016x", 64L), FastFormat.toHexString(64L)); assertEquals(String.format("%016x", 0X2e429160071c63d8L), FastFormat.toHexString(0X2e429160071c63d8L));