Skip to content

Commit

Permalink
change delimiter to semicolon (;) and adress comments
Browse files Browse the repository at this point in the history
  • Loading branch information
PradhanPrerak committed Aug 14, 2024
1 parent d364ac4 commit 6741625
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.apache.hadoop.security.ssl.DelegatingSSLSocketFactory;

import java.time.Duration;
import java.util.Locale;
import java.util.concurrent.TimeUnit;

/**
Expand Down Expand Up @@ -785,29 +786,6 @@ private Constants() {
"fs.s3a." + Constants.AWS_SERVICE_IDENTIFIER_STS.toLowerCase()
+ ".signing-algorithm";

/** Prefix for S3A client-specific properties. */
public static final String FS_S3A_CLIENT_PREFIX = "fs.s3a.client.";

/** Custom headers postfix. */
public static final String CUSTOM_HEADERS_POSTFIX = ".custom.headers";

/**
* List of custom headers to be set on the service client.
* Multiple parameters can be used to specify custom headers.
* fs.s3a.client.s3.custom.headers - headers to add on all the s3 requests.
* fs.s3a.client.sts.custom.headers - headers to add on all the sts requests.
* Examples
* CustomHeader {@literal ->} 'Header1:Value1'
* CustomHeaders {@literal ->} 'Header1=Value1:Value2,Header2=Value1'
*/
public static final String CUSTOM_HEADERS_STS =
FS_S3A_CLIENT_PREFIX + Constants.AWS_SERVICE_IDENTIFIER_STS.toLowerCase()
+ CUSTOM_HEADERS_POSTFIX;

public static final String CUSTOM_HEADERS_S3 =
FS_S3A_CLIENT_PREFIX + Constants.AWS_SERVICE_IDENTIFIER_S3.toLowerCase()
+ CUSTOM_HEADERS_POSTFIX;

public static final String S3N_FOLDER_SUFFIX = "_$folder$";
public static final String FS_S3A_BLOCK_SIZE = "fs.s3a.block.size";
public static final String FS_S3A = "s3a";
Expand Down Expand Up @@ -1275,6 +1253,33 @@ private Constants() {
public static final String AWS_SERVICE_IDENTIFIER_DDB = "DDB";
public static final String AWS_SERVICE_IDENTIFIER_STS = "STS";

/** Prefix for S3A client-specific properties.
* value: {@value}
*/
public static final String FS_S3A_CLIENT_PREFIX = "fs.s3a.client.";

/** Custom headers postfix.
* value: {@value}
*/
public static final String CUSTOM_HEADERS_POSTFIX = ".custom.headers";

/**
* List of custom headers to be set on the service client.
* Multiple parameters can be used to specify custom headers.
* fs.s3a.client.s3.custom.headers - headers to add on all the s3 requests.
* fs.s3a.client.sts.custom.headers - headers to add on all the sts requests.
* Examples
* CustomHeader {@literal ->} 'Header1:Value1'
* CustomHeaders {@literal ->} 'Header1=Value1;Value2,Header2=Value1'
*/
public static final String CUSTOM_HEADERS_STS =
FS_S3A_CLIENT_PREFIX + AWS_SERVICE_IDENTIFIER_STS.toLowerCase(Locale.ROOT)
+ CUSTOM_HEADERS_POSTFIX;

public static final String CUSTOM_HEADERS_S3 =
FS_S3A_CLIENT_PREFIX + AWS_SERVICE_IDENTIFIER_S3.toLowerCase(Locale.ROOT)
+ CUSTOM_HEADERS_POSTFIX;

/**
* How long to wait for the thread pool to terminate when cleaning up.
* Value: {@value} seconds.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ private static void initSigner(Configuration conf,
}

/**
*
* Initialize custom request headers for AWS clients.
* @param conf hadoop configuration
* @param clientConfig client configuration to update
* @param awsServiceIdentifier service name
Expand All @@ -431,13 +431,13 @@ private static void initRequestHeaders(Configuration conf,
configKey = CUSTOM_HEADERS_STS;
break;
default:
// Nothing to do. The original signer override is already setup
// No known service.
}
if (configKey != null) {
Map<String, String> awsClientCustomHeadersMap =
S3AUtils.getTrimmedStringCollectionSplitByEquals(conf, configKey);
awsClientCustomHeadersMap.forEach((header, valueString) -> {
List<String> headerValues = Arrays.asList(valueString.split(":"));
List<String> headerValues = Arrays.asList(valueString.split(";"));
clientConfig.putHeader(header, headerValues);
});
LOG.debug("headers for {} client = {}", awsServiceIdentifier, clientConfig.headers());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ private void setOptionsToValue(String value, Configuration conf, String... keys)
@Test
public void testInitRequestHeadersForSTS() throws IOException {
final Configuration conf = new Configuration();
conf.set(CUSTOM_HEADERS_STS, "foo=bar:baz,qux=quux");
conf.set(CUSTOM_HEADERS_STS, "foo=bar;baz,qux=quux");
Assertions.assertThat(conf.get(CUSTOM_HEADERS_S3))
.describedAs("Custom client headers for s3 %s", CUSTOM_HEADERS_S3)
.isNull();
Expand Down Expand Up @@ -246,7 +246,7 @@ public void testInitRequestHeadersForSTS() throws IOException {
@Test
public void testInitRequestHeadersForS3() throws IOException {
final Configuration conf = new Configuration();
conf.set(CUSTOM_HEADERS_S3, "foo=bar:baz,qux=quux");
conf.set(CUSTOM_HEADERS_S3, "foo=bar;baz,qux=quux");
Assertions.assertThat(conf.get(CUSTOM_HEADERS_STS))
.describedAs("Custom client headers for STS %s", CUSTOM_HEADERS_STS)
.isNull();
Expand Down

0 comments on commit 6741625

Please sign in to comment.