From 2ad20fb1b82e0f931e353fcd58ee26ae3ac296b6 Mon Sep 17 00:00:00 2001 From: jimin Date: Sun, 1 Oct 2023 00:28:57 +0800 Subject: [PATCH] optimize: remove 7z format compression support (#5895) --- all/pom.xml | 5 -- bom/pom.xml | 5 -- compressor/pom.xml | 1 - compressor/seata-compressor-7z/pom.xml | 48 ------------ .../compressor/sevenz/SevenZCompressor.java | 39 ---------- .../seata/compressor/sevenz/SevenZUtil.java | 73 ------------------- .../io.seata.core.compressor.Compressor | 1 - .../sevenz/SevenZCompressorTest.java | 36 --------- .../compressor/sevenz/SevenZUtilTest.java | 42 ----------- compressor/seata-compressor-all/pom.xml | 5 -- dependencies/pom.xml | 6 -- script/client/conf/file.conf | 2 +- 12 files changed, 1 insertion(+), 262 deletions(-) delete mode 100644 compressor/seata-compressor-7z/pom.xml delete mode 100644 compressor/seata-compressor-7z/src/main/java/io/seata/compressor/sevenz/SevenZCompressor.java delete mode 100644 compressor/seata-compressor-7z/src/main/java/io/seata/compressor/sevenz/SevenZUtil.java delete mode 100644 compressor/seata-compressor-7z/src/main/resources/META-INF/services/io.seata.core.compressor.Compressor delete mode 100644 compressor/seata-compressor-7z/src/test/java/io/seata/compressor/sevenz/SevenZCompressorTest.java delete mode 100644 compressor/seata-compressor-7z/src/test/java/io/seata/compressor/sevenz/SevenZUtilTest.java diff --git a/all/pom.xml b/all/pom.xml index 14ef25f22e7..b4675d052b0 100644 --- a/all/pom.xml +++ b/all/pom.xml @@ -264,11 +264,6 @@ seata-compressor-gzip ${project.version} - - io.seata - seata-compressor-7z - ${project.version} - io.seata seata-compressor-bzip2 diff --git a/bom/pom.xml b/bom/pom.xml index 0182b059be1..e71dc4c3988 100644 --- a/bom/pom.xml +++ b/bom/pom.xml @@ -290,11 +290,6 @@ seata-compressor-zip ${project.version} - - io.seata - seata-compressor-7z - ${project.version} - io.seata seata-compressor-bzip2 diff --git a/compressor/pom.xml b/compressor/pom.xml index 04724673c7a..71ed3dfd8d4 100644 --- a/compressor/pom.xml +++ b/compressor/pom.xml @@ -32,7 +32,6 @@ seata-compressor-all seata-compressor-gzip seata-compressor-zip - seata-compressor-7z seata-compressor-bzip2 seata-compressor-lz4 seata-compressor-deflater diff --git a/compressor/seata-compressor-7z/pom.xml b/compressor/seata-compressor-7z/pom.xml deleted file mode 100644 index 998c32e041d..00000000000 --- a/compressor/seata-compressor-7z/pom.xml +++ /dev/null @@ -1,48 +0,0 @@ - - - - - io.seata - seata-compressor - ${revision} - - 4.0.0 - seata-compressor-7z - jar - seata-compressor-7z ${project.version} - compressor-7z for Seata built with Maven - - - - ${project.groupId} - seata-core - ${project.version} - - - org.tukaani - xz - - - org.apache.commons - commons-compress - - - - - diff --git a/compressor/seata-compressor-7z/src/main/java/io/seata/compressor/sevenz/SevenZCompressor.java b/compressor/seata-compressor-7z/src/main/java/io/seata/compressor/sevenz/SevenZCompressor.java deleted file mode 100644 index 528382d7abd..00000000000 --- a/compressor/seata-compressor-7z/src/main/java/io/seata/compressor/sevenz/SevenZCompressor.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 1999-2019 Seata.io Group. - * - * Licensed 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 - * - * http://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 io.seata.compressor.sevenz; - -import io.seata.common.loader.LoadLevel; -import io.seata.core.compressor.Compressor; - -/** - * the SevenZ Compressor - * - * @author ph3636 - */ -@LoadLevel(name = "SEVENZ") -public class SevenZCompressor implements Compressor { - - @Override - public byte[] compress(byte[] bytes) { - return SevenZUtil.compress(bytes); - } - - @Override - public byte[] decompress(byte[] bytes) { - return SevenZUtil.decompress(bytes); - } - -} diff --git a/compressor/seata-compressor-7z/src/main/java/io/seata/compressor/sevenz/SevenZUtil.java b/compressor/seata-compressor-7z/src/main/java/io/seata/compressor/sevenz/SevenZUtil.java deleted file mode 100644 index 81d529a792d..00000000000 --- a/compressor/seata-compressor-7z/src/main/java/io/seata/compressor/sevenz/SevenZUtil.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright 1999-2019 Seata.io Group. - * - * Licensed 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 - * - * http://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 io.seata.compressor.sevenz; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; - -import org.apache.commons.compress.archivers.sevenz.SevenZArchiveEntry; -import org.apache.commons.compress.archivers.sevenz.SevenZFile; -import org.apache.commons.compress.archivers.sevenz.SevenZOutputFile; -import org.apache.commons.compress.utils.SeekableInMemoryByteChannel; - -/** - * the SevenZ Util - * - * @author ph3636 - */ -public class SevenZUtil { - - private static final int BUFFER_SIZE = 8192; - - public static byte[] compress(byte[] bytes) { - if (bytes == null) { - throw new NullPointerException("bytes is null"); - } - SeekableInMemoryByteChannel channel = new SeekableInMemoryByteChannel(); - try (SevenZOutputFile z7z = new SevenZOutputFile(channel)) { - SevenZArchiveEntry entry = new SevenZArchiveEntry(); - entry.setName("sevenZip"); - entry.setSize(bytes.length); - z7z.putArchiveEntry(entry); - z7z.write(bytes); - z7z.closeArchiveEntry(); - z7z.finish(); - return channel.array(); - } catch (IOException e) { - throw new RuntimeException("SevenZ compress error", e); - } - } - - public static byte[] decompress(byte[] bytes) { - if (bytes == null) { - throw new NullPointerException("bytes is null"); - } - ByteArrayOutputStream out = new ByteArrayOutputStream(); - SeekableInMemoryByteChannel channel = new SeekableInMemoryByteChannel(bytes); - try (SevenZFile sevenZFile = new SevenZFile(channel)) { - byte[] buffer = new byte[BUFFER_SIZE]; - while (sevenZFile.getNextEntry() != null) { - int n; - while ((n = sevenZFile.read(buffer)) > -1) { - out.write(buffer, 0, n); - } - } - return out.toByteArray(); - } catch (IOException e) { - throw new RuntimeException("SevenZ decompress error", e); - } - } -} diff --git a/compressor/seata-compressor-7z/src/main/resources/META-INF/services/io.seata.core.compressor.Compressor b/compressor/seata-compressor-7z/src/main/resources/META-INF/services/io.seata.core.compressor.Compressor deleted file mode 100644 index 67539a86756..00000000000 --- a/compressor/seata-compressor-7z/src/main/resources/META-INF/services/io.seata.core.compressor.Compressor +++ /dev/null @@ -1 +0,0 @@ -io.seata.compressor.sevenz.SevenZCompressor \ No newline at end of file diff --git a/compressor/seata-compressor-7z/src/test/java/io/seata/compressor/sevenz/SevenZCompressorTest.java b/compressor/seata-compressor-7z/src/test/java/io/seata/compressor/sevenz/SevenZCompressorTest.java deleted file mode 100644 index fa19bd88135..00000000000 --- a/compressor/seata-compressor-7z/src/test/java/io/seata/compressor/sevenz/SevenZCompressorTest.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 1999-2019 Seata.io Group. - * - * Licensed 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 - * - * http://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 io.seata.compressor.sevenz; - -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; - -/** - * the SevenZ Compressor test - * - * @author ph3636 - */ -public class SevenZCompressorTest { - - @Test - public void testCompressAndDecompress() { - SevenZCompressor compressor = new SevenZCompressor(); - byte[] bytes = "aa".getBytes(); - bytes = compressor.compress(bytes); - bytes = compressor.decompress(bytes); - Assertions.assertEquals(new String(bytes), "aa"); - } -} diff --git a/compressor/seata-compressor-7z/src/test/java/io/seata/compressor/sevenz/SevenZUtilTest.java b/compressor/seata-compressor-7z/src/test/java/io/seata/compressor/sevenz/SevenZUtilTest.java deleted file mode 100644 index 9a6c7f03317..00000000000 --- a/compressor/seata-compressor-7z/src/test/java/io/seata/compressor/sevenz/SevenZUtilTest.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 1999-2019 Seata.io Group. - * - * Licensed 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 - * - * http://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 io.seata.compressor.sevenz; - -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; - - -/** - * the SevenZ Util test - * - * @author ph3636 - */ -public class SevenZUtilTest { - - @Test - public void test_compress() { - Assertions.assertThrows(NullPointerException.class, () -> { - SevenZUtil.compress(null); - }); - } - - @Test - public void test_decompress() { - Assertions.assertThrows(NullPointerException.class, () -> { - SevenZUtil.decompress(null); - }); - } -} diff --git a/compressor/seata-compressor-all/pom.xml b/compressor/seata-compressor-all/pom.xml index c453a855f78..ad233d2903e 100644 --- a/compressor/seata-compressor-all/pom.xml +++ b/compressor/seata-compressor-all/pom.xml @@ -33,11 +33,6 @@ seata-compressor-gzip ${project.version} - - ${project.groupId} - seata-compressor-7z - ${project.version} - ${project.groupId} seata-compressor-bzip2 diff --git a/dependencies/pom.xml b/dependencies/pom.xml index 90dd88e10a1..513d6b2cb36 100644 --- a/dependencies/pom.xml +++ b/dependencies/pom.xml @@ -63,7 +63,6 @@ 6.3.0 1.0.0 1.82 - 1.8 1.21 1.10.12 1.7.1 @@ -543,11 +542,6 @@ fst ${fst.version} - - org.tukaani - xz - ${xz.version} - org.apache.commons commons-compress diff --git a/script/client/conf/file.conf b/script/client/conf/file.conf index a91822aaede..b1cbe6da375 100644 --- a/script/client/conf/file.conf +++ b/script/client/conf/file.conf @@ -98,7 +98,7 @@ client { logTable = "undo_log" compress { enable = true - # allow zip, gzip, deflater, 7z, lz4, bzip2, zstd default is zip + # allow zip, gzip, deflater, lz4, bzip2, zstd default is zip type = zip # if rollback info size > threshold, then will be compress # allow k m g t