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
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@
import static org.apache.hadoop.fs.azurebfs.constants.AbfsHttpConstants.SEMICOLON;
import static org.apache.hadoop.fs.azurebfs.constants.AbfsHttpConstants.SINGLE_WHITE_SPACE;
import static org.apache.hadoop.fs.azurebfs.constants.AbfsHttpConstants.UTF_8;
import static org.apache.hadoop.fs.azurebfs.constants.AbfsServiceType.BLOB;
import static org.apache.hadoop.fs.azurebfs.constants.ConfigurationKeys.FS_AZURE_IDENTITY_TRANSFORM_CLASS;
import static org.apache.hadoop.fs.azurebfs.constants.FileSystemConfigurations.DEFAULT_DELETE_CONSIDERED_IDEMPOTENT;
import static org.apache.hadoop.fs.azurebfs.constants.FileSystemConfigurations.ONE_MB;
Expand All @@ -152,6 +153,7 @@ public abstract class AbfsClient implements Closeable {
public static final Logger LOG = LoggerFactory.getLogger(AbfsClient.class);
public static final String HUNDRED_CONTINUE_USER_AGENT = SINGLE_WHITE_SPACE + HUNDRED_CONTINUE + SEMICOLON;
public static final String ABFS_CLIENT_TIMER_THREAD_NAME = "abfs-timer-client";
public static final String FNS_BLOB_USER_AGENT_IDENTIFIER = "FNS";

private final URL baseUrl;
private final SharedKeyCredentials sharedKeyCredentials;
Expand Down Expand Up @@ -1323,6 +1325,14 @@ String initializeUserAgent(final AbfsConfiguration abfsConfiguration,
sb.append(FORWARD_SLASH);
sb.append(abfsConfiguration.getClusterType());

// Add a unique identifier in FNS-Blob user agent string
if (!getIsNamespaceEnabled()
&& abfsConfiguration.getFsConfiguredServiceType() == BLOB) {
sb.append(SEMICOLON)
.append(SINGLE_WHITE_SPACE)
.append(FNS_BLOB_USER_AGENT_IDENTIFIER);
}

sb.append(")");

appendIfNotEmpty(sb, abfsConfiguration.getCustomUserAgentPrefix(), false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ public final class ITestAbfsClient extends AbstractAbfsIntegrationTest {

private static final String ACCOUNT_NAME = "bogusAccountName.dfs.core.windows.net";
private static final String FS_AZURE_USER_AGENT_PREFIX = "Partner Service";
private static final String FNS_BLOB_USER_AGENT_IDENTIFIER = "FNS";
private static final String HUNDRED_CONTINUE_USER_AGENT = SINGLE_WHITE_SPACE + HUNDRED_CONTINUE + SEMICOLON;
private static final String TEST_PATH = "/testfile";
public static final int REDUCED_RETRY_COUNT = 2;
Expand Down Expand Up @@ -355,6 +356,42 @@ public void verifyUserAgentClusterType() throws Exception {
.contains(DEFAULT_VALUE_UNKNOWN);
}

@Test
// Test to verify the unique identifier in user agent string for FNS-Blob accounts
public void verifyUserAgentForFNSBlob() throws Exception {
assumeHnsDisabled();
assumeBlobServiceType();
final AzureBlobFileSystem fs = getFileSystem();
final AbfsConfiguration configuration = fs.getAbfsStore()
.getAbfsConfiguration();

String userAgentStr = getUserAgentString(configuration, false);
verifyBasicInfo(userAgentStr);
Assertions.assertThat(userAgentStr)
.describedAs(
"User-Agent string for FNS accounts on Blob endpoint should contain "
+ FNS_BLOB_USER_AGENT_IDENTIFIER)
.contains(FNS_BLOB_USER_AGENT_IDENTIFIER);
}

@Test
// Test to verify that the user agent string for non-FNS-Blob accounts
// does not contain the FNS identifier.
public void verifyUserAgentForDFS() throws Exception {
assumeDfsServiceType();
final AzureBlobFileSystem fs = getFileSystem();
final AbfsConfiguration configuration = fs.getAbfsStore()
.getAbfsConfiguration();

String userAgentStr = getUserAgentString(configuration, false);
verifyBasicInfo(userAgentStr);
Assertions.assertThat(userAgentStr)
.describedAs(
"User-Agent string for non-FNS-Blob accounts should not contain"
+ FNS_BLOB_USER_AGENT_IDENTIFIER)
.doesNotContain(FNS_BLOB_USER_AGENT_IDENTIFIER);
}

public static AbfsClient createTestClientFromCurrentContext(
AbfsClient baseAbfsClientInstance,
AbfsConfiguration abfsConfig) throws IOException, URISyntaxException {
Expand Down