Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implements serializable #469

Merged
merged 2 commits into from
Aug 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<HostAddress> addresses;
protected final int connectionRetry;
protected final int executionRetry;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<String, TagItem> tagItems = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -14,7 +15,7 @@

@SuppressWarnings("checkstyle:Indentation")
public class StorageConnPoolFactory
implements KeyedPooledObjectFactory<HostAddress, GraphStorageConnection> {
implements KeyedPooledObjectFactory<HostAddress, GraphStorageConnection>, Serializable {
private static final Logger LOGGER = LoggerFactory.getLogger(StorageConnPoolFactory.class);

private final StoragePoolConfig config;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ValueWrapper> values;
protected String decodeType = "utf-8";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, ValueWrapper> props;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
}
}
}