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

review refactors: apachehttpclient #17

Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ public class AbfsConfiguration{
private int maxApacheHttpClientIoExceptionsRetries;

@IntegerConfigurationValidatorAnnotation(ConfigurationKey = FS_AZURE_APACHE_HTTP_CLIENT_MAX_CACHE_CONNECTION_SIZE,
DefaultValue = DEFAULT_HTTP_CLIENT_CONN_MAX_IDLE_CONNECTIONS)
DefaultValue = DEFAULT_HTTP_CLIENT_CONN_MAX_CACHED_CONNECTIONS)
private int maxApacheHttpClientCacheConnections;

@LongConfigurationValidatorAnnotation(ConfigurationKey = FS_AZURE_APACHE_HTTP_CLIENT_IDLE_CONNECTION_TTL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,12 @@ public static ApiVersion getCurrentVersion() {
*/
public static final Integer HTTP_STATUS_CATEGORY_QUOTIENT = 100;

/**
* System property that define maximum number of cached-connection per fileSystem for
* ApacheHttpClient. JDK network library uses the same property to define maximum
* number of cached-connections at JVM level.
*/
public static final String HTTP_MAX_CONN_SYS_PROP = "http.maxConnections";
public static final Integer DEFAULT_MAX_CONN_SYS_PROP = 5;
public static final int KAC_DEFAULT_CONN_TTL = 5_000;
public static final String JDK_IMPL = "JDK";
public static final String APACHE_IMPL = "Apache";
public static final String JDK_FALLBACK = "JDK_fallback";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,10 +319,17 @@ public static String accountProperty(String property, String account) {
* @see FileSystem#openFile(org.apache.hadoop.fs.Path)
*/
public static final String FS_AZURE_BUFFERED_PREAD_DISABLE = "fs.azure.buffered.pread.disable";
/**Defines what network library to use for server IO calls {@value }*/
/**Defines what network library to use for server IO calls: {@value}*/
public static final String FS_AZURE_NETWORKING_LIBRARY = "fs.azure.networking.library";
/**
* Maximum number of IOExceptions retries for a single server call on ApacheHttpClient.
* Breach of this count would turn off future uses of the ApacheHttpClient library
* in the JVM lifecycle: {@value}
*/
public static final String FS_AZURE_APACHE_HTTP_CLIENT_MAX_IO_EXCEPTION_RETRIES = "fs.azure.apache.http.client.max.io.exception.retries";
/**Maximum ApacheHttpClient-connection cache size at filesystem level: {@value}*/
public static final String FS_AZURE_APACHE_HTTP_CLIENT_MAX_CACHE_CONNECTION_SIZE = "fs.azure.apache.http.client.max.cache.connection.size";
/**Maximum idle time for a ApacheHttpClient-connection: {@value}*/
public static final String FS_AZURE_APACHE_HTTP_CLIENT_IDLE_CONNECTION_TTL = "fs.azure.apache.http.client.idle.connection.ttl";
private ConfigurationKeys() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ public final class FileSystemConfigurations {

public static final long DEFAULT_HTTP_CLIENT_CONN_MAX_IDLE_TIME = 5_000L;

public static final int DEFAULT_HTTP_CLIENT_CONN_MAX_IDLE_CONNECTIONS = 5;
public static final int DEFAULT_HTTP_CLIENT_CONN_MAX_CACHED_CONNECTIONS = 5;

private FileSystemConfigurations() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,17 @@

package org.apache.hadoop.fs.azurebfs.contracts.exceptions;

import java.io.IOException;

import org.apache.http.HttpResponse;

public class AbfsApacheHttpExpect100Exception extends IOException {
private final HttpResponse httpResponse;
import static org.apache.hadoop.fs.azurebfs.constants.AbfsHttpConstants.EXPECT_100_JDK_ERROR;

public AbfsApacheHttpExpect100Exception(final String s, final HttpResponse httpResponse) {
super(s);
this.httpResponse = httpResponse;
}
/**
* Exception that marks expect100 handshake error. This exception is thrown when
* the expect100 handshake fails with ADLS server sending 4xx or 5xx status code.
*/
public class AbfsApacheHttpExpect100Exception extends HttpResponseException {

public HttpResponse getHttpResponse() {
return httpResponse;
public AbfsApacheHttpExpect100Exception(final HttpResponse httpResponse) {
super(EXPECT_100_JDK_ERROR, httpResponse);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package org.apache.hadoop.fs.azurebfs.contracts.exceptions;

import java.io.IOException;
import java.util.Objects;

import org.apache.http.HttpResponse;

/**
* Encapsulates an exception thrown from ApacheHttpClient response parsing.
*/
public class HttpResponseException extends IOException {
protected final HttpResponse httpResponse;
public HttpResponseException(final String s, final HttpResponse httpResponse) {
super(s);
Objects.requireNonNull(httpResponse, "httpResponse should be non-null");
this.httpResponse = httpResponse;
}

public HttpResponse getHttpResponse() {
return httpResponse;
}
}
Loading
Loading