From da6a09e548925d5de42864d988f0a1c004787078 Mon Sep 17 00:00:00 2001 From: yuanbingze Date: Mon, 28 Nov 2022 16:30:08 +0800 Subject: [PATCH 1/3] fix checkstyle check --- .../api/traverser/JaccardSimilarityAPI.java | 3 - .../exception/InvalidOperationException.java | 1 - .../hugegraph/exception/ServerException.java | 5 + .../serializer/direct/HBaseSerializer.java | 23 +- .../serializer/direct/reuse/BytesDemo.java | 15 +- .../serializer/direct/util/IdGenerator.java | 16 +- hugegraph-dist/pom.xml | 14 ++ .../licenses/LICENSE-ant-launcher.txt | 2 +- .../release-docs/licenses/LICENSE-ant.txt | 2 +- hugegraph-hubble/hubble-be/pom.xml | 14 ++ .../apache/hugegraph/config/HubbleConfig.java | 5 + .../controller/load/LoadTaskController.java | 2 +- .../apache/hugegraph/license/ServerInfo.java | 2 - .../service/load/LoadTaskService.java | 3 +- .../service/query/ExecuteHistoryService.java | 7 +- .../apache/hugegraph/util/GremlinUtil.java | 8 +- .../apache/hugegraph/util/SerializeUtil.java | 1 - hugegraph-hubble/hubble-dist/pom.xml | 14 ++ .../loader/flink/HugeGraphOutputFormat.java | 22 +- .../loader/reader/file/LocalFileReader.java | 1 - .../hugegraph/loader/reader/line/Line.java | 4 +- .../loader/spark/HugeGraphSparkLoader.java | 38 +-- .../hugegraph/loader/task/InsertTask.java | 28 +-- .../org/apache/hugegraph/base/Printer.java | 2 +- .../org/apache/hugegraph/base/ToolClient.java | 3 +- .../apache/hugegraph/formatter/Formatter.java | 6 +- .../manager/AuthBackupRestoreManager.java | 34 +-- pom.xml | 21 +- style/checkstyle.xml | 237 ++++++++++++++++++ 29 files changed, 405 insertions(+), 128 deletions(-) create mode 100644 style/checkstyle.xml 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 9139a491e..e965718b6 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 @@ -24,13 +24,10 @@ import org.apache.hugegraph.api.graph.GraphAPI; import org.apache.hugegraph.client.RestClient; - import org.apache.hugegraph.rest.RestResult; - 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 3c2a80081..09e20fcb1 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 @@ -19,7 +19,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 253aaed6f..17e0d59e2 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 @@ -24,11 +24,15 @@ import org.apache.hugegraph.rest.RestResult; import jakarta.ws.rs.core.Response; +import org.apache.hugegraph.util.Log; +import org.slf4j.Logger; public class ServerException extends RuntimeException { private static final long serialVersionUID = 6335623004322652358L; + protected static final Logger LOG = Log.logger(ServerException.class); + private static final String[] EXCEPTION_KEYS = {"exception", "Exception-Class"}; private static final String[] MESSAGE_KEYS = {"message"}; @@ -54,6 +58,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 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 27003580c..e09c6c3c4 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 @@ -42,8 +42,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; @@ -52,12 +51,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()))); @@ -73,22 +72,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()); @@ -110,15 +109,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 019849e10..c04aa5f8c 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 @@ -57,7 +57,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(); @@ -128,15 +127,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) { @@ -188,7 +186,6 @@ 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 ba0f38f36..d43cb7b1b 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 @@ -30,19 +30,19 @@ public abstract class IdGenerator { public static final Id ZERO = IdGenerator.of(0L); - public final static Id of(String id) { + public static final Id of(String id) { return new StringId(id); } - public final static Id of(UUID id) { + public static final Id of(UUID id) { return new UuidId(id); } - public final static Id of(String id, boolean uuid) { + public static final Id of(String id, boolean uuid) { return uuid ? new UuidId(id) : new StringId(id); } - public final static Id of(long id) { + public static final Id of(long id) { return new LongId(id); } @@ -59,7 +59,7 @@ public static Id of(Object id) { return new ObjectId(id); } - public final static Id of(byte[] bytes, Id.IdType type) { + public static final Id of(byte[] bytes, Id.IdType type) { switch (type) { case LONG: return new LongId(bytes); @@ -72,7 +72,7 @@ public final static Id of(byte[] bytes, Id.IdType type) { } } - public final static Id ofStoredString(String id, Id.IdType type) { + public static final Id ofStoredString(String id, Id.IdType type) { switch (type) { case LONG: return of(LongEncoding.decodeSignedB64(id)); @@ -86,7 +86,7 @@ public final static Id ofStoredString(String id, Id.IdType type) { } } - public final static String asStoredString(Id id) { + public static final String asStoredString(Id id) { switch (id.type()) { case LONG: return LongEncoding.encodeSignedB64(id.asLong()); @@ -99,7 +99,7 @@ public final static String asStoredString(Id id) { } } - public final static Id.IdType idType(Id id) { + public static final Id.IdType idType(Id id) { if (id instanceof LongId) { return Id.IdType.LONG; } diff --git a/hugegraph-dist/pom.xml b/hugegraph-dist/pom.xml index 116fb7157..20f4e764d 100644 --- a/hugegraph-dist/pom.xml +++ b/hugegraph-dist/pom.xml @@ -1,4 +1,18 @@ + diff --git a/hugegraph-dist/release-docs/licenses/LICENSE-ant-launcher.txt b/hugegraph-dist/release-docs/licenses/LICENSE-ant-launcher.txt index cdf6ff8b2..b21d867b2 100644 --- a/hugegraph-dist/release-docs/licenses/LICENSE-ant-launcher.txt +++ b/hugegraph-dist/release-docs/licenses/LICENSE-ant-launcher.txt @@ -202,7 +202,7 @@ * limitations under the License. */ -W3C® SOFTWARE NOTICE AND LICENSE +W3C� SOFTWARE NOTICE AND LICENSE http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 This work (and included software, documentation such as READMEs, or other diff --git a/hugegraph-dist/release-docs/licenses/LICENSE-ant.txt b/hugegraph-dist/release-docs/licenses/LICENSE-ant.txt index cdf6ff8b2..b21d867b2 100644 --- a/hugegraph-dist/release-docs/licenses/LICENSE-ant.txt +++ b/hugegraph-dist/release-docs/licenses/LICENSE-ant.txt @@ -202,7 +202,7 @@ * limitations under the License. */ -W3C® SOFTWARE NOTICE AND LICENSE +W3C� SOFTWARE NOTICE AND LICENSE http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 This work (and included software, documentation such as READMEs, or other diff --git a/hugegraph-hubble/hubble-be/pom.xml b/hugegraph-hubble/hubble-be/pom.xml index 17ba84899..590e8a834 100644 --- a/hugegraph-hubble/hubble-be/pom.xml +++ b/hugegraph-hubble/hubble-be/pom.xml @@ -1,4 +1,18 @@ + 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 669c9ee2c..7cfaf296a 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 @@ -23,6 +23,8 @@ import org.apache.hugegraph.exception.ExternalException; import org.apache.hugegraph.options.HubbleOptions; +import org.apache.hugegraph.util.Log; +import org.slf4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.ApplicationArguments; import org.springframework.context.annotation.Bean; @@ -33,6 +35,8 @@ @Configuration public class HubbleConfig { + protected static final Logger LOG = Log.logger(HubbleConfig.class); + @Autowired private ApplicationArguments arguments; @@ -57,6 +61,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 d05600242..4490bb191 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 @@ -245,7 +245,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 b5b5adc5b..19376d0b4 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 @@ -19,8 +19,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 478099614..9f6e2c2ca 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 @@ -436,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(); 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 91322dc3b..942c59f6b 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 @@ -93,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); @@ -112,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 4a2c0de39..99abacf67 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 @@ -45,17 +45,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 503db2a17..c4f9f1049 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 @@ -26,7 +26,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-hubble/hubble-dist/pom.xml b/hugegraph-hubble/hubble-dist/pom.xml index 3ffc38c90..cc65a8660 100644 --- a/hugegraph-hubble/hubble-dist/pom.xml +++ b/hugegraph-hubble/hubble-dist/pom.xml @@ -1,4 +1,18 @@ + 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 9b5a9e898..ee5bac032 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,18 +183,18 @@ private void flush(ElementBuilder elementBuilder, List row Map updateStrategyMap = elementMapping.updateStrategies(); if (isVertex) { - BatchVertexRequest.Builder req = new BatchVertexRequest.Builder(); - req.vertices((List) (Object) graphElements) - .updatingStrategies(updateStrategyMap) - .createIfNotExist(true); - g.updateVertices(req.build()); + BatchVertexRequest.Builder request = new BatchVertexRequest.Builder(); + request.vertices((List) (Object) graphElements) + .updatingStrategies(updateStrategyMap) + .createIfNotExist(true); + g.updateVertices(request.build()); } else { - BatchEdgeRequest.Builder req = new BatchEdgeRequest.Builder(); - req.edges((List) (Object) graphElements) - .updatingStrategies(updateStrategyMap) - .checkVertex(this.loadOptions.checkVertex) - .createIfNotExist(true); - g.updateEdges(req.build()); + BatchEdgeRequest.Builder request = new BatchEdgeRequest.Builder(); + request.edges((List) (Object) graphElements) + .updatingStrategies(updateStrategyMap) + .checkVertex(this.loadOptions.checkVertex) + .createIfNotExist(true); + g.updateEdges(request.build()); } break; case DELETE: 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 e53190be8..2ff7f6352 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 @@ -20,7 +20,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/reader/line/Line.java b/hugegraph-loader/src/main/java/org/apache/hugegraph/loader/reader/line/Line.java index e066663d2..cdac3f67d 100644 --- a/hugegraph-loader/src/main/java/org/apache/hugegraph/loader/reader/line/Line.java +++ b/hugegraph-loader/src/main/java/org/apache/hugegraph/loader/reader/line/Line.java @@ -55,7 +55,7 @@ public void rawLine(String rawLine) { this.rawLine = rawLine; } - public final String[] names() { + public String[] names() { return this.names; } @@ -63,7 +63,7 @@ public void names(String[] names) { this.names = names; } - public final Object[] values() { + public Object[] values() { return this.values; } 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 e4293f5d7..71af5f90a 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 @@ -104,14 +104,14 @@ public void load() { .set("spark.kryo.registrationRequired", "true"); try { conf.registerKryoClasses(new Class[]{ - org.apache.hadoop.hbase.io.ImmutableBytesWritable.class, - org.apache.hadoop.hbase.KeyValue.class, - org.apache.spark.sql.types.StructType.class, - StructField[].class, - StructField.class, - org.apache.spark.sql.types.LongType$.class, - org.apache.spark.sql.types.Metadata.class, - org.apache.spark.sql.types.StringType$.class, + org.apache.hadoop.hbase.io.ImmutableBytesWritable.class, + org.apache.hadoop.hbase.KeyValue.class, + org.apache.spark.sql.types.StructType.class, + StructField[].class, + StructField.class, + org.apache.spark.sql.types.LongType$.class, + org.apache.spark.sql.types.Metadata.class, + org.apache.spark.sql.types.StringType$.class, Class.forName( "org.apache.spark.internal.io.FileCommitProtocol$TaskCommitMessage"), Class.forName("scala.reflect.ClassTag$$anon$1"), @@ -309,19 +309,19 @@ private void flush(Map.Entry> builderMap, } else { // CreateIfNotExist doesn't support false now if (isVertex) { - BatchVertexRequest.Builder req = + BatchVertexRequest.Builder request = new BatchVertexRequest.Builder(); - req.vertices((List) (Object) graphElements) - .updatingStrategies(updateStrategyMap) - .createIfNotExist(true); - g.updateVertices(req.build()); + request.vertices((List) (Object) graphElements) + .updatingStrategies(updateStrategyMap) + .createIfNotExist(true); + g.updateVertices(request.build()); } else { - BatchEdgeRequest.Builder req = new BatchEdgeRequest.Builder(); - req.edges((List) (Object) graphElements) - .updatingStrategies(updateStrategyMap) - .checkVertex(isCheckVertex) - .createIfNotExist(true); - g.updateEdges(req.build()); + BatchEdgeRequest.Builder request = new BatchEdgeRequest.Builder(); + request.edges((List) (Object) graphElements) + .updatingStrategies(updateStrategyMap) + .checkVertex(isCheckVertex) + .createIfNotExist(true); + g.updateEdges(request.build()); } } graphElements.clear(); 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 2a4e82fd7..51ede4b8b 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 @@ -48,9 +48,9 @@ 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 " + + "Connection refused", + "The server is being shutting down", + "not allowed to insert, because already exist a vertex " + "with same id and different label" }; @@ -127,20 +127,20 @@ protected void updateBatch(List batch, boolean checkVertex) { batch.forEach(r -> elements.add(r.element())); // CreateIfNotExist does not support false now if (this.type().isVertex()) { - BatchVertexRequest.Builder req = new BatchVertexRequest.Builder(); - req.vertices((List) (Object) elements) - .updatingStrategies(this.mapping.updateStrategies()) - .createIfNotExist(true); + BatchVertexRequest.Builder request = new BatchVertexRequest.Builder(); + request.vertices((List) (Object) elements) + .updatingStrategies(this.mapping.updateStrategies()) + .createIfNotExist(true); - client.graph().updateVertices(req.build()); + client.graph().updateVertices(request.build()); } else { - BatchEdgeRequest.Builder req = new BatchEdgeRequest.Builder(); - req.edges((List) (Object) elements) - .updatingStrategies(this.mapping.updateStrategies()) - .checkVertex(checkVertex) - .createIfNotExist(true); + BatchEdgeRequest.Builder request = new BatchEdgeRequest.Builder(); + request.edges((List) (Object) elements) + .updatingStrategies(this.mapping.updateStrategies()) + .checkVertex(checkVertex) + .createIfNotExist(true); - client.graph().updateEdges(req.build()); + client.graph().updateEdges(request.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 d5a907e4f..8b646cc8f 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 @@ -29,7 +29,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 24ce53bea..0d4629bf0 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 @@ -48,7 +48,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/formatter/Formatter.java b/hugegraph-tools/src/main/java/org/apache/hugegraph/formatter/Formatter.java index 46f2a8c6d..e5cbd287e 100644 --- a/hugegraph-tools/src/main/java/org/apache/hugegraph/formatter/Formatter.java +++ b/hugegraph-tools/src/main/java/org/apache/hugegraph/formatter/Formatter.java @@ -24,11 +24,11 @@ public interface Formatter { // Serialize a vertex(with edge and property) to string - public String dump(JsonGraph.JsonVertex vertex) throws Exception; + String dump(JsonGraph.JsonVertex vertex) throws Exception; - public static final String PACKAGE = Formatter.class.getPackage().getName(); + String PACKAGE = Formatter.class.getPackage().getName(); - public static Formatter loadFormatter(String formatter) { + static Formatter loadFormatter(String formatter) { String classPath = String.format("%s.%s", PACKAGE, formatter); ClassLoader loader = Formatter.class.getClassLoader(); try { 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 7089edd26..87cdc71a7 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 @@ -109,7 +109,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(); } } @@ -129,13 +129,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(); } } @@ -178,11 +178,11 @@ private List readRestoreData(HugeType type) { List resultList = Lists.newArrayList(); 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); - } + BufferedReader reader = new BufferedReader(isr)) { + 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); @@ -262,7 +262,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(); @@ -341,7 +341,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(); @@ -411,7 +411,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(); @@ -487,8 +487,8 @@ public List checkConflict() { "querying belongs of authority"); 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(); @@ -522,7 +522,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++; } @@ -549,8 +549,8 @@ public List checkConflict() { "querying accesses of authority"); 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(); @@ -584,7 +584,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/pom.xml b/pom.xml index 36cf930a6..01bbda335 100644 --- a/pom.xml +++ b/pom.xml @@ -17,7 +17,11 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - + + org.apache + apache + 23 + org.apache.hugegraph hugegraph-toolchain ${revision} @@ -29,12 +33,6 @@ hugegraph-toolchain is the integration project of a series of utilities for HugeGraph, it includes 4 main modules (loader/hubble/tools/client) - - org.apache - apache - 23 - - The Apache Software License, Version 2.0 @@ -83,6 +81,8 @@ ${project.name} ${project.version} 2.2.3 + 3.1.2 + 8.45 @@ -348,20 +348,19 @@ - org.apache.maven.plugins maven-checkstyle-plugin - 3.1.2 + ${checkstyle.plugin.version} com.puppycrawl.tools checkstyle - 8.45 + ${checkstyle.version} - checkstyle.xml + style/checkstyle.xml UTF-8 true true diff --git a/style/checkstyle.xml b/style/checkstyle.xml new file mode 100644 index 000000000..f539aa1f5 --- /dev/null +++ b/style/checkstyle.xml @@ -0,0 +1,237 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 1816199df420ce598316ab9617166756e12ae7b6 Mon Sep 17 00:00:00 2001 From: yuanbingze Date: Mon, 28 Nov 2022 18:29:57 +0800 Subject: [PATCH 2/3] delete blankspace --- .../java/org/apache/hugegraph/exception/ServerException.java | 2 +- hugegraph-dist/release-docs/licenses/LICENSE-ant-launcher.txt | 2 +- hugegraph-dist/release-docs/licenses/LICENSE-ant.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) 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 17e0d59e2..22fa3a02e 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 @@ -58,7 +58,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 excepiton "); + LOG.error("ServerException fromResponse excepiton"); } return exception; diff --git a/hugegraph-dist/release-docs/licenses/LICENSE-ant-launcher.txt b/hugegraph-dist/release-docs/licenses/LICENSE-ant-launcher.txt index b21d867b2..cdf6ff8b2 100644 --- a/hugegraph-dist/release-docs/licenses/LICENSE-ant-launcher.txt +++ b/hugegraph-dist/release-docs/licenses/LICENSE-ant-launcher.txt @@ -202,7 +202,7 @@ * limitations under the License. */ -W3C� SOFTWARE NOTICE AND LICENSE +W3C® SOFTWARE NOTICE AND LICENSE http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 This work (and included software, documentation such as READMEs, or other diff --git a/hugegraph-dist/release-docs/licenses/LICENSE-ant.txt b/hugegraph-dist/release-docs/licenses/LICENSE-ant.txt index b21d867b2..cdf6ff8b2 100644 --- a/hugegraph-dist/release-docs/licenses/LICENSE-ant.txt +++ b/hugegraph-dist/release-docs/licenses/LICENSE-ant.txt @@ -202,7 +202,7 @@ * limitations under the License. */ -W3C� SOFTWARE NOTICE AND LICENSE +W3C® SOFTWARE NOTICE AND LICENSE http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 This work (and included software, documentation such as READMEs, or other From 6eddbc8d39a8bc24c7f96e535dc2c06dafc95be2 Mon Sep 17 00:00:00 2001 From: yuanbingze Date: Mon, 28 Nov 2022 18:38:28 +0800 Subject: [PATCH 3/3] delete HugeGraphOutputFormat extra space --- .../apache/hugegraph/loader/flink/HugeGraphOutputFormat.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 ee5bac032..5763c0a7e 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 @@ -193,7 +193,7 @@ private void flush(ElementBuilder elementBuilder, List row request.edges((List) (Object) graphElements) .updatingStrategies(updateStrategyMap) .checkVertex(this.loadOptions.checkVertex) - .createIfNotExist(true); + .createIfNotExist(true); g.updateEdges(request.build()); } break;