Skip to content

Commit 35570e4

Browse files
HADOOP-17290. ABFS: Add Identifiers to Client Request Header (apache#2520)
Contributed by Sumangala Patki.
1 parent ea259f2 commit 35570e4

File tree

58 files changed

+1891
-551
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+1891
-551
lines changed

hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/AbfsConfiguration.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,15 @@
6161
import org.apache.hadoop.fs.azurebfs.services.ExponentialRetryPolicy;
6262
import org.apache.hadoop.fs.azurebfs.services.KeyProvider;
6363
import org.apache.hadoop.fs.azurebfs.services.SimpleKeyProvider;
64+
import org.apache.hadoop.fs.azurebfs.utils.TracingHeaderFormat;
6465
import org.apache.hadoop.security.ssl.DelegatingSSLSocketFactory;
6566
import org.apache.hadoop.security.ProviderUtils;
6667
import org.apache.hadoop.util.ReflectionUtils;
6768

6869
import org.slf4j.Logger;
6970
import org.slf4j.LoggerFactory;
7071

72+
import static org.apache.hadoop.fs.azurebfs.constants.AbfsHttpConstants.EMPTY_STRING;
7173
import static org.apache.hadoop.fs.azurebfs.constants.ConfigurationKeys.*;
7274
import static org.apache.hadoop.fs.azurebfs.constants.FileSystemConfigurations.*;
7375

@@ -264,6 +266,10 @@ public class AbfsConfiguration{
264266
DefaultValue = DEFAULT_VALUE_UNKNOWN)
265267
private String clusterType;
266268

269+
@StringConfigurationValidatorAnnotation(ConfigurationKey = FS_AZURE_CLIENT_CORRELATIONID,
270+
DefaultValue = EMPTY_STRING)
271+
private String clientCorrelationId;
272+
267273
@BooleanConfigurationValidatorAnnotation(ConfigurationKey = FS_AZURE_ENABLE_DELEGATION_TOKEN,
268274
DefaultValue = DEFAULT_ENABLE_DELEGATION_TOKEN)
269275
private boolean enableDelegationToken;
@@ -332,6 +338,14 @@ public String getAccountName() {
332338
return accountName;
333339
}
334340

341+
/**
342+
* Gets client correlation ID provided in config.
343+
* @return Client Correlation ID config
344+
*/
345+
public String getClientCorrelationId() {
346+
return clientCorrelationId;
347+
}
348+
335349
/**
336350
* Appends an account name to a configuration key yielding the
337351
* account-specific form.
@@ -722,6 +736,14 @@ public DelegatingSSLSocketFactory.SSLChannelMode getPreferredSSLFactoryOption()
722736
return getEnum(FS_AZURE_SSL_CHANNEL_MODE_KEY, DEFAULT_FS_AZURE_SSL_CHANNEL_MODE);
723737
}
724738

739+
/**
740+
* Enum config to allow user to pick format of x-ms-client-request-id header
741+
* @return tracingContextFormat config if valid, else default ALL_ID_FORMAT
742+
*/
743+
public TracingHeaderFormat getTracingHeaderFormat() {
744+
return getEnum(FS_AZURE_TRACINGHEADER_FORMAT, TracingHeaderFormat.ALL_ID_FORMAT);
745+
}
746+
725747
public AuthType getAuthType(String accountName) {
726748
return getEnum(FS_AZURE_ACCOUNT_AUTH_TYPE_PROPERTY_NAME, AuthType.SharedKey);
727749
}

hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/AzureBlobFileSystem.java

Lines changed: 166 additions & 52 deletions
Large diffs are not rendered by default.

hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/AzureBlobFileSystemStore.java

Lines changed: 154 additions & 109 deletions
Large diffs are not rendered by default.

hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/constants/ConfigurationKeys.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,12 @@ public final class ConfigurationKeys {
109109
* Default value of this config is true. **/
110110
public static final String FS_AZURE_DISABLE_OUTPUTSTREAM_FLUSH = "fs.azure.disable.outputstream.flush";
111111
public static final String FS_AZURE_USER_AGENT_PREFIX_KEY = "fs.azure.user.agent.prefix";
112+
/**
113+
* The client correlation ID provided over config that will be added to
114+
* x-ms-client-request-Id header. Defaults to empty string if the length and
115+
* character constraints are not satisfied. **/
116+
public static final String FS_AZURE_CLIENT_CORRELATIONID = "fs.azure.client.correlationid";
117+
public static final String FS_AZURE_TRACINGHEADER_FORMAT = "fs.azure.tracingheader.format";
112118
public static final String FS_AZURE_CLUSTER_NAME = "fs.azure.cluster.name";
113119
public static final String FS_AZURE_CLUSTER_TYPE = "fs.azure.cluster.type";
114120
public static final String FS_AZURE_SSL_CHANNEL_MODE_KEY = "fs.azure.ssl.channel.mode";
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/**
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"), you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
package org.apache.hadoop.fs.azurebfs.constants;
20+
21+
public enum FSOperationType {
22+
ACCESS("AS"),
23+
APPEND("AP"),
24+
BREAK_LEASE("BL"),
25+
CREATE("CR"),
26+
CREATE_FILESYSTEM("CF"),
27+
CREATE_NON_RECURSIVE("CN"),
28+
DELETE("DL"),
29+
GET_ACL_STATUS("GA"),
30+
GET_ATTR("GR"),
31+
GET_FILESTATUS("GF"),
32+
LISTSTATUS("LS"),
33+
MKDIR("MK"),
34+
MODIFY_ACL("MA"),
35+
OPEN("OP"),
36+
HAS_PATH_CAPABILITY("PC"),
37+
SET_PERMISSION("SP"),
38+
READ("RE"),
39+
RELEASE_LEASE("RL"),
40+
REMOVE_ACL("RA"),
41+
REMOVE_ACL_ENTRIES("RT"),
42+
REMOVE_DEFAULT_ACL("RD"),
43+
RENAME("RN"),
44+
SET_ATTR("SR"),
45+
SET_OWNER("SO"),
46+
SET_ACL("SA"),
47+
TEST_OP("TS"),
48+
WRITE("WR");
49+
50+
private final String opCode;
51+
52+
FSOperationType(String opCode) {
53+
this.opCode = opCode;
54+
}
55+
56+
@Override
57+
public String toString() {
58+
return opCode;
59+
}
60+
}

hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/constants/FileSystemConfigurations.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ public final class FileSystemConfigurations {
111111
public static final boolean DEFAULT_DELETE_CONSIDERED_IDEMPOTENT = true;
112112
public static final int DEFAULT_CLOCK_SKEW_WITH_SERVER_IN_MS = 5 * 60 * 1000; // 5 mins
113113

114+
public static final int STREAM_ID_LEN = 12;
114115
public static final boolean DEFAULT_ENABLE_ABFS_LIST_ITERATOR = true;
115116

116117
private FileSystemConfigurations() {}

0 commit comments

Comments
 (0)