Skip to content

Commit

Permalink
sync the lastest java client (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicole00 authored Dec 30, 2021
1 parent e9ea2e2 commit 0643db2
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.vesoft.nebula.client.graph.data.HostAddress;
import com.vesoft.nebula.client.graph.exception.ClientServerIncompatibleException;
import com.vesoft.nebula.client.meta.MetaClient;
import java.net.UnknownHostException;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
Expand Down Expand Up @@ -57,7 +58,12 @@ public AbstractNebulaCatalog(String catalogName, String defaultDatabase, String
public void open() throws CatalogException {
// test metaClient connection
List<HostAddress> hostAndPorts = NebulaUtils.getHostAndPorts(address);
MetaClient metaClient = new MetaClient(hostAndPorts);
MetaClient metaClient = null;
try {
metaClient = new MetaClient(hostAndPorts);
} catch (UnknownHostException e) {
throw new IllegalArgumentException("address is illegal, ", e);
}
try {
metaClient.connect();
metaClient.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.vesoft.nebula.meta.IdName;
import com.vesoft.nebula.meta.Schema;
import com.vesoft.nebula.meta.TagItem;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
Expand Down Expand Up @@ -53,7 +54,7 @@ public class NebulaCatalog extends AbstractNebulaCatalog {
private final MetaClient metaClient;

public NebulaCatalog(String catalogName, String defaultDatabase, String username, String pwd,
String address) {
String address) throws UnknownHostException {
super(catalogName, defaultDatabase, username, pwd, address);
this.hostAndPorts = NebulaUtils.getHostAndPorts(address);
this.metaClient = new MetaClient(hostAndPorts);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import static org.apache.flink.table.descriptors.CatalogDescriptorValidator.CATALOG_PROPERTY_VERSION;
import static org.apache.flink.table.descriptors.CatalogDescriptorValidator.CATALOG_TYPE;

import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
Expand All @@ -31,12 +32,16 @@ public class NebulaCatalogFactory implements CatalogFactory {
@Override
public Catalog createCatalog(String name, Map<String, String> properties) {
final DescriptorProperties prop = getValidatedProperties(properties);
return new NebulaCatalog(
name,
prop.getString(CATALOG_DEFAULT_DATABASE),
prop.getString(CATALOG_NEBULA_USERNAME),
prop.getString(CATALOG_NEBULA_PASSWORD),
prop.getString(CATALOG_NEBULA_ADDRESS));
try {
return new NebulaCatalog(
name,
prop.getString(CATALOG_DEFAULT_DATABASE),
prop.getString(CATALOG_NEBULA_USERNAME),
prop.getString(CATALOG_NEBULA_PASSWORD),
prop.getString(CATALOG_NEBULA_ADDRESS));
} catch (UnknownHostException e) {
throw new IllegalArgumentException("address is illegal,", e);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import com.vesoft.nebula.meta.Schema;
import com.vesoft.nebula.meta.SpaceItem;
import java.io.Serializable;
import java.net.UnknownHostException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand All @@ -35,7 +36,8 @@ public NebulaMetaConnectionProvider(NebulaClientOptions nebulaClientOptions) {
this.nebulaClientOptions = nebulaClientOptions;
}

public MetaClient getMetaClient() throws TException, ClientServerIncompatibleException {
public MetaClient getMetaClient() throws TException, ClientServerIncompatibleException,
UnknownHostException {
List<HostAddress> addresses = nebulaClientOptions.getMetaAddress();
int timeout = nebulaClientOptions.getTimeout();
int retry = nebulaClientOptions.getConnectRetry();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ public Row convert(BaseTableRow row) throws UnsupportedEncodingException {
record.setField(pos, valueWrapper.asGeography());
continue;
}
if (valueWrapper.isDuration()) {
record.setField(pos, valueWrapper.asDuration());
}
}
return record;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

package org.apache.flink.connector.nebula.utils;

import java.net.UnknownHostException;
import org.apache.flink.connector.nebula.catalog.NebulaCatalog;

/**
Expand All @@ -17,7 +18,7 @@ public class NebulaCatalogUtils {
*/
public static NebulaCatalog createNebulaCatalog(String catalogName, String defaultSpace,
String address, String username,
String password) {
String password) throws UnknownHostException {
return new NebulaCatalog(catalogName, defaultSpace, username, password, address);
}
}

0 comments on commit 0643db2

Please sign in to comment.