Skip to content
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
18 changes: 9 additions & 9 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/.classpath
/.project
/.settings
**/target
/.idea
/*.iml
/bin
.classpath
.project
.settings
target
.idea
*.iml
.directory

/docker/jwtHeader
/docker/jwtSecret

/docker/data
**/test-results-native

test-results-native
.flattened-pom.xml
30 changes: 10 additions & 20 deletions driver/src/main/java/com/arangodb/ArangoDB.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

package com.arangodb;

import com.arangodb.config.ConfigPropertiesProvider;
import com.arangodb.config.ConfigPropertyKey;
import com.arangodb.entity.*;
import com.arangodb.internal.ArangoDBImpl;
import com.arangodb.internal.ArangoDefaults;
Expand All @@ -39,10 +41,8 @@

import javax.annotation.concurrent.ThreadSafe;
import javax.net.ssl.SSLContext;
import java.io.InputStream;
import java.util.Collection;
import java.util.Locale;
import java.util.Properties;

/**
* Central access point for applications to communicate with an ArangoDB server.
Expand Down Expand Up @@ -333,38 +333,28 @@ public interface ArangoDB extends ArangoSerdeAccessor {
* @author Mark Vollmary
*/
class Builder extends InternalArangoDBBuilder {
private static final String PROPERTY_KEY_PROTOCOL = "arangodb.protocol";

protected Protocol protocol;
protected Protocol protocol = ArangoDefaults.DEFAULT_NETWORK_PROTOCOL;

public Builder() {
super();
}

private static Protocol loadProtocol(final Properties properties, final Protocol currentValue) {
return Protocol.valueOf(
getProperty(properties, PROPERTY_KEY_PROTOCOL, currentValue,
ArangoDefaults.DEFAULT_NETWORK_PROTOCOL)
.toUpperCase(Locale.ROOT));
private static Protocol loadProtocol(final ConfigPropertiesProvider properties, final Protocol currentValue) {
return Protocol.valueOf(getProperty(properties, ConfigPropertyKey.PROTOCOL, currentValue).toUpperCase(Locale.ROOT));
}

@Override
protected void loadProperties(final Properties properties) {
super.loadProperties(properties);
public Builder loadProperties(final ConfigPropertiesProvider properties) {
doLoadProperties(properties);
protocol = loadProtocol(properties, protocol);
return this;
}

public Builder useProtocol(final Protocol protocol) {
this.protocol = protocol;
return this;
}

@Override
public Builder loadProperties(final InputStream in) {
super.loadProperties(in);
return this;
}

/**
* Adds a host to connect to. Multiple hosts can be added to provide fallbacks.
*
Expand Down Expand Up @@ -461,7 +451,7 @@ public Builder verifyHost(final Boolean verifyHost) {
* @return {@link ArangoDB.Builder}
*/
public Builder chunksize(final Integer chunksize) {
setChunksize(chunksize);
setChunkSize(chunksize);
return this;
}

Expand Down Expand Up @@ -617,7 +607,7 @@ public ArangoDB build() {

return new ArangoDBImpl(
new VstCommunicationSync.Builder(hostHandler).timeout(timeout).user(user).password(password)
.jwt(jwt).useSsl(useSsl).sslContext(sslContext).chunksize(chunksize)
.jwt(jwt).useSsl(useSsl).sslContext(sslContext).chunksize(chunkSize)
.maxConnections(maxConnections).connectionTtl(connectionTtl),
new HttpCommunication.Builder().hostHandler(hostHandler),
serde,
Expand Down
13 changes: 6 additions & 7 deletions driver/src/main/java/com/arangodb/async/ArangoDBAsync.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.arangodb.async.internal.ArangoDBAsyncImpl;
import com.arangodb.async.internal.velocystream.VstCommunicationAsync;
import com.arangodb.async.internal.velocystream.VstConnectionFactoryAsync;
import com.arangodb.config.ConfigPropertiesProvider;
import com.arangodb.entity.*;
import com.arangodb.internal.ArangoDefaults;
import com.arangodb.internal.InternalArangoDBBuilder;
Expand All @@ -42,7 +43,6 @@

import javax.annotation.concurrent.ThreadSafe;
import javax.net.ssl.SSLContext;
import java.io.InputStream;
import java.util.Collection;
import java.util.concurrent.CompletableFuture;

Expand Down Expand Up @@ -308,9 +308,8 @@ public Builder() {
super();
}

@Override
public Builder loadProperties(final InputStream in) {
super.loadProperties(in);
public Builder loadProperties(final ConfigPropertiesProvider config) {
super.doLoadProperties(config);
return this;
}

Expand Down Expand Up @@ -399,7 +398,7 @@ public Builder sslContext(final SSLContext sslContext) {
* @return {@link ArangoDBAsync.Builder}
*/
public Builder chunksize(final Integer chunksize) {
setChunksize(chunksize);
setChunkSize(chunksize);
return this;
}

Expand Down Expand Up @@ -535,13 +534,13 @@ public ArangoDBAsync build() {

private VstCommunicationAsync.Builder asyncBuilder(final HostHandler hostHandler) {
return new VstCommunicationAsync.Builder(hostHandler).timeout(timeout).user(user).password(password)
.jwt(jwt).useSsl(useSsl).sslContext(sslContext).chunksize(chunksize).maxConnections(maxConnections)
.jwt(jwt).useSsl(useSsl).sslContext(sslContext).chunksize(chunkSize).maxConnections(maxConnections)
.connectionTtl(connectionTtl);
}

private VstCommunicationSync.Builder syncBuilder(final HostHandler hostHandler) {
return new VstCommunicationSync.Builder(hostHandler).timeout(timeout).user(user).password(password)
.jwt(jwt).useSsl(useSsl).sslContext(sslContext).chunksize(chunksize).maxConnections(maxConnections)
.jwt(jwt).useSsl(useSsl).sslContext(sslContext).chunksize(chunkSize).maxConnections(maxConnections)
.connectionTtl(connectionTtl);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.arangodb.config;


public interface ConfigPropertiesProvider {

/**
* @param key the property key
* @return the configuration property with the specified key if present, {@code null} otherwise
*/
String getProperty(String key);

default String getProperty(ConfigPropertyKey key) {
return getProperty(key.getValue());
}

default String getProperty(String key, String defaultValue) {
String p = getProperty(key);
return p != null ? p : defaultValue;
}

default String getProperty(ConfigPropertyKey key, String defaultValue) {
String p = getProperty(key);
return p != null ? p : defaultValue;
}
}
31 changes: 31 additions & 0 deletions driver/src/main/java/com/arangodb/config/ConfigPropertyKey.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.arangodb.config;

public enum ConfigPropertyKey {
HOSTS("hosts"),
TIMEOUT("timeout"),
USER("user"),
PASSWORD("password"),
JWT("jwt"),
USE_SSL("ssl"),
VERIFY_HOST("verifyHost"),
VST_CHUNK_SIZE("chunkSize"),
MAX_CONNECTIONS("connections.max"),
CONNECTION_TTL("connections.ttl"),
KEEP_ALIVE_INTERVAL("connections.keepAlive.interval"),
ACQUIRE_HOST_LIST("acquireHostList"),
ACQUIRE_HOST_LIST_INTERVAL("acquireHostList.interval"),
LOAD_BALANCING_STRATEGY("loadBalancingStrategy"),
RESPONSE_QUEUE_TIME_SAMPLES("metrics.responseQueueTimeSamples"),
PROTOCOL("protocol");

private final String value;

ConfigPropertyKey(String value) {
this.value = value;
}

public String getValue() {
return value;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public final class ArangoDefaults {
public static final int CHUNK_MAX_HEADER_SIZE = CHUNK_MIN_HEADER_SIZE + LONG_BYTES;
public static final int CHUNK_DEFAULT_CONTENT_SIZE = 30000;
public static final int MAX_CONNECTIONS_VST_DEFAULT = 1;
public static final Integer CONNECTION_TTL_VST_DEFAULT = null;
public static final Long CONNECTION_TTL_VST_DEFAULT = null;
public static final int MAX_CONNECTIONS_HTTP_DEFAULT = 20;
public static final int MAX_CONNECTIONS_HTTP2_DEFAULT = 1;
public static final Protocol DEFAULT_NETWORK_PROTOCOL = Protocol.HTTP2_JSON;
Expand Down
Loading