diff --git a/client/src/main/generated/com/vesoft/nebula/graph/GraphService.java b/client/src/main/generated/com/vesoft/nebula/graph/GraphService.java index 326abd953..5df20749b 100644 --- a/client/src/main/generated/com/vesoft/nebula/graph/GraphService.java +++ b/client/src/main/generated/com/vesoft/nebula/graph/GraphService.java @@ -6,6 +6,7 @@ */ package com.vesoft.nebula.graph; +import java.io.Serializable; import java.util.List; import java.util.ArrayList; import java.util.Map; @@ -65,7 +66,7 @@ public interface AsyncIface { } - public static class Client extends EventHandlerBase implements Iface, TClientIf { + public static class Client extends EventHandlerBase implements Iface, TClientIf, Serializable { public Client(TProtocol prot) { this(prot, prot); diff --git a/client/src/main/java/com/vesoft/nebula/client/meta/AbstractMetaClient.java b/client/src/main/java/com/vesoft/nebula/client/meta/AbstractMetaClient.java index ef946cbe3..7dc8a5d4d 100644 --- a/client/src/main/java/com/vesoft/nebula/client/meta/AbstractMetaClient.java +++ b/client/src/main/java/com/vesoft/nebula/client/meta/AbstractMetaClient.java @@ -11,11 +11,12 @@ import com.google.common.net.InetAddresses; import com.google.common.net.InternetDomainName; import com.vesoft.nebula.client.graph.data.HostAddress; +import java.io.Serializable; import java.net.InetAddress; import java.net.UnknownHostException; import java.util.List; -public class AbstractMetaClient { +public class AbstractMetaClient implements Serializable { protected final List addresses; protected final int connectionRetry; protected final int executionRetry; diff --git a/client/src/main/java/com/vesoft/nebula/client/meta/MetaClient.java b/client/src/main/java/com/vesoft/nebula/client/meta/MetaClient.java index 78ddf9792..13682157a 100644 --- a/client/src/main/java/com/vesoft/nebula/client/meta/MetaClient.java +++ b/client/src/main/java/com/vesoft/nebula/client/meta/MetaClient.java @@ -48,6 +48,7 @@ import com.vesoft.nebula.meta.VerifyClientVersionResp; import com.vesoft.nebula.util.SslUtil; import java.io.IOException; +import java.io.Serializable; import java.net.UnknownHostException; import java.util.Arrays; import java.util.HashSet; diff --git a/client/src/main/java/com/vesoft/nebula/client/meta/MetaManager.java b/client/src/main/java/com/vesoft/nebula/client/meta/MetaManager.java index 1c23ebb7b..4b3294a25 100644 --- a/client/src/main/java/com/vesoft/nebula/client/meta/MetaManager.java +++ b/client/src/main/java/com/vesoft/nebula/client/meta/MetaManager.java @@ -16,6 +16,7 @@ import com.vesoft.nebula.meta.IdName; import com.vesoft.nebula.meta.SpaceItem; import com.vesoft.nebula.meta.TagItem; +import java.io.Serializable; import java.net.UnknownHostException; import java.util.ArrayList; import java.util.HashMap; @@ -30,7 +31,7 @@ /** * MetaManager is a manager for meta info, such as spaces,tags and edges. */ -public class MetaManager implements MetaCache { +public class MetaManager implements MetaCache, Serializable { private class SpaceInfo { private SpaceItem spaceItem = null; private Map tagItems = new HashMap<>(); diff --git a/client/src/main/java/com/vesoft/nebula/client/storage/StorageClient.java b/client/src/main/java/com/vesoft/nebula/client/storage/StorageClient.java index 0f8be86c6..42fe38c56 100644 --- a/client/src/main/java/com/vesoft/nebula/client/storage/StorageClient.java +++ b/client/src/main/java/com/vesoft/nebula/client/storage/StorageClient.java @@ -18,6 +18,7 @@ import com.vesoft.nebula.storage.ScanEdgeRequest; import com.vesoft.nebula.storage.ScanVertexRequest; import com.vesoft.nebula.storage.VertexProp; +import java.io.Serializable; import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; @@ -26,7 +27,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class StorageClient { +public class StorageClient implements Serializable { private static final Logger LOGGER = LoggerFactory.getLogger(StorageClient.class); private final GraphStorageConnection connection; diff --git a/client/src/main/java/com/vesoft/nebula/client/storage/StorageConnPoolFactory.java b/client/src/main/java/com/vesoft/nebula/client/storage/StorageConnPoolFactory.java index 7bb1515ad..2136c2916 100644 --- a/client/src/main/java/com/vesoft/nebula/client/storage/StorageConnPoolFactory.java +++ b/client/src/main/java/com/vesoft/nebula/client/storage/StorageConnPoolFactory.java @@ -6,6 +6,7 @@ package com.vesoft.nebula.client.storage; import com.vesoft.nebula.client.graph.data.HostAddress; +import java.io.Serializable; import org.apache.commons.pool2.KeyedPooledObjectFactory; import org.apache.commons.pool2.PooledObject; import org.apache.commons.pool2.impl.DefaultPooledObject; @@ -14,7 +15,7 @@ @SuppressWarnings("checkstyle:Indentation") public class StorageConnPoolFactory - implements KeyedPooledObjectFactory { + implements KeyedPooledObjectFactory, Serializable { private static final Logger LOGGER = LoggerFactory.getLogger(StorageConnPoolFactory.class); private final StoragePoolConfig config; diff --git a/client/src/main/java/com/vesoft/nebula/client/storage/data/BaseTableRow.java b/client/src/main/java/com/vesoft/nebula/client/storage/data/BaseTableRow.java index 1a2951a19..3068cd87b 100644 --- a/client/src/main/java/com/vesoft/nebula/client/storage/data/BaseTableRow.java +++ b/client/src/main/java/com/vesoft/nebula/client/storage/data/BaseTableRow.java @@ -11,10 +11,11 @@ import com.vesoft.nebula.client.graph.data.GeographyWrapper; import com.vesoft.nebula.client.graph.data.TimeWrapper; import com.vesoft.nebula.client.graph.data.ValueWrapper; +import java.io.Serializable; import java.io.UnsupportedEncodingException; import java.util.List; -public class BaseTableRow { +public class BaseTableRow implements Serializable { protected final List values; protected String decodeType = "utf-8"; diff --git a/client/src/main/java/com/vesoft/nebula/client/storage/data/EdgeRow.java b/client/src/main/java/com/vesoft/nebula/client/storage/data/EdgeRow.java index f934cb50a..b30119455 100644 --- a/client/src/main/java/com/vesoft/nebula/client/storage/data/EdgeRow.java +++ b/client/src/main/java/com/vesoft/nebula/client/storage/data/EdgeRow.java @@ -6,9 +6,10 @@ package com.vesoft.nebula.client.storage.data; import com.vesoft.nebula.client.graph.data.ValueWrapper; +import java.io.Serializable; import java.util.Map; -public class EdgeRow { +public class EdgeRow implements Serializable { private final ValueWrapper srcId; private final ValueWrapper dstId; private final long rank; diff --git a/client/src/main/java/com/vesoft/nebula/client/storage/data/VertexRow.java b/client/src/main/java/com/vesoft/nebula/client/storage/data/VertexRow.java index 28e04c6eb..fb65cbc23 100644 --- a/client/src/main/java/com/vesoft/nebula/client/storage/data/VertexRow.java +++ b/client/src/main/java/com/vesoft/nebula/client/storage/data/VertexRow.java @@ -6,9 +6,10 @@ package com.vesoft.nebula.client.storage.data; import com.vesoft.nebula.client.graph.data.ValueWrapper; +import java.io.Serializable; import java.util.Map; -public class VertexRow { +public class VertexRow implements Serializable { private final ValueWrapper vid; private final Map props; diff --git a/client/src/main/java/com/vesoft/nebula/client/storage/scan/ScanResultIterator.java b/client/src/main/java/com/vesoft/nebula/client/storage/scan/ScanResultIterator.java index 28dda0019..b826a8760 100644 --- a/client/src/main/java/com/vesoft/nebula/client/storage/scan/ScanResultIterator.java +++ b/client/src/main/java/com/vesoft/nebula/client/storage/scan/ScanResultIterator.java @@ -13,6 +13,7 @@ import com.vesoft.nebula.client.storage.StorageConnPool; import com.vesoft.nebula.storage.PartitionResult; import com.vesoft.nebula.storage.ScanResponse; +import java.io.Serializable; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -22,7 +23,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class ScanResultIterator { +public class ScanResultIterator implements Serializable { private static final Logger LOGGER = LoggerFactory.getLogger(ScanResultIterator.class); protected boolean hasNext = true; diff --git a/client/src/test/java/com/vesoft/nebula/client/graph/net/TestGraphServiceClient.java b/client/src/test/java/com/vesoft/nebula/client/graph/net/TestGraphServiceClient.java new file mode 100644 index 000000000..96b2ddbed --- /dev/null +++ b/client/src/test/java/com/vesoft/nebula/client/graph/net/TestGraphServiceClient.java @@ -0,0 +1,32 @@ +/* Copyright (c) 2022 vesoft inc. All rights reserved. + * + * This source code is licensed under Apache 2.0 License. + */ + +package com.vesoft.nebula.client.graph.net; + +import com.facebook.thrift.protocol.TCompactProtocol; +import com.facebook.thrift.protocol.TProtocol; +import com.facebook.thrift.transport.TSocket; +import com.facebook.thrift.transport.TTransport; +import com.vesoft.nebula.graph.GraphService; +import java.io.Serializable; +import org.junit.Assert; +import org.junit.Test; + + +public class TestGraphServiceClient { + @Test + public void testClientSerialize() { + + TTransport transport = new TSocket("127.0.0.1", 9669, 10000, 10000); + TProtocol protocol = new TCompactProtocol(transport); + GraphService.Client client = new GraphService.Client(protocol); + + if (!(client instanceof Serializable)) { + System.out.println("GraphService.Client is not serialized."); + Assert.assertFalse("GraphService.Client is not serialized, " + + "please modify the thrift file manually", false); + } + } +}