use of com.baidu.hugegraph.config.HugeConfig in project incubator-hugegraph by apache.
the class HbaseSessions method open.
@Override
public synchronized void open() throws IOException {
HugeConfig config = this.config();
String hosts = config.get(HbaseOptions.HBASE_HOSTS);
int port = config.get(HbaseOptions.HBASE_PORT);
String znodeParent = config.get(HbaseOptions.HBASE_ZNODE_PARENT);
boolean isEnableKerberos = config.get(HbaseOptions.HBASE_KERBEROS_ENABLE);
Configuration hConfig = HBaseConfiguration.create();
hConfig.set(HConstants.ZOOKEEPER_QUORUM, hosts);
hConfig.set(HConstants.ZOOKEEPER_CLIENT_PORT, String.valueOf(port));
hConfig.set(HConstants.ZOOKEEPER_ZNODE_PARENT, znodeParent);
hConfig.setInt("zookeeper.recovery.retry", config.get(HbaseOptions.HBASE_ZK_RETRY));
// Set hbase.hconnection.threads.max 64 to avoid OOM(default value: 256)
hConfig.setInt("hbase.hconnection.threads.max", config.get(HbaseOptions.HBASE_THREADS_MAX));
String hbaseSite = config.get(HbaseOptions.HBASE_HBASE_SITE);
hConfig.addResource(new Path(hbaseSite));
if (isEnableKerberos) {
String krb5Conf = config.get(HbaseOptions.HBASE_KRB5_CONF);
System.setProperty("java.security.krb5.conf", krb5Conf);
String principal = config.get(HbaseOptions.HBASE_KERBEROS_PRINCIPAL);
String keyTab = config.get(HbaseOptions.HBASE_KERBEROS_KEYTAB);
hConfig.set("hadoop.security.authentication", "kerberos");
hConfig.set("hbase.security.authentication", "kerberos");
// login/authenticate using keytab
UserGroupInformation.setConfiguration(hConfig);
UserGroupInformation.loginUserFromKeytab(principal, keyTab);
}
this.hbase = ConnectionFactory.createConnection(hConfig);
}
use of com.baidu.hugegraph.config.HugeConfig in project incubator-hugegraph by apache.
the class RegisterUtil method registerBackends.
public static void registerBackends() {
String confFile = "/backend.properties";
URL input = RegisterUtil.class.getResource(confFile);
E.checkState(input != null, "Can't read file '%s' as stream", confFile);
PropertiesConfiguration props = null;
try {
props = new Configurations().properties(input);
} catch (ConfigurationException e) {
throw new HugeException("Can't load config file: %s", e, confFile);
}
HugeConfig config = new HugeConfig(props);
List<String> backends = config.get(DistOptions.BACKENDS);
for (String backend : backends) {
registerBackend(backend);
}
}
use of com.baidu.hugegraph.config.HugeConfig in project incubator-hugegraph by apache.
the class BinaryScatterSerializerTest method testVertex.
@Test
public void testVertex() {
HugeConfig config = FakeObjects.newConfig();
BinaryScatterSerializer ser = new BinaryScatterSerializer(config);
HugeEdge edge = new FakeObjects().newEdge(123, 456);
BackendEntry entry1 = ser.writeVertex(edge.sourceVertex());
HugeVertex vertex1 = ser.readVertex(edge.graph(), entry1);
Assert.assertEquals(edge.sourceVertex(), vertex1);
assertCollectionEquals(edge.sourceVertex().getProperties(), vertex1.getProperties());
BackendEntry entry2 = ser.writeVertex(edge.targetVertex());
HugeVertex vertex2 = ser.readVertex(edge.graph(), entry2);
Assert.assertEquals(edge.targetVertex(), vertex2);
assertCollectionEquals(edge.targetVertex().getProperties(), vertex2.getProperties());
Whitebox.setInternalState(vertex2, "removed", true);
Assert.assertTrue(vertex2.removed());
BackendEntry entry3 = ser.writeVertex(vertex2);
Assert.assertEquals(0, entry3.columnsSize());
Assert.assertNull(ser.readVertex(edge.graph(), null));
}
use of com.baidu.hugegraph.config.HugeConfig in project incubator-hugegraph by apache.
the class SerializerFactoryTest method testSerializer.
@Test
public void testSerializer() {
HugeConfig config = FakeObjects.newConfig();
AbstractSerializer serializer = SerializerFactory.serializer(config, "text");
Assert.assertEquals(TextSerializer.class, serializer.getClass());
serializer = SerializerFactory.serializer(config, "binary");
Assert.assertEquals(BinarySerializer.class, serializer.getClass());
serializer = SerializerFactory.serializer(config, "binaryscatter");
Assert.assertEquals(BinaryScatterSerializer.class, serializer.getClass());
Assert.assertThrows(BackendException.class, () -> {
SerializerFactory.serializer(config, "invalid");
}, e -> {
Assert.assertContains("Not exists serializer:", e.getMessage());
});
}
use of com.baidu.hugegraph.config.HugeConfig in project hugegraph-computer by hugegraph.
the class ComputerOptionsTest method testOptions.
@Test
public void testOptions() {
MapConfiguration mapConfig = new MapConfiguration(options);
HugeConfig config = new HugeConfig(mapConfig);
Map<String, TypedOption<?, ?>> allOptions = ComputerOptions.instance().options();
Collection<TypedOption<?, ?>> typedOptions = allOptions.values();
for (TypedOption<?, ?> typedOption : typedOptions) {
Object value = config.get(typedOption);
String key = typedOption.name();
if (options.containsKey(key)) {
Assert.assertEquals(String.valueOf(value), options.get(key));
} else {
Assert.assertNull(value);
}
}
}
Aggregations