diff --git a/hugegraph-commons/hugegraph-dist/release-docs/NOTICE b/hugegraph-commons/hugegraph-dist/release-docs/NOTICE index 7d13a7d48f..c021594e78 100644 --- a/hugegraph-commons/hugegraph-dist/release-docs/NOTICE +++ b/hugegraph-commons/hugegraph-dist/release-docs/NOTICE @@ -1,5 +1,5 @@ Apache HugeGraph(incubating) -Copyright 2022-2023 The Apache Software Foundation +Copyright 2022-2024 The Apache Software Foundation This product includes software developed at The Apache Software Foundation (http://www.apache.org/). diff --git a/hugegraph-commons/hugegraph-rpc/pom.xml b/hugegraph-commons/hugegraph-rpc/pom.xml index 0637da1c5c..23f0a32077 100644 --- a/hugegraph-commons/hugegraph-rpc/pom.xml +++ b/hugegraph-commons/hugegraph-rpc/pom.xml @@ -62,6 +62,7 @@ com.alipay.sofa sofa-rpc-all + 5.7.6 diff --git a/hugegraph-commons/hugegraph-rpc/src/main/java/org/apache/hugegraph/config/RpcOptions.java b/hugegraph-commons/hugegraph-rpc/src/main/java/org/apache/hugegraph/config/RpcOptions.java index 09adcbab84..43985a5317 100644 --- a/hugegraph-commons/hugegraph-rpc/src/main/java/org/apache/hugegraph/config/RpcOptions.java +++ b/hugegraph-commons/hugegraph-rpc/src/main/java/org/apache/hugegraph/config/RpcOptions.java @@ -104,8 +104,7 @@ public static synchronized RpcOptions instance() { public static final ConfigOption RPC_CLIENT_READ_TIMEOUT = new ConfigOption<>( "rpc.client_read_timeout", - "The timeout(in seconds) of rpc client read from rpc " + - "server.", + "The timeout(in seconds) of rpc client read from RPC server.", rangeInt(1, Integer.MAX_VALUE), 40 ); @@ -121,7 +120,7 @@ public static synchronized RpcOptions instance() { public static final ConfigOption RPC_CLIENT_LOAD_BALANCER = new ConfigOption<>( "rpc.client_load_balancer", - "The rpc client uses a load-balancing algorithm to " + + "The RPC client uses a load-balancing algorithm to " + "access multiple rpc servers in one cluster. Default " + "value is 'consistentHash', means forwarding by request " + "parameters.", @@ -133,16 +132,26 @@ public static synchronized RpcOptions instance() { public static final ConfigOption RPC_PROTOCOL = new ConfigOption<>( "rpc.protocol", - "Rpc communication protocol, client and server need to " + + "RPC communication protocol, client and server need to " + "be specified the same value.", allowValues("bolt", "rest", "dubbo", "h2c", "http"), "bolt" ); + public static final ConfigOption RPC_SERIALIZATION = + new ConfigOption<>( + "rpc.serialization", + "RPC serialization type, client and server must set the same value." + + "Note: If you choose 'protobuf', you need to add the relative IDL file. " + + "(Could refer PD/Store *.proto)", + allowValues("hessian2", "protobuf"), + "hessian2" + ); + public static final ConfigOption RPC_CONFIG_ORDER = new ConfigOption<>( "rpc.config_order", - "Sofa rpc configuration file loading order, the larger " + + "Sofa-RPC configuration file loading order, the larger " + "the more later loading.", rangeInt(1, Integer.MAX_VALUE), 999 @@ -151,7 +160,7 @@ public static synchronized RpcOptions instance() { public static final ConfigOption RPC_LOGGER_IMPL = new ConfigOption<>( "rpc.logger_impl", - "Sofa rpc log implementation class.", + "Sofa-RPC log implementation class.", disallowEmpty(), "com.alipay.sofa.rpc.log.SLF4JLoggerImpl" ); diff --git a/hugegraph-commons/hugegraph-rpc/src/main/java/org/apache/hugegraph/rpc/RpcConsumerConfig.java b/hugegraph-commons/hugegraph-rpc/src/main/java/org/apache/hugegraph/rpc/RpcConsumerConfig.java index c489f5cd9b..9459ac516a 100644 --- a/hugegraph-commons/hugegraph-rpc/src/main/java/org/apache/hugegraph/rpc/RpcConsumerConfig.java +++ b/hugegraph-commons/hugegraph-rpc/src/main/java/org/apache/hugegraph/rpc/RpcConsumerConfig.java @@ -22,6 +22,9 @@ import java.util.Map; import java.util.Set; +import org.apache.hugegraph.config.HugeConfig; +import org.apache.hugegraph.config.RpcOptions; +import org.apache.hugegraph.util.Log; import org.slf4j.Logger; import com.alipay.sofa.rpc.bootstrap.Bootstraps; @@ -36,9 +39,6 @@ import com.alipay.sofa.rpc.core.response.SofaResponse; import com.alipay.sofa.rpc.ext.Extension; import com.alipay.sofa.rpc.ext.ExtensionLoaderFactory; -import org.apache.hugegraph.config.HugeConfig; -import org.apache.hugegraph.config.RpcOptions; -import org.apache.hugegraph.util.Log; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.collect.Sets; @@ -135,6 +135,7 @@ private ConsumerConfig consumerConfig(String graph, .setConnectTimeout(connectTimeout) .setReconnectPeriod(reconnectPeriod) .setRetries(retries) + .setSerialization(conf.get(RpcOptions.RPC_SERIALIZATION)) .setLoadBalancer(loadBalancer); this.configs.put(serviceId, consumerConfig); @@ -168,13 +169,13 @@ protected SofaResponse doInvoke(SofaRequest request) } } - if (responses.size() > 0) { + if (!responses.isEmpty()) { /* * Just choose the first one as result to return, ignore others * TODO: maybe more strategies should be provided */ return responses.get(0); - } else if (excepts.size() > 0) { + } else if (!excepts.isEmpty()) { throw excepts.get(0); } else { assert providers.isEmpty(); diff --git a/hugegraph-commons/hugegraph-rpc/src/main/java/org/apache/hugegraph/rpc/RpcServer.java b/hugegraph-commons/hugegraph-rpc/src/main/java/org/apache/hugegraph/rpc/RpcServer.java index fe0b91ac58..7791ac8cd5 100644 --- a/hugegraph-commons/hugegraph-rpc/src/main/java/org/apache/hugegraph/rpc/RpcServer.java +++ b/hugegraph-commons/hugegraph-rpc/src/main/java/org/apache/hugegraph/rpc/RpcServer.java @@ -19,6 +19,12 @@ import java.util.Map; +import org.apache.commons.collections.MapUtils; +import org.apache.hugegraph.config.HugeConfig; +import org.apache.hugegraph.config.RpcOptions; +import org.apache.hugegraph.testutil.Whitebox; +import org.apache.hugegraph.util.E; +import org.apache.hugegraph.util.Log; import org.slf4j.Logger; import com.alipay.remoting.RemotingServer; @@ -27,12 +33,6 @@ import com.alipay.sofa.rpc.config.ServerConfig; import com.alipay.sofa.rpc.server.Server; import com.alipay.sofa.rpc.server.bolt.BoltServer; -import org.apache.hugegraph.config.RpcOptions; -import org.apache.commons.collections.MapUtils; -import org.apache.hugegraph.config.HugeConfig; -import org.apache.hugegraph.testutil.Whitebox; -import org.apache.hugegraph.util.E; -import org.apache.hugegraph.util.Log; public class RpcServer { @@ -55,6 +55,7 @@ public RpcServer(HugeConfig config) { this.serverConfig.setProtocol(config.get(RpcOptions.RPC_PROTOCOL)) .setHost(host).setPort(port) .setAdaptivePort(adaptivePort) + .setSerialization(config.get(RpcOptions.RPC_SERIALIZATION)) .setDaemon(false); } else { this.serverConfig = null; @@ -87,8 +88,7 @@ public int port() { * TODO: remove this code after adding Server.port() interface: * https://github.com/sofastack/sofa-rpc/issues/1022 */ - RemotingServer rs = Whitebox.getInternalState(server, - "remotingServer"); + RemotingServer rs = Whitebox.getInternalState(server, "remotingServer"); return rs.port(); } // When using random port 0, the returned port is not the actual port diff --git a/hugegraph-commons/hugegraph-rpc/src/test/java/org/apache/hugegraph/unit/ServerClientTest.java b/hugegraph-commons/hugegraph-rpc/src/test/java/org/apache/hugegraph/unit/ServerClientTest.java index 6b800c02c2..a1c64c0585 100644 --- a/hugegraph-commons/hugegraph-rpc/src/test/java/org/apache/hugegraph/unit/ServerClientTest.java +++ b/hugegraph-commons/hugegraph-rpc/src/test/java/org/apache/hugegraph/unit/ServerClientTest.java @@ -21,14 +21,6 @@ import java.net.InetAddress; import java.net.ServerSocket; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; - -import com.alipay.sofa.rpc.common.RpcOptions; -import com.alipay.sofa.rpc.core.exception.SofaRpcException; -import com.alipay.sofa.rpc.core.exception.SofaRpcRuntimeException; import org.apache.hugegraph.config.HugeConfig; import org.apache.hugegraph.rpc.RpcClientProvider; import org.apache.hugegraph.rpc.RpcCommonConfig; @@ -38,6 +30,14 @@ import org.apache.hugegraph.testutil.Assert; import org.apache.hugegraph.testutil.Whitebox; import org.apache.hugegraph.util.E; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +import com.alipay.sofa.rpc.common.RpcOptions; +import com.alipay.sofa.rpc.core.exception.SofaRpcException; +import com.alipay.sofa.rpc.core.exception.SofaRpcRuntimeException; import com.google.common.collect.ImmutableMap; public class ServerClientTest extends BaseUnitTest { @@ -169,7 +169,7 @@ public void testStartServerWithAdaptivePort() throws IOException { RpcProviderConfig serverConfig = rpcServerAdaptive.config(); serverConfig.addService(HelloService.class, new HelloServiceImpl()); - // Start other server bound the port + // Start another server bound the port int usedPort = rpcServerAdaptive.port(); InetAddress ip = InetAddress.getByName(rpcServerAdaptive.host()); ServerSocket inUse = new ServerSocket(usedPort,50, ip); diff --git a/hugegraph-server/hugegraph-api/pom.xml b/hugegraph-server/hugegraph-api/pom.xml index 8a6fdb9e77..5bef81e048 100644 --- a/hugegraph-server/hugegraph-api/pom.xml +++ b/hugegraph-server/hugegraph-api/pom.xml @@ -38,6 +38,8 @@ io.grpc grpc-netty-shaded + + 1.47.0 diff --git a/hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/core/GraphManager.java b/hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/core/GraphManager.java index 9a9d957e8b..daae180a36 100644 --- a/hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/core/GraphManager.java +++ b/hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/core/GraphManager.java @@ -89,7 +89,7 @@ public final class GraphManager { private final RpcClientProvider rpcClient; private RoleElectionStateMachine roleStateMachine; - private GlobalMasterInfo globalNodeRoleInfo; + private final GlobalMasterInfo globalNodeRoleInfo; private final HugeConfig conf; private final EventHub eventHub; diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/HugeGraphParams.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/HugeGraphParams.java index 5556fdfa6a..b0b19c7071 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/HugeGraphParams.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/HugeGraphParams.java @@ -25,7 +25,6 @@ import org.apache.hugegraph.backend.store.ram.RamTable; import org.apache.hugegraph.backend.tx.GraphTransaction; import org.apache.hugegraph.backend.tx.ISchemaTransaction; -import org.apache.hugegraph.backend.tx.SchemaTransaction; import org.apache.hugegraph.config.HugeConfig; import org.apache.hugegraph.event.EventHub; import org.apache.hugegraph.job.EphemeralJob; diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/serializer/BinaryBackendEntry.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/serializer/BinaryBackendEntry.java index ca605f0b65..67e437d9cf 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/serializer/BinaryBackendEntry.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/serializer/BinaryBackendEntry.java @@ -49,7 +49,8 @@ public BinaryBackendEntry(HugeType type, byte[] bytes, boolean enablePartition) } // FIXME: `enablePartition` is unused here - public BinaryBackendEntry(HugeType type, byte[] bytes, boolean enablePartition, boolean isOlap) { + public BinaryBackendEntry(HugeType type, byte[] bytes, boolean enablePartition, + boolean isOlap) { this(type, BytesBuffer.wrap(bytes).parseOlapId(type, isOlap)); } diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/serializer/BinarySerializer.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/serializer/BinarySerializer.java index 677ed165f1..0bb07760a5 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/serializer/BinarySerializer.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/serializer/BinarySerializer.java @@ -17,6 +17,8 @@ package org.apache.hugegraph.backend.serializer; +import static org.apache.hugegraph.schema.SchemaElement.UNDEF; + import java.util.Arrays; import java.util.Collection; import java.util.Iterator; @@ -74,8 +76,6 @@ import org.apache.hugegraph.util.StringEncoding; import org.apache.tinkerpop.gremlin.structure.Edge; -import static org.apache.hugegraph.schema.SchemaElement.UNDEF; - public class BinarySerializer extends AbstractSerializer { /* @@ -932,10 +932,10 @@ public BackendEntry parse(BackendEntry originEntry) { BytesBuffer buffer = BytesBuffer.allocate(BytesBuffer.BUF_EDGE_ID); buffer.write(parsedEntry.id().asBytes()); buffer.write(bytes); - parsedEntry = new BinaryBackendEntry(originEntry.type(), new BinaryId(buffer.bytes(), - BytesBuffer.wrap( - buffer.bytes()) - .readEdgeId())); + parsedEntry = new BinaryBackendEntry(originEntry.type(), + new BinaryId(buffer.bytes(), + BytesBuffer.wrap(buffer.bytes()) + .readEdgeId())); for (BackendColumn col : originEntry.columns()) { parsedEntry.column(buffer.bytes(), col.value); diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/tx/GraphTransaction.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/tx/GraphTransaction.java index ccd2b5405f..7f441574eb 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/tx/GraphTransaction.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/tx/GraphTransaction.java @@ -34,8 +34,6 @@ import java.util.stream.Collectors; import java.util.stream.Stream; -import com.google.common.collect.Iterators; - import org.apache.commons.collections.CollectionUtils; import org.apache.hugegraph.HugeException; import org.apache.hugegraph.HugeGraph; @@ -103,6 +101,7 @@ import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils; import com.google.common.collect.ImmutableList; +import com.google.common.collect.Iterators; import jakarta.ws.rs.ForbiddenException; @@ -1053,8 +1052,10 @@ protected Iterator queryEdgesFromBackend(Query query) { if (query instanceof ConditionQuery && !query.paging()) { // TODO: support: paging + parent label boolean supportIn = this.storeFeatures().supportsQueryWithInCondition(); - // consider multi labels + properties, see org.apache.hugegraph.core.EdgeCoreTest.testQueryInEdgesOfVertexByLabels - Stream flattenedQueries = ConditionQueryFlatten.flatten((ConditionQuery) query, supportIn).stream(); + // consider multi labels + properties, + // see org.apache.hugegraph.core.EdgeCoreTest.testQueryInEdgesOfVertexByLabels + Stream flattenedQueries = + ConditionQueryFlatten.flatten((ConditionQuery) query, supportIn).stream(); Stream> edgeIterators = flattenedQueries.map(cq -> { Id label = cq.condition(HugeKeys.LABEL); @@ -1073,7 +1074,8 @@ protected Iterator queryEdgesFromBackend(Query query) { } }); - return edgeIterators.reduce(ExtendableIterator::concat).orElse(Collections.emptyIterator()); + return edgeIterators.reduce(ExtendableIterator::concat) + .orElse(Collections.emptyIterator()); } return queryEdgesFromBackendInternal(query); @@ -1640,7 +1642,8 @@ private Query optimizeQuery(ConditionQuery query) { */ boolean byLabel = (label != null && query.conditionsSize() == 1); if (!byLabel || this.store().features().supportsQueryByLabel()) { - if (this.storeFeatures().supportsFatherAndSubEdgeLabel() && byLabel && query.resultType().isEdge()) { + if (this.storeFeatures().supportsFatherAndSubEdgeLabel() && byLabel && + query.resultType().isEdge()) { // for memory backend EdgeLabel edgeLabel = graph().edgeLabel(label); if (edgeLabel.hasFather()) { diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/tx/SchemaTransactionV2.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/tx/SchemaTransactionV2.java index 903bfade68..d24e2767db 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/tx/SchemaTransactionV2.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/tx/SchemaTransactionV2.java @@ -626,7 +626,8 @@ public Id createOlapPk(PropertyKey propertyKey) { return asyncRun(this.graph(), propertyKey, job); } - // -- store related methods, divided into two categories: 1. olap table related 2. ID generation strategy + // -- store related methods, divided into two categories: + // 1. olap table related 2. ID generation strategy // - 1. olap table related public void createOlapPk(Id id) { this.graphParams().loadGraphStore().createOlapTable(id); diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/job/algorithm/cent/BetweennessCentralityAlgorithmV2.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/job/algorithm/cent/BetweennessCentralityAlgorithmV2.java index bc4c3ae378..ca99fddf8d 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/job/algorithm/cent/BetweennessCentralityAlgorithmV2.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/job/algorithm/cent/BetweennessCentralityAlgorithmV2.java @@ -26,7 +26,6 @@ import org.apache.hugegraph.backend.query.Query; import org.apache.hugegraph.job.UserJob; import org.apache.hugegraph.job.algorithm.BfsTraverser; -import org.apache.hugegraph.schema.SchemaLabel; import org.apache.hugegraph.structure.HugeVertex; import org.apache.hugegraph.traversal.algorithm.HugeTraverser; import org.apache.hugegraph.type.define.Directions; diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/job/schema/EdgeLabelRemoveJob.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/job/schema/EdgeLabelRemoveJob.java index e8d3461e34..7e100c1f74 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/job/schema/EdgeLabelRemoveJob.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/job/schema/EdgeLabelRemoveJob.java @@ -23,7 +23,6 @@ import org.apache.hugegraph.backend.id.Id; import org.apache.hugegraph.backend.tx.GraphTransaction; import org.apache.hugegraph.backend.tx.ISchemaTransaction; -import org.apache.hugegraph.backend.tx.SchemaTransaction; import org.apache.hugegraph.schema.EdgeLabel; import org.apache.hugegraph.type.define.SchemaStatus; import org.apache.hugegraph.util.LockUtil; diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/job/schema/IndexLabelRebuildJob.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/job/schema/IndexLabelRebuildJob.java index 5e4acf92e9..c44b60e1a3 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/job/schema/IndexLabelRebuildJob.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/job/schema/IndexLabelRebuildJob.java @@ -25,7 +25,6 @@ import org.apache.hugegraph.backend.id.Id; import org.apache.hugegraph.backend.tx.GraphTransaction; import org.apache.hugegraph.backend.tx.ISchemaTransaction; -import org.apache.hugegraph.backend.tx.SchemaTransaction; import org.apache.hugegraph.schema.EdgeLabel; import org.apache.hugegraph.schema.IndexLabel; import org.apache.hugegraph.schema.SchemaElement; diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/job/schema/IndexLabelRemoveJob.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/job/schema/IndexLabelRemoveJob.java index b87978d8b2..1dad57dd39 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/job/schema/IndexLabelRemoveJob.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/job/schema/IndexLabelRemoveJob.java @@ -21,7 +21,6 @@ import org.apache.hugegraph.backend.id.Id; import org.apache.hugegraph.backend.tx.GraphTransaction; import org.apache.hugegraph.backend.tx.ISchemaTransaction; -import org.apache.hugegraph.backend.tx.SchemaTransaction; import org.apache.hugegraph.schema.IndexLabel; import org.apache.hugegraph.type.define.SchemaStatus; import org.apache.hugegraph.util.LockUtil; diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/job/schema/OlapPropertyKeyClearJob.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/job/schema/OlapPropertyKeyClearJob.java index 155a6b8bfa..d6e0666bfa 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/job/schema/OlapPropertyKeyClearJob.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/job/schema/OlapPropertyKeyClearJob.java @@ -21,7 +21,6 @@ import org.apache.hugegraph.backend.id.Id; import org.apache.hugegraph.backend.tx.GraphTransaction; import org.apache.hugegraph.backend.tx.ISchemaTransaction; -import org.apache.hugegraph.backend.tx.SchemaTransaction; import org.apache.hugegraph.schema.IndexLabel; import org.apache.hugegraph.type.define.SchemaStatus; import org.apache.hugegraph.util.LockUtil; diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/job/schema/OlapPropertyKeyCreateJob.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/job/schema/OlapPropertyKeyCreateJob.java index 272ebbc3e5..483b9106f8 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/job/schema/OlapPropertyKeyCreateJob.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/job/schema/OlapPropertyKeyCreateJob.java @@ -18,7 +18,6 @@ package org.apache.hugegraph.job.schema; import org.apache.hugegraph.backend.tx.ISchemaTransaction; -import org.apache.hugegraph.backend.tx.SchemaTransaction; import org.apache.hugegraph.schema.PropertyKey; public class OlapPropertyKeyCreateJob extends SchemaJob { diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/job/schema/OlapPropertyKeyRemoveJob.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/job/schema/OlapPropertyKeyRemoveJob.java index 200ef51c37..e6f5f20e0c 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/job/schema/OlapPropertyKeyRemoveJob.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/job/schema/OlapPropertyKeyRemoveJob.java @@ -19,7 +19,6 @@ import org.apache.hugegraph.backend.id.Id; import org.apache.hugegraph.backend.tx.ISchemaTransaction; -import org.apache.hugegraph.backend.tx.SchemaTransaction; import org.apache.hugegraph.schema.PropertyKey; public class OlapPropertyKeyRemoveJob extends OlapPropertyKeyClearJob { diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/job/schema/VertexLabelRemoveJob.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/job/schema/VertexLabelRemoveJob.java index 86c059e8f7..204d3f5a5d 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/job/schema/VertexLabelRemoveJob.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/job/schema/VertexLabelRemoveJob.java @@ -25,7 +25,6 @@ import org.apache.hugegraph.backend.id.Id; import org.apache.hugegraph.backend.tx.GraphTransaction; import org.apache.hugegraph.backend.tx.ISchemaTransaction; -import org.apache.hugegraph.backend.tx.SchemaTransaction; import org.apache.hugegraph.schema.EdgeLabel; import org.apache.hugegraph.schema.VertexLabel; import org.apache.hugegraph.type.define.SchemaStatus; diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/masterelection/GlobalMasterInfo.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/masterelection/GlobalMasterInfo.java index 8a36513cda..c345c50e60 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/masterelection/GlobalMasterInfo.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/masterelection/GlobalMasterInfo.java @@ -25,7 +25,7 @@ // TODO: rename to GlobalNodeRoleInfo public final class GlobalMasterInfo { - private final static NodeInfo NO_MASTER = new NodeInfo(false, ""); + private static final NodeInfo NO_MASTER = new NodeInfo(false, ""); private volatile boolean supportElection; private volatile NodeInfo masterNodeInfo; diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/meta/MetaDriver.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/meta/MetaDriver.java index 2d0936498f..1409adb47c 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/meta/MetaDriver.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/meta/MetaDriver.java @@ -25,21 +25,21 @@ public interface MetaDriver { - public void put(String key, String value); + void put(String key, String value); - public String get(String key); + String get(String key); - public void delete(String key); + void delete(String key); - public void deleteWithPrefix(String prefix); + void deleteWithPrefix(String prefix); - public Map scanWithPrefix(String prefix); + Map scanWithPrefix(String prefix); - public void listen(String key, Consumer consumer); + void listen(String key, Consumer consumer); - public void listenPrefix(String prefix, Consumer consumer); + void listenPrefix(String prefix, Consumer consumer); - public List extractValuesFromResponse(T response); + List extractValuesFromResponse(T response); /** * Extract K-V pairs of response @@ -48,9 +48,9 @@ public interface MetaDriver { * @param response * @return */ - public Map extractKVFromResponse(T response); + Map extractKVFromResponse(T response); - public LockResult tryLock(String key, long ttl, long timeout); + LockResult tryLock(String key, long ttl, long timeout); /** * return if the key is Locked. @@ -58,9 +58,9 @@ public interface MetaDriver { * @param key * @return bool */ - public boolean isLocked(String key); + boolean isLocked(String key); - public void unlock(String key, LockResult lockResult); + void unlock(String key, LockResult lockResult); /** * keepAlive of current lease @@ -69,5 +69,5 @@ public interface MetaDriver { * @param lease * @return next leaseId */ - public long keepAlive(String key, long lease); + long keepAlive(String key, long lease); } diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/meta/lock/EtcdDistributedLock.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/meta/lock/EtcdDistributedLock.java index 3e9a830581..390ab9ea2d 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/meta/lock/EtcdDistributedLock.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/meta/lock/EtcdDistributedLock.java @@ -44,11 +44,12 @@ public class EtcdDistributedLock { private final Lease leaseClient; private static final int poolSize = 8; - private final ScheduledExecutorService service = new ScheduledThreadPoolExecutor(poolSize, r -> { - Thread t = new Thread(r, "keepalive"); - t.setDaemon(true); - return t; - }); + private final ScheduledExecutorService service = + new ScheduledThreadPoolExecutor(poolSize, r -> { + Thread t = new Thread(r, "keepalive"); + t.setDaemon(true); + return t; + }); private EtcdDistributedLock(Client client) { this.kvClient = client.getKVClient(); diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/schema/builder/PropertyKeyBuilder.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/schema/builder/PropertyKeyBuilder.java index 6ce6ddd847..a50b426d1d 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/schema/builder/PropertyKeyBuilder.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/schema/builder/PropertyKeyBuilder.java @@ -25,7 +25,6 @@ import org.apache.hugegraph.backend.id.Id; import org.apache.hugegraph.backend.id.IdGenerator; import org.apache.hugegraph.backend.tx.ISchemaTransaction; -import org.apache.hugegraph.backend.tx.SchemaTransaction; import org.apache.hugegraph.config.CoreOptions; import org.apache.hugegraph.exception.ExistedException; import org.apache.hugegraph.exception.NotAllowException; @@ -42,17 +41,16 @@ import org.apache.hugegraph.type.define.WriteType; import org.apache.hugegraph.util.E; -public class PropertyKeyBuilder extends AbstractBuilder - implements PropertyKey.Builder { +public class PropertyKeyBuilder extends AbstractBuilder implements PropertyKey.Builder { private Id id; - private String name; + private final String name; private DataType dataType; private Cardinality cardinality; private AggregateType aggregateType; private WriteType writeType; private boolean checkExist; - private Userdata userdata; + private final Userdata userdata; public PropertyKeyBuilder(ISchemaTransaction transaction, HugeGraph graph, String name) { diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/schema/builder/VertexLabelBuilder.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/schema/builder/VertexLabelBuilder.java index dfd56565d4..53b6cabddb 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/schema/builder/VertexLabelBuilder.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/schema/builder/VertexLabelBuilder.java @@ -30,7 +30,6 @@ import org.apache.hugegraph.backend.id.Id; import org.apache.hugegraph.backend.id.IdGenerator; import org.apache.hugegraph.backend.tx.ISchemaTransaction; -import org.apache.hugegraph.backend.tx.SchemaTransaction; import org.apache.hugegraph.exception.ExistedException; import org.apache.hugegraph.exception.NotAllowException; import org.apache.hugegraph.exception.NotFoundException; @@ -45,19 +44,18 @@ import com.google.common.collect.ImmutableList; -public class VertexLabelBuilder extends AbstractBuilder - implements VertexLabel.Builder { +public class VertexLabelBuilder extends AbstractBuilder implements VertexLabel.Builder { private Id id; - private String name; + private final String name; private IdStrategy idStrategy; - private Set properties; - private List primaryKeys; - private Set nullableKeys; + private final Set properties; + private final List primaryKeys; + private final Set nullableKeys; private long ttl; private String ttlStartTime; private Boolean enableLabelIndex; - private Userdata userdata; + private final Userdata userdata; private boolean checkExist; public VertexLabelBuilder(ISchemaTransaction transaction, @@ -559,7 +557,7 @@ private void checkTtl() { if (this.ttlStartTime == null) { return; } - // Check whether the properties contains the specified keys + // Check whether the properties contain the specified keys E.checkArgument(!this.properties.isEmpty(), "The properties can't be empty when exist " + "ttl start time for edge label '%s'", this.name); diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/space/GraphSpace.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/space/GraphSpace.java index 047bd65f53..1ed255001b 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/space/GraphSpace.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/space/GraphSpace.java @@ -66,7 +66,6 @@ public class GraphSpace { private Date createTime; private Date updateTime; - public GraphSpace(String name) { E.checkArgument(name != null && !StringUtils.isEmpty(name), "The name of graph space can't be null or empty"); diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/structure/HugeIndex.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/structure/HugeIndex.java index fa442e1298..6e76913935 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/structure/HugeIndex.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/structure/HugeIndex.java @@ -255,7 +255,8 @@ public static HugeIndex parseIndexId(HugeGraph graph, HugeType type, "Invalid range index field type"); Class clazz = dataType.isNumber() ? dataType.clazz() : DataType.LONG.clazz(); - values = bytes2number(buffer.read(id.length - labelLength - HUGE_TYPE_CODE_LENGTH), clazz); + values = bytes2number(buffer.read(id.length - labelLength - HUGE_TYPE_CODE_LENGTH), + clazz); } HugeIndex index = new HugeIndex(graph, indexLabel); index.fieldValues(values); diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/task/HugeTaskResult.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/task/HugeTaskResult.java index 24fc186cd9..1c47ee9da5 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/task/HugeTaskResult.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/task/HugeTaskResult.java @@ -21,13 +21,7 @@ import java.util.Iterator; import java.util.List; -import org.apache.hugegraph.HugeGraph; import org.apache.hugegraph.backend.id.Id; -import org.apache.hugegraph.schema.PropertyKey; -import org.apache.hugegraph.schema.SchemaManager; -import org.apache.hugegraph.schema.VertexLabel; -import org.apache.hugegraph.type.define.Cardinality; -import org.apache.hugegraph.type.define.DataType; import org.apache.hugegraph.util.Blob; import org.apache.hugegraph.util.E; import org.apache.hugegraph.util.Log; diff --git a/hugegraph-server/hugegraph-dist/src/assembly/static/conf/rest-server.properties b/hugegraph-server/hugegraph-dist/src/assembly/static/conf/rest-server.properties index 9d6bb2ca82..25b7644f7b 100644 --- a/hugegraph-server/hugegraph-dist/src/assembly/static/conf/rest-server.properties +++ b/hugegraph-server/hugegraph-dist/src/assembly/static/conf/rest-server.properties @@ -31,9 +31,10 @@ arthas.disabled_commands=jad #auth.admin_token= #auth.user_tokens=[] +# TODO: Deprecated & removed later (useless from version 1.5.0) # rpc server configs for multi graph-servers or raft-servers -rpc.server_host=127.0.0.1 -rpc.server_port=8091 +#rpc.server_host=127.0.0.1 +#rpc.server_port=8091 #rpc.server_timeout=30 # rpc client configs (like enable to keep cache consistency)