From e809b7697d8e22daa5d440d0acdb3677a50634ec Mon Sep 17 00:00:00 2001 From: liuxiao Date: Tue, 1 Aug 2023 16:58:19 +0800 Subject: [PATCH 1/7] fix: checkstyle --- checkstyle.xml | 7 +++- .../api/traverser/JaccardSimilarityAPI.java | 1 - .../exception/InvalidOperationException.java | 1 - .../hugegraph/exception/ServerException.java | 5 +++ .../serializer/direct/HBaseSerializer.java | 23 ++++++----- .../serializer/direct/reuse/BytesDemo.java | 28 ++++++-------- .../serializer/direct/util/IdGenerator.java | 16 ++++---- .../direct/util/SplicingIdGenerator.java | 20 +++++----- .../apache/hugegraph/config/HubbleConfig.java | 5 +++ .../controller/load/LoadTaskController.java | 2 +- .../apache/hugegraph/license/ServerInfo.java | 2 - .../service/load/LoadTaskService.java | 14 ++++--- .../service/query/ExecuteHistoryService.java | 8 ++-- .../apache/hugegraph/util/GremlinUtil.java | 8 ++-- .../apache/hugegraph/util/SerializeUtil.java | 1 - .../loader/flink/HugeGraphOutputFormat.java | 10 ++--- .../loader/reader/file/LocalFileReader.java | 1 - .../loader/spark/HugeGraphSparkLoader.java | 18 ++++----- .../hugegraph/loader/task/InsertTask.java | 20 +++++----- .../org/apache/hugegraph/base/Printer.java | 2 +- .../org/apache/hugegraph/base/ToolClient.java | 3 +- .../hugegraph/cmd/HugeGraphCommand.java | 4 +- .../manager/AuthBackupRestoreManager.java | 38 +++++++++---------- suppression.xml | 25 ++++++++++++ 24 files changed, 146 insertions(+), 116 deletions(-) create mode 100644 suppression.xml diff --git a/checkstyle.xml b/checkstyle.xml index 79f0983f8..ccbba9c97 100644 --- a/checkstyle.xml +++ b/checkstyle.xml @@ -20,7 +20,10 @@ - + + + + @@ -123,7 +126,7 @@ - + diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/JaccardSimilarityAPI.java b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/JaccardSimilarityAPI.java index 41a827aea..80fe8b486 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/JaccardSimilarityAPI.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/api/traverser/JaccardSimilarityAPI.java @@ -28,7 +28,6 @@ import org.apache.hugegraph.structure.constant.Direction; import org.apache.hugegraph.structure.traverser.SingleSourceJaccardSimilarityRequest; - import org.apache.hugegraph.util.E; public class JaccardSimilarityAPI extends TraversersAPI { diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/exception/InvalidOperationException.java b/hugegraph-client/src/main/java/org/apache/hugegraph/exception/InvalidOperationException.java index f70cbf972..bd5ce9153 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/exception/InvalidOperationException.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/exception/InvalidOperationException.java @@ -17,7 +17,6 @@ package org.apache.hugegraph.exception; - import org.apache.hugegraph.rest.ClientException; public class InvalidOperationException extends ClientException { diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/exception/ServerException.java b/hugegraph-client/src/main/java/org/apache/hugegraph/exception/ServerException.java index 1e0ac5787..e718181d3 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/exception/ServerException.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/exception/ServerException.java @@ -20,11 +20,15 @@ import java.util.Map; import org.apache.hugegraph.rest.RestResult; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import jakarta.ws.rs.core.Response; public class ServerException extends RuntimeException { + private static final Logger LOG = LoggerFactory.getLogger(ServerException.class); + private static final long serialVersionUID = 6335623004322652358L; private static final String[] EXCEPTION_KEYS = {"exception", @@ -52,6 +56,7 @@ public static ServerException fromResponse(Response response) { exception.cause = (String) getByKeys(json, CAUSE_KEYS); exception.trace = getByKeys(json, TRACE_KEYS); } catch (Exception ignored) { + LOG.error("ServerException fromResponse excepiton"); } return exception; diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/serializer/direct/HBaseSerializer.java b/hugegraph-client/src/main/java/org/apache/hugegraph/serializer/direct/HBaseSerializer.java index 9197ecc78..18cb87af0 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/serializer/direct/HBaseSerializer.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/serializer/direct/HBaseSerializer.java @@ -40,8 +40,7 @@ public class HBaseSerializer { private HugeClient client; private GraphSchema graphSchema; - - public HBaseSerializer(HugeClient client, int vertexPartitions, int edgePartitions){ + public HBaseSerializer(HugeClient client, int vertexPartitions, int edgePartitions) { this.client = client; this.graphSchema = new GraphSchema(client); this.edgeLogicPartitions = edgePartitions; @@ -50,12 +49,12 @@ public HBaseSerializer(HugeClient client, int vertexPartitions, int edgePartitio public byte[] getKeyBytes(GraphElement e) { byte[] array = null; - if(e.type() == "vertex" && e.id() != null){ + if (e.type() == "vertex" && e.id() != null) { BytesBuffer buffer = BytesBuffer.allocate(2 + 1 + e.id().toString().length()); buffer.writeShort(getPartition(HugeType.VERTEX, IdGenerator.of(e.id()))); buffer.writeId(IdGenerator.of(e.id())); array = buffer.bytes(); - }else if ( e.type() == "edge" ){ + } else if (e.type() == "edge") { BytesBuffer buffer = BytesBuffer.allocate(BytesBuffer.BUF_EDGE_ID); Edge edge = (Edge)e; buffer.writeShort(getPartition(HugeType.EDGE, IdGenerator.of(edge.sourceId()))); @@ -71,22 +70,22 @@ public byte[] getKeyBytes(GraphElement e) { public byte[] getValueBytes(GraphElement e) { byte[] array = null; - if(e.type() == "vertex"){ - int propsCount = e.properties().size() ; //vertex.sizeOfProperties(); + if (e.type() == "vertex") { + int propsCount = e.properties().size(); //vertex.sizeOfProperties(); BytesBuffer buffer = BytesBuffer.allocate(8 + 16 * propsCount); buffer.writeId(IdGenerator.of(graphSchema.getVertexLabel(e.label()).id())); buffer.writeVInt(propsCount); - for(Map.Entry entry : e.properties().entrySet()){ + for (Map.Entry entry : e.properties().entrySet()) { PropertyKey propertyKey = graphSchema.getPropertyKey(entry.getKey()); buffer.writeVInt(propertyKey.id().intValue()); buffer.writeProperty(propertyKey.dataType(),entry.getValue()); } array = buffer.bytes(); - } else if ( e.type() == "edge" ){ + } else if (e.type() == "edge") { int propsCount = e.properties().size(); BytesBuffer buffer = BytesBuffer.allocate(4 + 16 * propsCount); buffer.writeVInt(propsCount); - for(Map.Entry entry : e.properties().entrySet()){ + for (Map.Entry entry : e.properties().entrySet()) { PropertyKey propertyKey = graphSchema.getPropertyKey(entry.getKey()); buffer.writeVInt(propertyKey.id().intValue()); buffer.writeProperty(propertyKey.dataType(),entry.getValue()); @@ -108,15 +107,15 @@ public short getPartition(HugeType type, Id id) { return partition > 0 ? partition : (short) -partition; } - public int getEdgeLogicPartitions(){ + public int getEdgeLogicPartitions() { return this.edgeLogicPartitions; } - public int getVertexLogicPartitions(){ + public int getVertexLogicPartitions() { return this.vertexLogicPartitions; } - public void close(){ + public void close() { this.client.close(); } } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/serializer/direct/reuse/BytesDemo.java b/hugegraph-client/src/main/java/org/apache/hugegraph/serializer/direct/reuse/BytesDemo.java index ba3c1e480..8404dffe0 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/serializer/direct/reuse/BytesDemo.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/serializer/direct/reuse/BytesDemo.java @@ -39,7 +39,7 @@ public class BytesDemo { static HugeClient client; boolean bypassServer = true; RocksDBSerializer ser; - HBaseSerializer HBaseSer; + HBaseSerializer hBaseSer; public static void main(String[] args) { BytesDemo ins = new BytesDemo(); @@ -54,7 +54,6 @@ void initGraph() { SchemaManager schema = client.schema(); - schema.propertyKey("name").asText().ifNotExist().create(); schema.propertyKey("age").asInt().ifNotExist().create(); schema.propertyKey("lang").asText().ifNotExist().create(); @@ -97,7 +96,7 @@ void initGraph() { .ifNotExist() .create(); - HBaseSer = new HBaseSerializer(client, vertexLogicPartitions, edgeLogicPartitions); + hBaseSer = new HBaseSerializer(client, vertexLogicPartitions, edgeLogicPartitions); writeGraphElements(); client.close(); @@ -125,15 +124,14 @@ private void writeGraphElements() { .property("date", "2017-03-24"); List vertices = new ArrayList() {{ - add(peter); - add(lop); - add(vadasB); - }}; - + add(peter); + add(lop); + add(vadasB); + }}; List edges = new ArrayList() {{ - add(peterCreateLop); - }}; + add(peterCreateLop); + }}; // Old way: encode to json then send to server if (bypassServer) { @@ -148,14 +146,14 @@ private void writeGraphElements() { * */ void writeDirectly(List vertices, List edges) { for (Vertex vertex : vertices) { - byte[] rowkey = HBaseSer.getKeyBytes(vertex); - byte[] values = HBaseSer.getValueBytes(vertex); + byte[] rowkey = hBaseSer.getKeyBytes(vertex); + byte[] values = hBaseSer.getValueBytes(vertex); sendRpcToHBase("vertex", rowkey, values); } for (Edge edge : edges) { - byte[] rowkey = HBaseSer.getKeyBytes(edge); - byte[] values = HBaseSer.getValueBytes(edge); + byte[] rowkey = hBaseSer.getKeyBytes(edge); + byte[] values = hBaseSer.getValueBytes(edge); sendRpcToHBase("edge", rowkey, values); } } @@ -185,10 +183,8 @@ boolean sendRpcToHBase(String type, byte[] rowkey, byte[] values) { return flag; } - boolean put(String type, byte[] rowkey, byte[] values) throws IOException { // TODO: put to HBase return true; } - } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/serializer/direct/util/IdGenerator.java b/hugegraph-client/src/main/java/org/apache/hugegraph/serializer/direct/util/IdGenerator.java index c6c51e371..c6f79cb95 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/serializer/direct/util/IdGenerator.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/serializer/direct/util/IdGenerator.java @@ -28,19 +28,19 @@ public abstract class IdGenerator { public static final Id ZERO = IdGenerator.of(0L); - public final static Id of(String id) { + public static Id of(String id) { return new StringId(id); } - public final static Id of(UUID id) { + public static Id of(UUID id) { return new UuidId(id); } - public final static Id of(String id, boolean uuid) { + public static Id of(String id, boolean uuid) { return uuid ? new UuidId(id) : new StringId(id); } - public final static Id of(long id) { + public static Id of(long id) { return new LongId(id); } @@ -57,7 +57,7 @@ public static Id of(Object id) { return new ObjectId(id); } - public final static Id of(byte[] bytes, Id.IdType type) { + public static Id of(byte[] bytes, Id.IdType type) { switch (type) { case LONG: return new LongId(bytes); @@ -70,7 +70,7 @@ public final static Id of(byte[] bytes, Id.IdType type) { } } - public final static Id ofStoredString(String id, Id.IdType type) { + public static Id ofStoredString(String id, Id.IdType type) { switch (type) { case LONG: return of(LongEncoding.decodeSignedB64(id)); @@ -84,7 +84,7 @@ public final static Id ofStoredString(String id, Id.IdType type) { } } - public final static String asStoredString(Id id) { + public static String asStoredString(Id id) { switch (id.type()) { case LONG: return LongEncoding.encodeSignedB64(id.asLong()); @@ -97,7 +97,7 @@ public final static String asStoredString(Id id) { } } - public final static Id.IdType idType(Id id) { + public static Id.IdType idType(Id id) { if (id instanceof LongId) { return Id.IdType.LONG; } diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/serializer/direct/util/SplicingIdGenerator.java b/hugegraph-client/src/main/java/org/apache/hugegraph/serializer/direct/util/SplicingIdGenerator.java index ca2fdcdf5..e79515404 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/serializer/direct/util/SplicingIdGenerator.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/serializer/direct/util/SplicingIdGenerator.java @@ -55,16 +55,16 @@ public static SplicingIdGenerator instance() { /** * Generate a string id of HugeVertex from Vertex name */ -// public Id generate(HugeVertex vertex) { -// /* -// * Hash for row-key which will be evenly distributed. -// * We can also use LongEncoding.encode() to encode the int/long hash -// * if needed. -// * id = String.format("%s%s%s", HashUtil.hash(id), ID_SPLITOR, id); -// */ -// // TODO: use binary Id with binary fields instead of string id -// return splicing(vertex.schemaLabel().id().asString(), vertex.name()); -// } + // public Id generate(HugeVertex vertex) { + // /* + // * Hash for row-key which will be evenly distributed. + // * We can also use LongEncoding.encode() to encode the int/long hash + // * if needed. + // * id = String.format("%s%s%s", HashUtil.hash(id), ID_SPLITOR, id); + // */ + // // TODO: use binary Id with binary fields instead of string id + // return splicing(vertex.schemaLabel().id().asString(), vertex.name()); + // } /** * Concat multiple ids into one composite id with IDS_SPLITOR diff --git a/hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/config/HubbleConfig.java b/hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/config/HubbleConfig.java index af2a19623..b5ff22e72 100644 --- a/hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/config/HubbleConfig.java +++ b/hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/config/HubbleConfig.java @@ -22,6 +22,8 @@ import org.apache.hugegraph.exception.ExternalException; import org.apache.hugegraph.options.HubbleOptions; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.ApplicationArguments; import org.springframework.context.annotation.Bean; @@ -32,6 +34,8 @@ @Configuration public class HubbleConfig { + private static final Logger LOG = LoggerFactory.getLogger(HubbleConfig.class); + @Autowired private ApplicationArguments arguments; @@ -56,6 +60,7 @@ public HugeConfig hugeConfig() { conf = path; } } catch (Exception ignored) { + LOG.error("hugeConfig exception"); } return new HugeConfig(conf); } diff --git a/hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/controller/load/LoadTaskController.java b/hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/controller/load/LoadTaskController.java index 6e4a4f597..52a1137c6 100644 --- a/hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/controller/load/LoadTaskController.java +++ b/hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/controller/load/LoadTaskController.java @@ -244,7 +244,7 @@ public LoadTask retry(@PathVariable("connId") int connId, return this.service.retry(taskId); } finally { jobEntity.setJobStatus(JobStatus.LOADING); - jobEntity.setUpdateTime( HubbleUtil.nowDate()); + jobEntity.setUpdateTime(HubbleUtil.nowDate()); this.jobService.update(jobEntity); } } diff --git a/hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/license/ServerInfo.java b/hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/license/ServerInfo.java index d441eeb19..f5779094f 100644 --- a/hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/license/ServerInfo.java +++ b/hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/license/ServerInfo.java @@ -18,8 +18,6 @@ package org.apache.hugegraph.license; -import org.apache.hugegraph.license.MachineInfo; - public final class ServerInfo { private final String serverId; diff --git a/hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/service/load/LoadTaskService.java b/hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/service/load/LoadTaskService.java index 896b65502..3d3745336 100644 --- a/hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/service/load/LoadTaskService.java +++ b/hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/service/load/LoadTaskService.java @@ -64,6 +64,7 @@ import org.apache.hugegraph.mapper.load.LoadTaskMapper; import org.apache.hugegraph.service.SettingSSLService; import org.apache.hugegraph.util.Ex; + import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.Wrappers; @@ -421,8 +422,8 @@ private FileSource buildFileSource(FileMapping fileMapping) { } private List - buildVertexMappings(GraphConnection connection, - FileMapping fileMapping) { + buildVertexMappings(GraphConnection connection, + FileMapping fileMapping) { int connId = connection.getId(); List vMappings = new ArrayList<>(); @@ -435,7 +436,8 @@ private FileSource buildFileSource(FileMapping fileMapping) { Ex.check(idFields.size() == 1, "When the ID strategy is CUSTOMIZED, you must " + "select a column in the file as the id"); - vMapping = new org.apache.hugegraph.loader.mapping.VertexMapping(idFields.get(0), true); + vMapping = new org.apache.hugegraph.loader.mapping.VertexMapping(idFields.get(0), + true); } else { assert vl.getIdStrategy().isPrimaryKey(); List primaryKeys = vl.getPrimaryKeys(); @@ -475,8 +477,8 @@ private FileSource buildFileSource(FileMapping fileMapping) { } private List - buildEdgeMappings(GraphConnection connection, - FileMapping fileMapping) { + buildEdgeMappings(GraphConnection connection, + FileMapping fileMapping) { int connId = connection.getId(); List eMappings = new ArrayList<>(); @@ -526,7 +528,7 @@ private FileSource buildFileSource(FileMapping fileMapping) { org.apache.hugegraph.loader.mapping.EdgeMapping eMapping; eMapping = new org.apache.hugegraph.loader.mapping.EdgeMapping( - sourceFields, unfoldSource, targetFields, unfoldTarget); + sourceFields, unfoldSource, targetFields, unfoldTarget); // set label eMapping.label(mapping.getLabel()); // set field_mapping diff --git a/hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/service/query/ExecuteHistoryService.java b/hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/service/query/ExecuteHistoryService.java index 91eea19ca..e51ba6f4f 100644 --- a/hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/service/query/ExecuteHistoryService.java +++ b/hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/service/query/ExecuteHistoryService.java @@ -39,6 +39,7 @@ import org.apache.hugegraph.service.HugeClientPoolService; import org.apache.hugegraph.structure.Task; import org.apache.hugegraph.util.HubbleUtil; + import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.Wrappers; @@ -92,7 +93,6 @@ public IPage list(int connId, long current, long pageSize) { return results; } - public ExecuteHistory get(int connId, int id) { HugeClient client = this.getClient(connId); ExecuteHistory history = this.mapper.selectById(id); @@ -111,9 +111,9 @@ public ExecuteHistory get(int connId, int id) { @Transactional(isolation = Isolation.READ_COMMITTED) public void save(ExecuteHistory history) { - if (this.mapper.insert(history) != 1) { - throw new InternalException("entity.insert.failed", history); - } + if (this.mapper.insert(history) != 1) { + throw new InternalException("entity.insert.failed", history); + } } @Transactional(isolation = Isolation.READ_COMMITTED) diff --git a/hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/util/GremlinUtil.java b/hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/util/GremlinUtil.java index 352e1fc0c..acd311814 100644 --- a/hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/util/GremlinUtil.java +++ b/hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/util/GremlinUtil.java @@ -44,17 +44,17 @@ public final class GremlinUtil { ); private static final String[] COMPILE_SEARCH_LIST = new String[]{ - ".", "(", ")" + ".", "(", ")" }; private static final String[] COMPILE_TARGET_LIST = new String[]{ - "\\.", "\\(", "\\)" + "\\.", "\\(", "\\)" }; private static final String[] ESCAPE_SEARCH_LIST = new String[]{ - "\\", "\"", "'", "\n" + "\\", "\"", "'", "\n" }; private static final String[] ESCAPE_TARGET_LIST = new String[]{ - "\\\\", "\\\"", "\\'", "\\n" + "\\\\", "\\\"", "\\'", "\\n" }; private static final Set LIMIT_PATTERNS = compile(LIMIT_SUFFIXES); diff --git a/hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/util/SerializeUtil.java b/hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/util/SerializeUtil.java index d92153b28..d427598b2 100644 --- a/hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/util/SerializeUtil.java +++ b/hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/util/SerializeUtil.java @@ -25,7 +25,6 @@ import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.JsonSerializer; import com.fasterxml.jackson.databind.SerializerProvider; -import org.apache.hugegraph.util.TimeUtil; public final class SerializeUtil { diff --git a/hugegraph-loader/src/main/java/org/apache/hugegraph/loader/flink/HugeGraphOutputFormat.java b/hugegraph-loader/src/main/java/org/apache/hugegraph/loader/flink/HugeGraphOutputFormat.java index 7bfefa16f..1f9754d0d 100644 --- a/hugegraph-loader/src/main/java/org/apache/hugegraph/loader/flink/HugeGraphOutputFormat.java +++ b/hugegraph-loader/src/main/java/org/apache/hugegraph/loader/flink/HugeGraphOutputFormat.java @@ -183,15 +183,15 @@ private void flush(ElementBuilder elementBuilder, List row if (isVertex) { BatchVertexRequest.Builder req = new BatchVertexRequest.Builder(); req.vertices((List) (Object) graphElements) - .updatingStrategies(updateStrategyMap) - .createIfNotExist(true); + .updatingStrategies(updateStrategyMap) + .createIfNotExist(true); g.updateVertices(req.build()); } else { BatchEdgeRequest.Builder req = new BatchEdgeRequest.Builder(); req.edges((List) (Object) graphElements) - .updatingStrategies(updateStrategyMap) - .checkVertex(this.loadOptions.checkVertex) - .createIfNotExist(true); + .updatingStrategies(updateStrategyMap) + .checkVertex(this.loadOptions.checkVertex) + .createIfNotExist(true); g.updateEdges(req.build()); } break; diff --git a/hugegraph-loader/src/main/java/org/apache/hugegraph/loader/reader/file/LocalFileReader.java b/hugegraph-loader/src/main/java/org/apache/hugegraph/loader/reader/file/LocalFileReader.java index d41ac49db..bf6825448 100644 --- a/hugegraph-loader/src/main/java/org/apache/hugegraph/loader/reader/file/LocalFileReader.java +++ b/hugegraph-loader/src/main/java/org/apache/hugegraph/loader/reader/file/LocalFileReader.java @@ -18,7 +18,6 @@ package org.apache.hugegraph.loader.reader.file; import java.io.File; -import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.nio.file.Files; diff --git a/hugegraph-loader/src/main/java/org/apache/hugegraph/loader/spark/HugeGraphSparkLoader.java b/hugegraph-loader/src/main/java/org/apache/hugegraph/loader/spark/HugeGraphSparkLoader.java index 228f2db03..492b604ba 100644 --- a/hugegraph-loader/src/main/java/org/apache/hugegraph/loader/spark/HugeGraphSparkLoader.java +++ b/hugegraph-loader/src/main/java/org/apache/hugegraph/loader/spark/HugeGraphSparkLoader.java @@ -98,11 +98,11 @@ public HugeGraphSparkLoader(String[] args) { this.executor = Executors.newCachedThreadPool(); } - private void registerKryoClasses (SparkConf conf) { + private void registerKryoClasses(SparkConf conf) { try { conf.set("spark.serializer", "org.apache.spark.serializer.KryoSerializer") .set("spark.kryo.registrationRequired", "true") - .registerKryoClasses(new Class[] { + .registerKryoClasses(new Class[]{ ImmutableBytesWritable.class, KeyValue.class, org.apache.spark.sql.types.StructType.class, @@ -114,10 +114,10 @@ private void registerKryoClasses (SparkConf conf) { org.apache.spark.sql.catalyst.InternalRow.class, org.apache.spark.sql.catalyst.InternalRow[].class, Class.forName("org.apache.spark.internal.io." + - "FileCommitProtocol$TaskCommitMessage"), + "FileCommitProtocol$TaskCommitMessage"), Class.forName("scala.collection.immutable.Set$EmptySet$"), Class.forName("org.apache.spark.sql.types.DoubleType$") - }); + }); } catch (ClassNotFoundException e) { LOG.error("spark kryo serialized registration failed"); throw new LoadException("spark kryo serialized registration failed", e); @@ -334,15 +334,15 @@ private void flush(Map.Entry> builderMap, BatchVertexRequest.Builder req = new BatchVertexRequest.Builder(); req.vertices((List) (Object) graphElements) - .updatingStrategies(updateStrategyMap) - .createIfNotExist(true); + .updatingStrategies(updateStrategyMap) + .createIfNotExist(true); g.updateVertices(req.build()); } else { BatchEdgeRequest.Builder req = new BatchEdgeRequest.Builder(); req.edges((List) (Object) graphElements) - .updatingStrategies(updateStrategyMap) - .checkVertex(isCheckVertex) - .createIfNotExist(true); + .updatingStrategies(updateStrategyMap) + .checkVertex(isCheckVertex) + .createIfNotExist(true); g.updateEdges(req.build()); } } diff --git a/hugegraph-loader/src/main/java/org/apache/hugegraph/loader/task/InsertTask.java b/hugegraph-loader/src/main/java/org/apache/hugegraph/loader/task/InsertTask.java index b773f3fed..87d934193 100644 --- a/hugegraph-loader/src/main/java/org/apache/hugegraph/loader/task/InsertTask.java +++ b/hugegraph-loader/src/main/java/org/apache/hugegraph/loader/task/InsertTask.java @@ -45,11 +45,11 @@ public abstract class InsertTask implements Runnable { ); public static final String[] UNACCEPTABLE_MESSAGES = { - // org.apache.http.conn.HttpHostConnectException - "Connection refused", - "The server is being shutting down", - "not allowed to insert, because already exist a vertex " + - "with same id and different label" + // org.apache.http.conn.HttpHostConnectException + "Connection refused", + "The server is being shutting down", + "not allowed to insert, because already exist a vertex " + + "with same id and different label" }; protected final LoadContext context; @@ -127,16 +127,16 @@ protected void updateBatch(List batch, boolean checkVertex) { if (this.type().isVertex()) { BatchVertexRequest.Builder req = new BatchVertexRequest.Builder(); req.vertices((List) (Object) elements) - .updatingStrategies(this.mapping.updateStrategies()) - .createIfNotExist(true); + .updatingStrategies(this.mapping.updateStrategies()) + .createIfNotExist(true); client.graph().updateVertices(req.build()); } else { BatchEdgeRequest.Builder req = new BatchEdgeRequest.Builder(); req.edges((List) (Object) elements) - .updatingStrategies(this.mapping.updateStrategies()) - .checkVertex(checkVertex) - .createIfNotExist(true); + .updatingStrategies(this.mapping.updateStrategies()) + .checkVertex(checkVertex) + .createIfNotExist(true); client.graph().updateEdges(req.build()); } diff --git a/hugegraph-tools/src/main/java/org/apache/hugegraph/base/Printer.java b/hugegraph-tools/src/main/java/org/apache/hugegraph/base/Printer.java index 86aa3d095..9af58ba2f 100644 --- a/hugegraph-tools/src/main/java/org/apache/hugegraph/base/Printer.java +++ b/hugegraph-tools/src/main/java/org/apache/hugegraph/base/Printer.java @@ -27,7 +27,7 @@ public static void print(String content) { System.out.println(content); } - public static void print(String content, Object ... objects) { + public static void print(String content, Object... objects) { System.out.println(String.format(content, objects)); } diff --git a/hugegraph-tools/src/main/java/org/apache/hugegraph/base/ToolClient.java b/hugegraph-tools/src/main/java/org/apache/hugegraph/base/ToolClient.java index 86cea21fd..5d03c2a6a 100644 --- a/hugegraph-tools/src/main/java/org/apache/hugegraph/base/ToolClient.java +++ b/hugegraph-tools/src/main/java/org/apache/hugegraph/base/ToolClient.java @@ -45,7 +45,8 @@ public ToolClient(ConnectionInfo info) { info.username = ""; info.password = ""; } - String trustStoreFile, trustStorePassword; + String trustStoreFile; + String trustStorePassword; if (info.url.startsWith("https")) { if (info.trustStoreFile == null || info.trustStoreFile.isEmpty()) { trustStoreFile = Paths.get(homePath(), DEFAULT_TRUST_STORE_FILE) diff --git a/hugegraph-tools/src/main/java/org/apache/hugegraph/cmd/HugeGraphCommand.java b/hugegraph-tools/src/main/java/org/apache/hugegraph/cmd/HugeGraphCommand.java index da5c46ead..8a3501c74 100644 --- a/hugegraph-tools/src/main/java/org/apache/hugegraph/cmd/HugeGraphCommand.java +++ b/hugegraph-tools/src/main/java/org/apache/hugegraph/cmd/HugeGraphCommand.java @@ -163,7 +163,7 @@ private void throwMode(boolean throwMode) { this.throwMode.throwMode = throwMode; } - public JCommander jCommander() { + public JCommander jcommander() { JCommander.Builder builder = JCommander.newBuilder(); // Add main command firstly @@ -474,7 +474,7 @@ private GraphMode mode() { } public JCommander parseCommand(String[] args) { - JCommander jCommander = this.jCommander(); + JCommander jCommander = this.jcommander(); if (args.length == 0) { throw ExitException.exception(ToolUtil.commandUsage(jCommander), "No command found, please input" + diff --git a/hugegraph-tools/src/main/java/org/apache/hugegraph/manager/AuthBackupRestoreManager.java b/hugegraph-tools/src/main/java/org/apache/hugegraph/manager/AuthBackupRestoreManager.java index 51830bf0c..f8a49490d 100644 --- a/hugegraph-tools/src/main/java/org/apache/hugegraph/manager/AuthBackupRestoreManager.java +++ b/hugegraph-tools/src/main/java/org/apache/hugegraph/manager/AuthBackupRestoreManager.java @@ -107,7 +107,7 @@ private void doBackup(List authManagers) { E.checkState(CollectionUtils.isNotEmpty(authManagers), "Backup data is empty, please check the type"); for (AuthManager authManager : authManagers) { - authManager.backup(); + authManager.backup(); } } @@ -127,13 +127,13 @@ private void doRestore(List authManagers) { "Restore data is empty, please check the type"); List allConflicts = Lists.newArrayList(); for (AuthManager authManager : authManagers) { - allConflicts.addAll(authManager.checkConflict()); + allConflicts.addAll(authManager.checkConflict()); } E.checkState(CollectionUtils.isEmpty(allConflicts), "Restore conflict with STOP strategy, conflicting " + "data is s%", JsonUtil.toJson(allConflicts)); for (AuthManager authManager : authManagers) { - authManager.restore(); + authManager.restore(); } } @@ -158,7 +158,7 @@ private List addAuthManagers(List types) { break; default: throw new AssertionError(String.format( - "Bad auth restore type: %s", type)); + "Bad auth restore type: %s", type)); } } return authManagers; @@ -177,10 +177,10 @@ private List readRestoreData(HugeType type) { InputStream is = this.inputStream(type.string()); try (InputStreamReader isr = new InputStreamReader(is, API.CHARSET); BufferedReader reader = new BufferedReader(isr)) { - String line; - while ((line = reader.readLine()) != null) { - resultList.add(line); - } + String line; + while ((line = reader.readLine()) != null) { + resultList.add(line); + } } catch (IOException e) { throw new ToolsException("Failed to deserialize %s from %s", e, type.string(), resultList); @@ -260,7 +260,7 @@ public List checkConflict() { "querying users of authority"); Map userMap = Maps.newHashMap(); for (User user : users) { - userMap.put(user.name(), user); + userMap.put(user.name(), user); } List userJsons = readRestoreData(HugeType.USER); List conflicts = Lists.newArrayList(); @@ -339,7 +339,7 @@ public List checkConflict() { "querying groups of authority"); Map groupMap = Maps.newHashMap(); for (Group group : groups) { - groupMap.put(group.name(), group); + groupMap.put(group.name(), group); } List groupJsons = readRestoreData(HugeType.GROUP); List conflicts = Lists.newArrayList(); @@ -409,7 +409,7 @@ public List checkConflict() { "querying targets of authority"); Map targetMap = Maps.newHashMap(); for (Target target : targets) { - targetMap.put(target.name(), target); + targetMap.put(target.name(), target); } List targetJsons = readRestoreData(HugeType.TARGET); List conflicts = Lists.newArrayList(); @@ -483,10 +483,10 @@ public void backup() { public List checkConflict() { List belongs = retry(client.authManager()::listBelongs, "querying belongs of authority"); - Map belongMap = Maps.newHashMap(); + Map belongMap = Maps.newHashMap(); for (Belong belong : belongs) { - String belongKey = belong.user() + ":" + belong.group(); - belongMap.put(belongKey, belong); + String belongKey = belong.user() + ":" + belong.group(); + belongMap.put(belongKey, belong); } List belongJsons = readRestoreData(HugeType.BELONG); List conflicts = Lists.newArrayList(); @@ -520,7 +520,7 @@ public void restore() { restoreBelong.user(idsMap.get(restoreBelong.user().toString())); restoreBelong.group(idsMap.get(restoreBelong.group().toString())); retry(() -> { - return client.authManager().createBelong(restoreBelong); + return client.authManager().createBelong(restoreBelong); }, "restore belongs of authority"); count++; } @@ -545,10 +545,10 @@ public void backup() { public List checkConflict() { List accesses = retry(client.authManager()::listAccesses, "querying accesses of authority"); - Map accessMap = Maps.newHashMap(); + Map accessMap = Maps.newHashMap(); for (Access access : accesses) { - String accessKey = access.group() + ":" + access.target(); - accessMap.put(accessKey, access); + String accessKey = access.group() + ":" + access.target(); + accessMap.put(accessKey, access); } List accessJsons = readRestoreData(HugeType.ACCESS); List conflicts = Lists.newArrayList(); @@ -582,7 +582,7 @@ public void restore() { restoreAccess.target(idsMap.get(restoreAccess.target().toString())); restoreAccess.group(idsMap.get(restoreAccess.group().toString())); retry(() -> { - return client.authManager().createAccess(restoreAccess); + return client.authManager().createAccess(restoreAccess); }, "restore accesses of authority"); count++; } diff --git a/suppression.xml b/suppression.xml new file mode 100644 index 000000000..3e9732156 --- /dev/null +++ b/suppression.xml @@ -0,0 +1,25 @@ + + + + + + + + + + \ No newline at end of file From 4d5d4aa4572a78659d8355574cf84522aafb7d49 Mon Sep 17 00:00:00 2001 From: liuxiao Date: Tue, 1 Aug 2023 17:00:58 +0800 Subject: [PATCH 2/7] update name --- checkstyle.xml | 2 +- suppression.xml => suppressions.xml | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename suppression.xml => suppressions.xml (100%) diff --git a/checkstyle.xml b/checkstyle.xml index ccbba9c97..142e83759 100644 --- a/checkstyle.xml +++ b/checkstyle.xml @@ -22,7 +22,7 @@ - + diff --git a/suppression.xml b/suppressions.xml similarity index 100% rename from suppression.xml rename to suppressions.xml From db9c58ed7e19fc60c82d353b62ca3575954148fa Mon Sep 17 00:00:00 2001 From: liuxiao Date: Tue, 1 Aug 2023 17:15:00 +0800 Subject: [PATCH 3/7] update --- .../hugegraph/serializer/direct/reuse/BytesDemo.java | 12 ++++++------ suppressions.xml | 1 + 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/serializer/direct/reuse/BytesDemo.java b/hugegraph-client/src/main/java/org/apache/hugegraph/serializer/direct/reuse/BytesDemo.java index 8404dffe0..ea7bbbd9a 100644 --- a/hugegraph-client/src/main/java/org/apache/hugegraph/serializer/direct/reuse/BytesDemo.java +++ b/hugegraph-client/src/main/java/org/apache/hugegraph/serializer/direct/reuse/BytesDemo.java @@ -124,14 +124,14 @@ private void writeGraphElements() { .property("date", "2017-03-24"); List vertices = new ArrayList() {{ - add(peter); - add(lop); - add(vadasB); - }}; + add(peter); + add(lop); + add(vadasB); + }}; List edges = new ArrayList() {{ - add(peterCreateLop); - }}; + add(peterCreateLop); + }}; // Old way: encode to json then send to server if (bypassServer) { diff --git a/suppressions.xml b/suppressions.xml index 3e9732156..adb1cfd95 100644 --- a/suppressions.xml +++ b/suppressions.xml @@ -22,4 +22,5 @@ + \ No newline at end of file From 81118c2a7ac5bee603ba8df5af73d472ea8686b9 Mon Sep 17 00:00:00 2001 From: liuxiao Date: Tue, 1 Aug 2023 17:17:11 +0800 Subject: [PATCH 4/7] update --- checkstyle.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/checkstyle.xml b/checkstyle.xml index 142e83759..9626d305f 100644 --- a/checkstyle.xml +++ b/checkstyle.xml @@ -20,7 +20,6 @@ - From e41f45bd98becc6f524276442e9a42615cc5abc0 Mon Sep 17 00:00:00 2001 From: liuxiao Date: Tue, 1 Aug 2023 17:28:31 +0800 Subject: [PATCH 5/7] fix submodule check --- pom.xml | 3 ++- checkstyle.xml => tools/checkstyle.xml | 6 +++--- suppressions.xml => tools/suppressions.xml | 0 3 files changed, 5 insertions(+), 4 deletions(-) rename checkstyle.xml => tools/checkstyle.xml (98%) rename suppressions.xml => tools/suppressions.xml (100%) diff --git a/pom.xml b/pom.xml index 192733125..b11b9e7f6 100644 --- a/pom.xml +++ b/pom.xml @@ -439,12 +439,13 @@ - checkstyle.xml + tools/checkstyle.xml UTF-8 true true false false + tools/suppressions.xml diff --git a/checkstyle.xml b/tools/checkstyle.xml similarity index 98% rename from checkstyle.xml rename to tools/checkstyle.xml index 9626d305f..2bfd9c951 100644 --- a/checkstyle.xml +++ b/tools/checkstyle.xml @@ -20,9 +20,9 @@ - - - + + + diff --git a/suppressions.xml b/tools/suppressions.xml similarity index 100% rename from suppressions.xml rename to tools/suppressions.xml From 192288dcdf175941400f4a3631dc391638d388ed Mon Sep 17 00:00:00 2001 From: liuxiao Date: Tue, 1 Aug 2023 17:36:07 +0800 Subject: [PATCH 6/7] remove conf in checkstyle file --- tools/checkstyle.xml | 3 --- 1 file changed, 3 deletions(-) diff --git a/tools/checkstyle.xml b/tools/checkstyle.xml index 2bfd9c951..9b21713d7 100644 --- a/tools/checkstyle.xml +++ b/tools/checkstyle.xml @@ -20,9 +20,6 @@ - - - From bd70fe3cef1222b33d1f3d1ca50eeabe9c960135 Mon Sep 17 00:00:00 2001 From: Liu Xiao <42756849+liuxiaocs7@users.noreply.github.com> Date: Tue, 1 Aug 2023 19:15:00 +0800 Subject: [PATCH 7/7] Update tools/suppressions.xml Co-authored-by: imbajin --- tools/suppressions.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/suppressions.xml b/tools/suppressions.xml index adb1cfd95..098b474f9 100644 --- a/tools/suppressions.xml +++ b/tools/suppressions.xml @@ -23,4 +23,4 @@ - \ No newline at end of file +