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

HADOOP-19226: [ABFS][FNSOverBlob] Implementing Azure Rest APIs on Blob Endpoint for AbfsBlobClient #6944

Merged
merged 18 commits into from
Nov 26, 2024
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@
files="org[\\/]apache[\\/]hadoop[\\/]fs[\\/]azurebfs[\\/]AzureBlobFileSystemStore.java"/>
<suppress checks="ParameterNumber"
files="org[\\/]apache[\\/]hadoop[\\/]fs[\\/]azurebfs[\\/]services[\\/]AbfsClient.java"/>
<suppress checks="ParameterNumber"
files="org[\\/]apache[\\/]hadoop[\\/]fs[\\/]azurebfs[\\/]services[\\/]AbfsBlobClient.java"/>
<suppress checks="ParameterNumber"
files="org[\\/]apache[\\/]hadoop[\\/]fs[\\/]azurebfs[\\/]contracts[\\/]services[\\/]AppendRequestParameters.java"/>
<suppress checks="ParameterNumber|MagicNumber"
files="org[\\/]apache[\\/]hadoop[\\/]fs[\\/]azurebfs[\\/]utils[\\/]Base64.java"/>
<suppress checks="ParameterNumber|VisibilityModifier"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1457,7 +1457,7 @@ private boolean fileSystemExists() throws IOException {
try {
checkException(null, ex);
// Because HEAD request won't contain message body,
// there is not way to get the storage error code
// there is no way to get the storage error code
// workaround here is to check its status code.
} catch (FileNotFoundException e) {
statIncrement(ERROR_IGNORED);
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,16 @@ public final class AbfsHttpConstants {
public static final String DEFAULT_LEASE_BREAK_PERIOD = "0";
public static final String DEFAULT_TIMEOUT = "90";
public static final String APPEND_BLOB_TYPE = "appendblob";
public static final String TOKEN_VERSION = "2";

//Abfs Http Client Constants for Blob Endpoint APIs.
public static final String CONTAINER = "container";
public static final String METADATA = "metadata";
public static final String LIST = "list";
public static final String BLOCK = "block";
public static final String BLOCKLIST = "blocklist";
public static final String LEASE = "lease";
public static final String BLOCK_BLOB_TYPE = "BlockBlob";
public static final String BLOCK_TYPE_COMMITTED = "committed";

public static final String JAVA_VENDOR = "java.vendor";
public static final String JAVA_VERSION = "java.version";
Expand All @@ -60,6 +69,7 @@ public final class AbfsHttpConstants {

public static final String APN_VERSION = "APN/1.0";
public static final String CLIENT_VERSION = "Azure Blob FS/" + VersionInfo.getVersion();
public static final String TOKEN_VERSION = "2";

// Abfs Http Verb
public static final String HTTP_METHOD_DELETE = "DELETE";
Expand Down Expand Up @@ -92,6 +102,7 @@ public final class AbfsHttpConstants {
public static final String HTTP_HEADER_PREFIX = "x-ms-";
public static final String HASH = "#";
public static final String TRUE = "true";
public static final String ZERO = "0";

public static final String PLUS_ENCODE = "%20";
public static final String FORWARD_SLASH_ENCODE = "%2F";
Expand All @@ -101,6 +112,7 @@ public final class AbfsHttpConstants {
public static final String GMT_TIMEZONE = "GMT";
public static final String APPLICATION_JSON = "application/json";
public static final String APPLICATION_OCTET_STREAM = "application/octet-stream";
public static final String APPLICATION_XML = "application/xml";
public static final String XMS_PROPERTIES_ENCODING_ASCII = "ISO-8859-1";
public static final String XMS_PROPERTIES_ENCODING_UNICODE = "UTF-8";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ public enum FSOperationType {
SET_OWNER("SO"),
SET_ACL("SA"),
TEST_OP("TS"),
WRITE("WR"),
INIT("IN");
WRITE("WR");

private final String opCode;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,16 @@ public final class HttpHeaderConfigurations {
public static final String X_MS_LEASE_ACTION = "x-ms-lease-action";
public static final String X_MS_LEASE_DURATION = "x-ms-lease-duration";
public static final String X_MS_LEASE_ID = "x-ms-lease-id";
public static final String X_MS_SOURCE_LEASE_ID = "x-ms-source-lease-id";
public static final String X_MS_PROPOSED_LEASE_ID = "x-ms-proposed-lease-id";
public static final String X_MS_LEASE_BREAK_PERIOD = "x-ms-lease-break-period";
public static final String EXPECT = "Expect";
public static final String X_MS_RANGE_GET_CONTENT_MD5 = "x-ms-range-get-content-md5";
public static final String X_MS_BLOB_TYPE = "x-ms-blob-type";
public static final String X_MS_META_HDI_ISFOLDER = "x-ms-meta-hdi_isfolder";
public static final String X_MS_METADATA_PREFIX = "x-ms-meta-";
public static final String X_MS_COPY_SOURCE = "x-ms-copy-source";
public static final String X_MS_BLOB_CONTENT_MD5 = "x-ms-blob-content-md5";

private HttpHeaderConfigurations() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,17 @@ public final class HttpQueryParams {
public static final String QUERY_PARAM_BLOBTYPE = "blobtype";
public static final String QUERY_PARAM_PAGINATED = "paginated";

// query parameters for Blob Endpoint Rest APIs
public static final String QUERY_PARAM_RESTYPE = "restype";
public static final String QUERY_PARAM_COMP = "comp";
public static final String QUERY_PARAM_INCLUDE = "include";
public static final String QUERY_PARAM_PREFIX = "prefix";
public static final String QUERY_PARAM_MARKER = "marker";
public static final String QUERY_PARAM_DELIMITER = "delimiter";
public static final String QUERY_PARAM_MAX_RESULTS = "maxresults";
public static final String QUERY_PARAM_BLOCKID = "blockid";
public static final String QUERY_PARAM_BLOCKLISTTYPE = "blocklisttype";

//query params for SAS
public static final String QUERY_PARAM_SAOID = "saoid";
public static final String QUERY_PARAM_SKOID = "skoid";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ public enum Mode {
private boolean isExpectHeaderEnabled;
private boolean isRetryDueToExpect;

/*
* Following parameters are used by AbfsBlobClient only.
* Blob Endpoint Append API requires blockId and eTag to be passed in the request.
*/
private String blockId;
private String eTag;

// Constructor to be used for interacting with AbfsDfsClient
public AppendRequestParameters(final long position,
final int offset,
final int length,
Expand All @@ -52,6 +60,30 @@ public AppendRequestParameters(final long position,
this.leaseId = leaseId;
this.isExpectHeaderEnabled = isExpectHeaderEnabled;
this.isRetryDueToExpect = false;
this.blockId = null;
this.eTag = null;
}

// Constructor to be used for interacting with AbfsBlobClient
public AppendRequestParameters(final long position,
final int offset,
final int length,
final Mode mode,
final boolean isAppendBlob,
final String leaseId,
final boolean isExpectHeaderEnabled,
final String blockId,
final String eTag) {
this.position = position;
this.offset = offset;
this.length = length;
this.mode = mode;
this.isAppendBlob = isAppendBlob;
this.leaseId = leaseId;
this.isExpectHeaderEnabled = isExpectHeaderEnabled;
this.isRetryDueToExpect = false;
this.blockId = blockId;
this.eTag = eTag;
}

public long getPosition() {
Expand Down Expand Up @@ -86,6 +118,14 @@ public boolean isRetryDueToExpect() {
return isRetryDueToExpect;
}

public String getBlockId() {
return blockId;
}

public String getETag() {
return eTag;
}

public void setRetryDueToExpect(boolean retryDueToExpect) {
isRetryDueToExpect = retryDueToExpect;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@
public enum AzureServiceErrorCode {
FILE_SYSTEM_ALREADY_EXISTS("FilesystemAlreadyExists", HttpURLConnection.HTTP_CONFLICT, null),
PATH_ALREADY_EXISTS("PathAlreadyExists", HttpURLConnection.HTTP_CONFLICT, null),
BLOB_ALREADY_EXISTS("BlobAlreadyExists", HttpURLConnection.HTTP_CONFLICT, null),
INTERNAL_OPERATION_ABORT("InternalOperationAbortError", HttpURLConnection.HTTP_CONFLICT, null),
PATH_CONFLICT("PathConflict", HttpURLConnection.HTTP_CONFLICT, null),
FILE_SYSTEM_NOT_FOUND("FilesystemNotFound", HttpURLConnection.HTTP_NOT_FOUND, null),
PATH_NOT_FOUND("PathNotFound", HttpURLConnection.HTTP_NOT_FOUND, null),
BLOB_PATH_NOT_FOUND("BlobNotFound", HttpURLConnection.HTTP_NOT_FOUND, null),
PRE_CONDITION_FAILED("PreconditionFailed", HttpURLConnection.HTTP_PRECON_FAILED, null),
SOURCE_PATH_NOT_FOUND("SourcePathNotFound", HttpURLConnection.HTTP_NOT_FOUND, null),
INVALID_SOURCE_OR_DESTINATION_RESOURCE_TYPE("InvalidSourceOrDestinationResourceType", HttpURLConnection.HTTP_CONFLICT, null),
Expand Down
Loading
Loading