Skip to content

Commit aaec4da

Browse files
Tsukilcimbajin
authored andcommitted
fix(struct): Fix the classpath conflict between struct and server (#65)
* fix(server): add META in HugeType * fix(server): Add enumerations to the struct * fix(struct): remove hugegraph-struct/schema to hugegraph-struct/struct/schema * fix(struct): Change the loading order of classes * fix(struct): Change the loading order of classes
1 parent 3b5554e commit aaec4da

29 files changed

Lines changed: 177 additions & 159 deletions

File tree

hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/type/HugeType.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,8 @@ public boolean isGraph() {
121121
}
122122

123123
public boolean isVertex() {
124-
return this == HugeType.VERTEX || this == HugeType.TASK || this == HugeType.SERVER;
124+
return this == HugeType.VERTEX || this == HugeType.TASK || this == HugeType.SERVER ||
125+
this == HugeType.VARIABLE;
125126
}
126127

127128
public boolean isEdge() {
@@ -132,7 +133,6 @@ public boolean isEdgeLabel() {
132133
return this == EDGE_LABEL;
133134
}
134135

135-
136136
public boolean isIndex() {
137137
return this == VERTEX_LABEL_INDEX || this == EDGE_LABEL_INDEX ||
138138
this == SECONDARY_INDEX || this == SEARCH_INDEX ||

hugegraph-server/hugegraph-dist/src/assembly/static/bin/init-store.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@ fi
5454

5555
echo "Initializing HugeGraph Store..."
5656

57-
CP=$(find "${LIB}" "${PLUGINS}" -name "*.jar" | tr "\n" ":")
57+
# Build classpath with hugegraph*.jar first to avoid class loading conflicts
58+
CP=$(find -L "${LIB}" -name 'hugegraph*.jar' | sort | tr '\n' ':')
59+
CP="$CP":$(find -L "${LIB}" -name '*.jar' \! -name 'hugegraph*' | sort | tr '\n' ':')
60+
CP="$CP":$(find -L "${PLUGINS}" -name '*.jar' | sort | tr '\n' ':')
5861
$JAVA -cp $CP ${DEFAULT_JAVA_OPTIONS} \
5962
org.apache.hugegraph.cmd.InitStore "${CONF}"/rest-server.properties
6063

hugegraph-store/hg-store-core/src/main/java/org/apache/hugegraph/store/business/DataManagerImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
import org.apache.hugegraph.pd.grpc.pulse.CleanType;
3939
import org.apache.hugegraph.rocksdb.access.RocksDBSession;
4040
import org.apache.hugegraph.rocksdb.access.ScanIterator;
41-
import org.apache.hugegraph.schema.IndexLabel;
4241
import org.apache.hugegraph.serializer.BinaryElementSerializer;
4342
import org.apache.hugegraph.store.HgStoreEngine;
4443
import org.apache.hugegraph.store.cmd.HgCmdClient;
@@ -51,6 +50,7 @@
5150
import org.apache.hugegraph.store.raft.RaftClosure;
5251
import org.apache.hugegraph.store.raft.RaftOperation;
5352
import org.apache.hugegraph.store.term.Bits;
53+
import org.apache.hugegraph.struct.schema.IndexLabel;
5454
import org.apache.hugegraph.structure.BaseEdge;
5555
import org.apache.hugegraph.structure.BaseElement;
5656
import org.apache.hugegraph.structure.BaseVertex;

hugegraph-store/hg-store-core/src/main/java/org/apache/hugegraph/store/business/GraphStoreIterator.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,6 @@
3434
import org.apache.hugegraph.id.Id;
3535
import org.apache.hugegraph.rocksdb.access.RocksDBSession;
3636
import org.apache.hugegraph.rocksdb.access.ScanIterator;
37-
import org.apache.hugegraph.schema.EdgeLabel;
38-
import org.apache.hugegraph.schema.PropertyKey;
39-
import org.apache.hugegraph.schema.VertexLabel;
4037
import org.apache.hugegraph.store.grpc.Graphpb;
4138
import org.apache.hugegraph.store.grpc.Graphpb.Edge;
4239
import org.apache.hugegraph.store.grpc.Graphpb.ScanPartitionRequest;
@@ -45,6 +42,9 @@
4542
import org.apache.hugegraph.store.grpc.Graphpb.Variant.Builder;
4643
import org.apache.hugegraph.store.grpc.Graphpb.VariantType;
4744
import org.apache.hugegraph.store.grpc.Graphpb.Vertex;
45+
import org.apache.hugegraph.struct.schema.EdgeLabel;
46+
import org.apache.hugegraph.struct.schema.PropertyKey;
47+
import org.apache.hugegraph.struct.schema.VertexLabel;
4848
import org.apache.hugegraph.structure.BaseEdge;
4949
import org.apache.hugegraph.structure.BaseElement;
5050
import org.apache.hugegraph.structure.BaseProperty;

hugegraph-store/hg-store-core/src/main/java/org/apache/hugegraph/store/meta/GraphIdManager.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@
4141
public class GraphIdManager extends PartitionMetaStore {
4242

4343
protected static final String GRAPH_ID_PREFIX = "@GRAPH_ID@";
44-
protected static int maxGraphID = 65535;
44+
// FIXME: we need to ensure the right num & proper logic for it (IMPORTANT)
45+
protected static int maxGraphID = 65535 - 1;
4546
static Object graphIdLock = new Object();
4647
static Object cidLock = new Object();
4748
final DBSessionBuilder sessionBuilder;

hugegraph-struct/src/main/java/org/apache/hugegraph/HugeGraphSupplier.java

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -23,55 +23,54 @@
2323
import java.util.List;
2424

2525
import org.apache.hugegraph.config.HugeConfig;
26-
import org.apache.hugegraph.util.DateUtil;
27-
2826
import org.apache.hugegraph.id.Id;
29-
import org.apache.hugegraph.schema.EdgeLabel;
30-
import org.apache.hugegraph.schema.IndexLabel;
31-
import org.apache.hugegraph.schema.PropertyKey;
32-
import org.apache.hugegraph.schema.VertexLabel;
27+
import org.apache.hugegraph.struct.schema.EdgeLabel;
28+
import org.apache.hugegraph.struct.schema.IndexLabel;
29+
import org.apache.hugegraph.struct.schema.PropertyKey;
30+
import org.apache.hugegraph.struct.schema.VertexLabel;
31+
import org.apache.hugegraph.util.DateUtil;
3332

3433
/**
35-
* Acturally, it would be better if this interface be called
34+
* Actually, it would be better if this interface be called
3635
* "HugeGraphSchemaSupplier".
3736
*/
3837
public interface HugeGraphSupplier {
3938

40-
public List<String> mapPkId2Name(Collection<Id> ids);
39+
List<String> mapPkId2Name(Collection<Id> ids);
4140

42-
public List<String> mapIlId2Name(Collection<Id> ids);
41+
List<String> mapIlId2Name(Collection<Id> ids);
4342

44-
public PropertyKey propertyKey(Id key);
43+
PropertyKey propertyKey(Id key);
4544

46-
public Collection<PropertyKey> propertyKeys();
45+
Collection<PropertyKey> propertyKeys();
4746

48-
public VertexLabel vertexLabelOrNone(Id id);
47+
VertexLabel vertexLabelOrNone(Id id);
4948

50-
public boolean existsLinkLabel(Id vertexLabel);
49+
boolean existsLinkLabel(Id vertexLabel);
5150

52-
public VertexLabel vertexLabel(Id label);
51+
VertexLabel vertexLabel(Id label);
5352

54-
public VertexLabel vertexLabel(String label);
53+
VertexLabel vertexLabel(String label);
5554

5655

57-
public default EdgeLabel edgeLabelOrNone(Id id) {
56+
default EdgeLabel edgeLabelOrNone(Id id) {
5857
EdgeLabel el = this.edgeLabel(id);
5958
if (el == null) {
6059
el = EdgeLabel.undefined(this, id);
6160
}
6261
return el;
6362
}
64-
public EdgeLabel edgeLabel(Id label);
63+
EdgeLabel edgeLabel(Id label);
6564

66-
public EdgeLabel edgeLabel(String label);
65+
EdgeLabel edgeLabel(String label);
6766

68-
public IndexLabel indexLabel(Id id);
67+
IndexLabel indexLabel(Id id);
6968

70-
public Collection<IndexLabel> indexLabels();
69+
Collection<IndexLabel> indexLabels();
7170

72-
public String name();
71+
String name();
7372

74-
public HugeConfig configuration();
73+
HugeConfig configuration();
7574

7675
default long now() {
7776
return DateUtil.now().getTime();

hugegraph-struct/src/main/java/org/apache/hugegraph/SchemaDriver.java

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,6 @@
3030
import java.util.concurrent.atomic.AtomicReference;
3131
import java.util.function.Consumer;
3232

33-
import org.apache.hugegraph.util.E;
34-
import org.apache.hugegraph.util.Log;
35-
import org.apache.tinkerpop.shaded.jackson.core.JsonProcessingException;
36-
import org.apache.tinkerpop.shaded.jackson.databind.ObjectMapper;
37-
import org.slf4j.Logger;
38-
3933
import org.apache.hugegraph.exception.HugeException;
4034
import org.apache.hugegraph.exception.NotAllowException;
4135
import org.apache.hugegraph.id.Id;
@@ -47,15 +41,20 @@
4741
import org.apache.hugegraph.pd.grpc.kv.WatchEvent;
4842
import org.apache.hugegraph.pd.grpc.kv.WatchResponse;
4943
import org.apache.hugegraph.pd.grpc.kv.WatchType;
50-
import org.apache.hugegraph.schema.EdgeLabel;
51-
import org.apache.hugegraph.schema.IndexLabel;
52-
import org.apache.hugegraph.schema.PropertyKey;
53-
import org.apache.hugegraph.schema.SchemaElement;
54-
import org.apache.hugegraph.schema.VertexLabel;
44+
import org.apache.hugegraph.struct.schema.EdgeLabel;
45+
import org.apache.hugegraph.struct.schema.IndexLabel;
46+
import org.apache.hugegraph.struct.schema.PropertyKey;
47+
import org.apache.hugegraph.struct.schema.SchemaElement;
48+
import org.apache.hugegraph.struct.schema.VertexLabel;
5549
import org.apache.hugegraph.type.HugeType;
50+
import org.apache.hugegraph.util.E;
51+
import org.apache.hugegraph.util.Log;
52+
import org.apache.tinkerpop.shaded.jackson.core.JsonProcessingException;
53+
import org.apache.tinkerpop.shaded.jackson.databind.ObjectMapper;
54+
import org.slf4j.Logger;
5655

5756
public class SchemaDriver {
58-
private static Logger log = Log.logger(SchemaDriver.class);
57+
private static final Logger log = Log.logger(SchemaDriver.class);
5958
private static final ObjectMapper MAPPER = new ObjectMapper();
6059

6160
public static final String DELIMITER = "-";
@@ -81,7 +80,7 @@ public class SchemaDriver {
8180
// Client for accessing PD
8281
private final KvClient<WatchResponse> client;
8382

84-
private SchemaCaches caches;
83+
private final SchemaCaches caches;
8584

8685
private SchemaDriver(PDConfig pdConfig, int cacheSize,
8786
long expiration) {
@@ -731,7 +730,7 @@ private static final class SchemaCaches {
731730
private final long expiration;
732731
private final Timer timer;
733732

734-
private ConcurrentHashMap<String, ConcurrentHashMap<String,
733+
private final ConcurrentHashMap<String, ConcurrentHashMap<String,
735734
SchemaElement>> caches;
736735

737736
public SchemaCaches(int limit, long expiration) {

hugegraph-struct/src/main/java/org/apache/hugegraph/SchemaGraph.java

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,28 +19,29 @@
1919

2020
package org.apache.hugegraph;
2121

22-
import org.apache.hugegraph.HugeGraphSupplier;
23-
import org.apache.hugegraph.SchemaDriver;
24-
import org.apache.hugegraph.id.Id;
25-
import org.apache.hugegraph.pd.client.PDConfig;
26-
import org.apache.hugegraph.schema.*;
22+
import java.util.ArrayList;
23+
import java.util.Collection;
24+
import java.util.List;
25+
import java.util.Map;
2726

2827
import org.apache.commons.configuration2.Configuration;
2928
import org.apache.commons.configuration2.MapConfiguration;
3029
import org.apache.hugegraph.config.HugeConfig;
30+
import org.apache.hugegraph.id.Id;
31+
import org.apache.hugegraph.pd.client.PDConfig;
32+
import org.apache.hugegraph.struct.schema.EdgeLabel;
33+
import org.apache.hugegraph.struct.schema.IndexLabel;
34+
import org.apache.hugegraph.struct.schema.PropertyKey;
35+
import org.apache.hugegraph.struct.schema.SchemaElement;
36+
import org.apache.hugegraph.struct.schema.VertexLabel;
3137
import org.apache.hugegraph.util.E;
3238

33-
import java.util.ArrayList;
34-
import java.util.Collection;
35-
import java.util.List;
36-
import java.util.Map;
37-
3839
public class SchemaGraph implements HugeGraphSupplier {
3940

4041
private final String graphSpace;
4142
private final String graph;
4243
private final PDConfig pdConfig;
43-
private HugeConfig config;
44+
private final HugeConfig config;
4445

4546
private final SchemaDriver schemaDriver;
4647

hugegraph-struct/src/main/java/org/apache/hugegraph/query/MatchedIndex.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
import java.util.Set;
2525
import java.util.stream.Collectors;
2626

27-
import org.apache.hugegraph.schema.IndexLabel;
28-
import org.apache.hugegraph.schema.SchemaLabel;
27+
import org.apache.hugegraph.struct.schema.IndexLabel;
28+
import org.apache.hugegraph.struct.schema.SchemaLabel;
2929

3030
public class MatchedIndex {
3131

hugegraph-struct/src/main/java/org/apache/hugegraph/serializer/BinaryElementSerializer.java

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,13 @@
1919

2020
package org.apache.hugegraph.serializer;
2121

22-
import com.google.common.primitives.Longs;
22+
import static org.apache.hugegraph.struct.schema.SchemaElement.UNDEF;
23+
24+
import java.util.Arrays;
25+
import java.util.Base64;
26+
import java.util.Collection;
27+
import java.util.Map;
28+
2329
import org.apache.commons.lang.ArrayUtils;
2430
import org.apache.commons.lang.NotImplementedException;
2531
import org.apache.hugegraph.HugeGraphSupplier;
@@ -29,11 +35,15 @@
2935
import org.apache.hugegraph.id.EdgeId;
3036
import org.apache.hugegraph.id.Id;
3137
import org.apache.hugegraph.id.IdGenerator;
32-
import org.apache.hugegraph.schema.EdgeLabel;
33-
import org.apache.hugegraph.schema.PropertyKey;
34-
import org.apache.hugegraph.schema.SchemaElement;
35-
import org.apache.hugegraph.schema.VertexLabel;
36-
import org.apache.hugegraph.structure.*;
38+
import org.apache.hugegraph.struct.schema.EdgeLabel;
39+
import org.apache.hugegraph.struct.schema.PropertyKey;
40+
import org.apache.hugegraph.struct.schema.SchemaElement;
41+
import org.apache.hugegraph.struct.schema.VertexLabel;
42+
import org.apache.hugegraph.structure.BaseEdge;
43+
import org.apache.hugegraph.structure.BaseElement;
44+
import org.apache.hugegraph.structure.BaseProperty;
45+
import org.apache.hugegraph.structure.BaseVertex;
46+
import org.apache.hugegraph.structure.Index;
3747
import org.apache.hugegraph.type.HugeType;
3848
import org.apache.hugegraph.type.define.Cardinality;
3949
import org.apache.hugegraph.type.define.EdgeLabelType;
@@ -43,12 +53,7 @@
4353
import org.apache.hugegraph.util.StringEncoding;
4454
import org.slf4j.Logger;
4555

46-
import java.util.Arrays;
47-
import java.util.Base64;
48-
import java.util.Collection;
49-
import java.util.Map;
50-
51-
import static org.apache.hugegraph.schema.SchemaElement.UNDEF;
56+
import com.google.common.primitives.Longs;
5257

5358
public class BinaryElementSerializer {
5459
static final BinaryElementSerializer INSTANCE =

0 commit comments

Comments
 (0)