From d475b22d6998ccc01c96c240abb362e26dba25a6 Mon Sep 17 00:00:00 2001 From: imbajin Date: Thu, 9 Mar 2023 16:37:36 +0800 Subject: [PATCH] fix import style --- .../backend/store/raft/RaftContext.java | 38 +++++++++---------- .../backend/store/raft/StoreSnapshotFile.java | 10 ++--- .../store/raft/compress/CompressStrategy.java | 4 +- .../compress/CompressStrategyManager.java | 6 +-- .../compress/ParallelCompressStrategy.java | 11 +++--- .../raft/compress/SerialCompressStrategy.java | 4 +- .../apache/hugegraph/config/CoreOptions.java | 1 - 7 files changed, 35 insertions(+), 39 deletions(-) diff --git a/hugegraph-core/src/main/java/org/apache/hugegraph/backend/store/raft/RaftContext.java b/hugegraph-core/src/main/java/org/apache/hugegraph/backend/store/raft/RaftContext.java index 5564021d61..6f74bed6a0 100644 --- a/hugegraph-core/src/main/java/org/apache/hugegraph/backend/store/raft/RaftContext.java +++ b/hugegraph-core/src/main/java/org/apache/hugegraph/backend/store/raft/RaftContext.java @@ -30,22 +30,6 @@ import java.util.concurrent.ThreadPoolExecutor; import org.apache.commons.io.FileUtils; -import org.apache.hugegraph.backend.store.raft.rpc.ListPeersProcessor; -import org.apache.hugegraph.backend.store.raft.rpc.RpcForwarder; -import org.apache.hugegraph.backend.store.raft.compress.CompressStrategyManager; -import org.slf4j.Logger; - -import com.alipay.sofa.jraft.NodeManager; -import com.alipay.sofa.jraft.conf.Configuration; -import com.alipay.sofa.jraft.entity.PeerId; -import com.alipay.sofa.jraft.option.NodeOptions; -import com.alipay.sofa.jraft.option.RaftOptions; -import com.alipay.sofa.jraft.option.ReadOnlyOption; -import com.alipay.sofa.jraft.rpc.RaftRpcServerFactory; -import com.alipay.sofa.jraft.rpc.RpcServer; -import com.alipay.sofa.jraft.rpc.impl.BoltRpcServer; -import com.alipay.sofa.jraft.util.NamedThreadFactory; -import com.alipay.sofa.jraft.util.ThreadPoolUtil; import org.apache.hugegraph.HugeException; import org.apache.hugegraph.HugeGraphParams; import org.apache.hugegraph.backend.cache.Cache; @@ -55,11 +39,14 @@ import org.apache.hugegraph.backend.store.BackendMutation; import org.apache.hugegraph.backend.store.BackendStore; import org.apache.hugegraph.backend.store.BackendStoreProvider; +import org.apache.hugegraph.backend.store.raft.compress.CompressStrategyManager; +import org.apache.hugegraph.backend.store.raft.rpc.AddPeerProcessor; +import org.apache.hugegraph.backend.store.raft.rpc.ListPeersProcessor; import org.apache.hugegraph.backend.store.raft.rpc.RaftRequests.StoreType; +import org.apache.hugegraph.backend.store.raft.rpc.RemovePeerProcessor; +import org.apache.hugegraph.backend.store.raft.rpc.RpcForwarder; import org.apache.hugegraph.backend.store.raft.rpc.SetLeaderProcessor; import org.apache.hugegraph.backend.store.raft.rpc.StoreCommandProcessor; -import org.apache.hugegraph.backend.store.raft.rpc.AddPeerProcessor; -import org.apache.hugegraph.backend.store.raft.rpc.RemovePeerProcessor; import org.apache.hugegraph.config.CoreOptions; import org.apache.hugegraph.config.HugeConfig; import org.apache.hugegraph.event.EventHub; @@ -69,6 +56,19 @@ import org.apache.hugegraph.util.E; import org.apache.hugegraph.util.Events; import org.apache.hugegraph.util.Log; +import org.slf4j.Logger; + +import com.alipay.sofa.jraft.NodeManager; +import com.alipay.sofa.jraft.conf.Configuration; +import com.alipay.sofa.jraft.entity.PeerId; +import com.alipay.sofa.jraft.option.NodeOptions; +import com.alipay.sofa.jraft.option.RaftOptions; +import com.alipay.sofa.jraft.option.ReadOnlyOption; +import com.alipay.sofa.jraft.rpc.RaftRpcServerFactory; +import com.alipay.sofa.jraft.rpc.RpcServer; +import com.alipay.sofa.jraft.rpc.impl.BoltRpcServer; +import com.alipay.sofa.jraft.util.NamedThreadFactory; +import com.alipay.sofa.jraft.util.ThreadPoolUtil; public final class RaftContext { @@ -114,7 +114,7 @@ public RaftContext(HugeGraphParams params) { HugeConfig config = params.configuration(); /* - * NOTE: `raft.group_peers` option is transfered from ServerConfig + * NOTE: `raft.group_peers` option is transferred from ServerConfig * to CoreConfig, since it's shared by all graphs. */ String groupPeersString = this.config().getString("raft.group_peers"); diff --git a/hugegraph-core/src/main/java/org/apache/hugegraph/backend/store/raft/StoreSnapshotFile.java b/hugegraph-core/src/main/java/org/apache/hugegraph/backend/store/raft/StoreSnapshotFile.java index addd6bef36..6cf08f1e58 100644 --- a/hugegraph-core/src/main/java/org/apache/hugegraph/backend/store/raft/StoreSnapshotFile.java +++ b/hugegraph-core/src/main/java/org/apache/hugegraph/backend/store/raft/StoreSnapshotFile.java @@ -31,6 +31,10 @@ import org.apache.commons.io.FileUtils; import org.apache.commons.lang3.StringUtils; import org.apache.hugegraph.backend.store.raft.compress.CompressStrategyManager; +import org.apache.hugegraph.testutil.Whitebox; +import org.apache.hugegraph.util.E; +import org.apache.hugegraph.util.InsertionOrderUtil; +import org.apache.hugegraph.util.Log; import org.slf4j.Logger; import com.alipay.sofa.jraft.Closure; @@ -40,12 +44,6 @@ import com.alipay.sofa.jraft.storage.snapshot.SnapshotReader; import com.alipay.sofa.jraft.storage.snapshot.SnapshotWriter; import com.alipay.sofa.jraft.util.CRC64; - -import org.apache.hugegraph.testutil.Whitebox; -import org.apache.hugegraph.util.E; -import org.apache.hugegraph.util.InsertionOrderUtil; -import org.apache.hugegraph.util.Log; - import com.google.protobuf.ByteString; public class StoreSnapshotFile { diff --git a/hugegraph-core/src/main/java/org/apache/hugegraph/backend/store/raft/compress/CompressStrategy.java b/hugegraph-core/src/main/java/org/apache/hugegraph/backend/store/raft/compress/CompressStrategy.java index 88ee2d3989..18a4e137c7 100644 --- a/hugegraph-core/src/main/java/org/apache/hugegraph/backend/store/raft/compress/CompressStrategy.java +++ b/hugegraph-core/src/main/java/org/apache/hugegraph/backend/store/raft/compress/CompressStrategy.java @@ -21,8 +21,8 @@ public interface CompressStrategy { - void compressZip(String rootDir, String sourceDir, String outputZipFile, Checksum checksum) - throws Throwable; + void compressZip(String rootDir, String sourceDir, String outputZipFile, + Checksum checksum) throws Throwable; void decompressZip(String sourceZipFile, String outputDir, Checksum checksum) throws Throwable; } diff --git a/hugegraph-core/src/main/java/org/apache/hugegraph/backend/store/raft/compress/CompressStrategyManager.java b/hugegraph-core/src/main/java/org/apache/hugegraph/backend/store/raft/compress/CompressStrategyManager.java index a951561d9c..8d45df2528 100644 --- a/hugegraph-core/src/main/java/org/apache/hugegraph/backend/store/raft/compress/CompressStrategyManager.java +++ b/hugegraph-core/src/main/java/org/apache/hugegraph/backend/store/raft/compress/CompressStrategyManager.java @@ -56,10 +56,10 @@ public static void init(final HugeConfig config) { // add parallel compress strategy if (compressStrategies[PARALLEL_STRATEGY] == null) { CompressStrategy compressStrategy = new ParallelCompressStrategy( - config.get(CoreOptions.RAFT_SNAPSHOT_COMPRESS_THREADS), - config.get(CoreOptions.RAFT_SNAPSHOT_DECOMPRESS_THREADS)); + config.get(CoreOptions.RAFT_SNAPSHOT_COMPRESS_THREADS), + config.get(CoreOptions.RAFT_SNAPSHOT_DECOMPRESS_THREADS)); CompressStrategyManager.addCompressStrategy( - CompressStrategyManager.PARALLEL_STRATEGY, compressStrategy); + CompressStrategyManager.PARALLEL_STRATEGY, compressStrategy); DEFAULT_STRATEGY = PARALLEL_STRATEGY; } } diff --git a/hugegraph-core/src/main/java/org/apache/hugegraph/backend/store/raft/compress/ParallelCompressStrategy.java b/hugegraph-core/src/main/java/org/apache/hugegraph/backend/store/raft/compress/ParallelCompressStrategy.java index d5f71093ca..10131edfa4 100644 --- a/hugegraph-core/src/main/java/org/apache/hugegraph/backend/store/raft/compress/ParallelCompressStrategy.java +++ b/hugegraph-core/src/main/java/org/apache/hugegraph/backend/store/raft/compress/ParallelCompressStrategy.java @@ -123,8 +123,8 @@ public void compressZip(String rootDir, String sourceDir, String outputZipFile, } @Override - public void decompressZip(String sourceZipFile, String outputDir, Checksum checksum) - throws Throwable { + public void decompressZip(String sourceZipFile, String outputDir, + Checksum checksum) throws Throwable { LOG.info("Start to decompress snapshot in parallel mode"); ExecutorService decompressExecutor = newFixedPool(decompressThreads, decompressThreads, @@ -166,8 +166,7 @@ private void compressDirectoryToZipFile(File dir, ZipArchiveScatterOutputStream addEntry(sourceDir, dir, scatterOutput, method); return; } - File[] files = Requires.requireNonNull(Objects.requireNonNull(dir.listFiles()), - "files"); + File[] files = Requires.requireNonNull(Objects.requireNonNull(dir.listFiles()), "files"); for (File file : files) { String child = Paths.get(sourceDir, file.getName()).toString(); if (file.isDirectory()) { @@ -199,8 +198,8 @@ private void addEntry(String filePath, File file, /** * Unzip the archive entry to targetDir */ - private void unZipFile(ZipFile zipFile, ZipArchiveEntry entry, String targetDir) - throws Exception { + private void unZipFile(ZipFile zipFile, ZipArchiveEntry entry, + String targetDir) throws Exception { File targetFile = new File(Paths.get(targetDir, entry.getName()).toString()); if (!targetFile.toPath().normalize().startsWith(targetDir)) { throw new IOException(String.format("Bad entry: %s", entry.getName())); diff --git a/hugegraph-core/src/main/java/org/apache/hugegraph/backend/store/raft/compress/SerialCompressStrategy.java b/hugegraph-core/src/main/java/org/apache/hugegraph/backend/store/raft/compress/SerialCompressStrategy.java index dbd56c7c19..b2cb2c5a07 100644 --- a/hugegraph-core/src/main/java/org/apache/hugegraph/backend/store/raft/compress/SerialCompressStrategy.java +++ b/hugegraph-core/src/main/java/org/apache/hugegraph/backend/store/raft/compress/SerialCompressStrategy.java @@ -35,8 +35,8 @@ public void compressZip(String rootDir, String sourceDir, String outputZipFile, } @Override - public void decompressZip(String sourceZipFile, String outputDir, Checksum checksum) - throws Throwable { + public void decompressZip(String sourceZipFile, String outputDir, + Checksum checksum) throws Throwable { LOG.info("Start to decompress snapshot in serial strategy"); CompressUtil.decompressZip(sourceZipFile, outputDir, checksum); } diff --git a/hugegraph-core/src/main/java/org/apache/hugegraph/config/CoreOptions.java b/hugegraph-core/src/main/java/org/apache/hugegraph/config/CoreOptions.java index 53276defae..fe8dfc2e24 100644 --- a/hugegraph-core/src/main/java/org/apache/hugegraph/config/CoreOptions.java +++ b/hugegraph-core/src/main/java/org/apache/hugegraph/config/CoreOptions.java @@ -24,7 +24,6 @@ import static org.apache.hugegraph.config.OptionChecker.rangeInt; import org.apache.hugegraph.backend.query.Query; -import org.apache.hugegraph.backend.tx.GraphTransaction; import org.apache.hugegraph.type.define.CollectionType; import org.apache.hugegraph.util.Bytes;