Skip to content

Commit

Permalink
[Blob] Set tier and rehydrate (#7269)
Browse files Browse the repository at this point in the history
* [BlockBlob][Tier]Add BlobTier Support For CopyBlob/PutBlob/PutBlockList

* [BlockBlob][Tier]Add Recordings for Standard BlobTier Support

* [BlockBlob][Rehydrate]Enable Rehydrate Priority for Copy/SetTier

* [BlockBlob][Rehydrate]Recordings for Rehydrate Priority for Copy/SetTier
  • Loading branch information
xiafu-msft authored and rakshith91 committed Oct 1, 2019
1 parent ad3edc9 commit e544514
Show file tree
Hide file tree
Showing 24 changed files with 3,198 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ def upload_block_blob( # pylint: disable=too-many-locals
if (encryption_options.get('key') is not None) and (adjusted_count is not None):
adjusted_count += (16 - (length % 16))
blob_headers = kwargs.pop('blob_headers', None)
tier = kwargs.pop('standard_blob_tier', None)

# Do single put if the size is smaller than config.max_single_put_size
if adjusted_count is not None and (adjusted_count < blob_settings.max_single_put_size):
Expand All @@ -100,6 +101,7 @@ def upload_block_blob( # pylint: disable=too-many-locals
validate_content=validate_content,
data_stream_total=adjusted_count,
upload_stream_current=0,
tier=tier.value if tier else None,
**kwargs)

use_original_upload_path = blob_settings.use_byte_buffer or \
Expand Down Expand Up @@ -145,6 +147,7 @@ def upload_block_blob( # pylint: disable=too-many-locals
cls=return_response_headers,
validate_content=validate_content,
headers=headers,
tier=tier.value if tier else None,
**kwargs)
except StorageErrorException as error:
try:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ async def upload_block_blob( # pylint: disable=too-many-locals
if (encryption_options.get('key') is not None) and (adjusted_count is not None):
adjusted_count += (16 - (length % 16))
blob_headers = kwargs.pop('blob_headers', None)
tier = kwargs.pop('standard_blob_tier', None)

# Do single put if the size is smaller than config.max_single_put_size
if adjusted_count is not None and (adjusted_count < blob_settings.max_single_put_size):
Expand All @@ -74,6 +75,7 @@ async def upload_block_blob( # pylint: disable=too-many-locals
validate_content=validate_content,
data_stream_total=adjusted_count,
upload_stream_current=0,
tier=tier.value if tier else None,
**kwargs)

use_original_upload_path = blob_settings.use_byte_buffer or \
Expand Down Expand Up @@ -119,6 +121,7 @@ async def upload_block_blob( # pylint: disable=too-many-locals
cls=return_response_headers,
validate_content=validate_content,
headers=headers,
tier=tier.value if tier else None,
**kwargs)
except StorageErrorException as error:
try:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,9 @@ async def upload_blob(
A page blob tier value to set the blob to. The tier correlates to the size of the
blob and number of allowed IOPS. This is only applicable to page blobs on
premium storage accounts.
:param ~azure.storage.blob.models.StandardBlobTier standard_blob_tier:
A standard blob tier value to set the blob to. For this version of the library,
this is only applicable to block blobs on standard storage accounts.
:param int maxsize_condition:
Optional conditional header. The max length in bytes permitted for
the append blob. If the Append Block operation would cause the blob
Expand Down Expand Up @@ -910,6 +913,11 @@ async def start_copy_from_url(self, source_url, metadata=None, incremental_copy=
A page blob tier value to set the blob to. The tier correlates to the size of the
blob and number of allowed IOPS. This is only applicable to page blobs on
premium storage accounts.
:param ~azure.storage.blob.models.StandardBlobTier standard_blob_tier:
A standard blob tier value to set the blob to. For this version of the library,
this is only applicable to block blobs on standard storage accounts.
:param :class:`~azure.storage.blob.models.RehydratePriority` rehydrate_priority:
Indicates the priority with which to rehydrate an archived blob
:param bool requires_sync:
Enforces that the service will not return a response until the copy is complete.
:returns: A dictionary of copy properties (etag, last_modified, copy_id, copy_status).
Expand Down Expand Up @@ -1034,6 +1042,8 @@ async def set_standard_blob_tier(self, standard_blob_tier, **kwargs):
tier is optimized for storing data that is rarely accessed and stored
for at least six months with flexible latency requirements.
:type standard_blob_tier: str or ~azure.storage.blob.models.StandardBlobTier
:param :class:`~azure.storage.blob.models.RehydratePriority` rehydrate_priority:
Indicates the priority with which to rehydrate an archived blob
:param int timeout:
The timeout parameter is expressed in seconds.
:param lease:
Expand Down Expand Up @@ -1238,6 +1248,9 @@ async def commit_block_list( # type: ignore
the value specified. Specify the wildcard character (*) to perform
the operation only if the resource does not exist, and fail the
operation if it does exist.
:param ~azure.storage.blob.models.StandardBlobTier standard_blob_tier:
A standard blob tier value to set the blob to. For this version of the library,
this is only applicable to block blobs on standard storage accounts.
:param ~azure.storage.blob.models.CustomerProvidedEncryptionKey cpk:
Encrypts the data on the service-side with the given key.
Use of customer-provided keys must be done over HTTPS.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,9 @@ async def upload_blob(
A page blob tier value to set the blob to. The tier correlates to the size of the
blob and number of allowed IOPS. This is only applicable to page blobs on
premium storage accounts.
:param ~azure.storage.blob.models.StandardBlobTier standard_blob_tier:
A standard blob tier value to set the blob to. For this version of the library,
this is only applicable to block blobs on standard storage accounts.
:param int maxsize_condition:
Optional conditional header. The max length in bytes permitted for
the append blob. If the Append Block operation would cause the blob
Expand All @@ -666,6 +669,11 @@ async def upload_blob(
:param int max_connections:
Maximum number of parallel connections to use when the blob size exceeds
64MB.
:param ~azure.storage.blob.models.CustomerProvidedEncryptionKey cpk:
Encrypts the data on the service-side with the given key.
Use of customer-provided keys must be done over HTTPS.
As the encryption key itself is provided in the request,
a secure connection must be established to transfer the key.
:param str encoding:
Defaults to UTF-8.
:returns: A BlobClient to interact with the newly uploaded blob.
Expand Down
27 changes: 23 additions & 4 deletions sdk/storage/azure-storage-blob/azure/storage/blob/blob_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,9 @@ def upload_blob( # pylint: disable=too-many-locals
A page blob tier value to set the blob to. The tier correlates to the size of the
blob and number of allowed IOPS. This is only applicable to page blobs on
premium storage accounts.
:param ~azure.storage.blob.models.StandardBlobTier standard_blob_tier:
A standard blob tier value to set the blob to. For this version of the library,
this is only applicable to block blobs on standard storage accounts.
:param int maxsize_condition:
Optional conditional header. The max length in bytes permitted for
the append blob. If the Append Block operation would cause the blob
Expand Down Expand Up @@ -1341,9 +1344,9 @@ def _start_copy_from_url_options(self, source_url, metadata=None, incremental_co
headers['x-ms-source-lease-id'] = source_lease.id # type: str
except AttributeError:
headers['x-ms-source-lease-id'] = source_lease
if kwargs.get('premium_page_blob_tier'):
premium_page_blob_tier = kwargs.pop('premium_page_blob_tier')
headers['x-ms-access-tier'] = premium_page_blob_tier.value

tier = kwargs.pop('premium_page_blob_tier', None) or kwargs.pop('standard_blob_tier', None)

if kwargs.get('requires_sync'):
headers['x-ms-requires-sync'] = str(kwargs.pop('requires_sync'))

Expand All @@ -1358,6 +1361,7 @@ def _start_copy_from_url_options(self, source_url, metadata=None, incremental_co
'timeout': timeout,
'modified_access_conditions': dest_mod_conditions,
'headers': headers,
'tier': tier.value if tier else None,
'cls': return_response_headers,
}
if not incremental_copy:
Expand Down Expand Up @@ -1499,6 +1503,11 @@ def start_copy_from_url(self, source_url, metadata=None, incremental_copy=False,
A page blob tier value to set the blob to. The tier correlates to the size of the
blob and number of allowed IOPS. This is only applicable to page blobs on
premium storage accounts.
:param ~azure.storage.blob.models.StandardBlobTier standard_blob_tier:
A standard blob tier value to set the blob to. For this version of the library,
this is only applicable to block blobs on standard storage accounts.
:param :class:`~azure.storage.blob.models.RehydratePriority` rehydrate_priority:
Indicates the priority with which to rehydrate an archived blob
:param bool requires_sync:
Enforces that the service will not return a response until the copy is complete.
:returns: A dictionary of copy properties (etag, last_modified, copy_id, copy_status).
Expand Down Expand Up @@ -1640,6 +1649,8 @@ def set_standard_blob_tier(self, standard_blob_tier, **kwargs):
tier is optimized for storing data that is rarely accessed and stored
for at least six months with flexible latency requirements.
:type standard_blob_tier: str or ~azure.storage.blob.models.StandardBlobTier
:param :class:`~azure.storage.blob._generated.models.RehydratePriority` rehydrate_priority:
Indicates the priority with which to rehydrate an archived blob
:param int timeout:
The timeout parameter is expressed in seconds.
:param lease:
Expand Down Expand Up @@ -1930,6 +1941,9 @@ def _commit_block_list_options( # type: ignore
raise ValueError("Customer provided encryption key must be used over HTTPS.")
cpk_info = CpkInfo(encryption_key=cpk.key_value, encryption_key_sha256=cpk.key_hash,
encryption_algorithm=cpk.algorithm)

tier = kwargs.pop('standard_blob_tier', None)

options = {
'blocks': block_lookup,
'blob_http_headers': blob_headers,
Expand All @@ -1938,7 +1952,9 @@ def _commit_block_list_options( # type: ignore
'modified_access_conditions': mod_conditions,
'cls': return_response_headers,
'validate_content': validate_content,
'cpk_info': cpk_info}
'cpk_info': cpk_info,
'tier': tier.value if tier else None
}
options.update(kwargs)
return options

Expand Down Expand Up @@ -1993,6 +2009,9 @@ def commit_block_list( # type: ignore
the value specified. Specify the wildcard character (*) to perform
the operation only if the resource does not exist, and fail the
operation if it does exist.
:param ~azure.storage.blob.models.StandardBlobTier standard_blob_tier:
A standard blob tier value to set the blob to. For this version of the library,
this is only applicable to block blobs on standard storage accounts.
:param ~azure.storage.blob.models.CustomerProvidedEncryptionKey cpk:
Encrypts the data on the service-side with the given key.
Use of customer-provided keys must be done over HTTPS.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -833,6 +833,9 @@ def upload_blob(
A page blob tier value to set the blob to. The tier correlates to the size of the
blob and number of allowed IOPS. This is only applicable to page blobs on
premium storage accounts.
:param ~azure.storage.blob.models.StandardBlobTier standard_blob_tier:
A standard blob tier value to set the blob to. For this version of the library,
this is only applicable to block blobs on standard storage accounts.
:param int maxsize_condition:
Optional conditional header. The max length in bytes permitted for
the append blob. If the Append Block operation would cause the blob
Expand All @@ -842,6 +845,11 @@ def upload_blob(
:param int max_connections:
Maximum number of parallel connections to use when the blob size exceeds
64MB.
:param ~azure.storage.blob.models.CustomerProvidedEncryptionKey cpk:
Encrypts the data on the service-side with the given key.
Use of customer-provided keys must be done over HTTPS.
As the encryption key itself is provided in the request,
a secure connection must be established to transfer the key.
:param str encoding:
Defaults to UTF-8.
:returns: A BlobClient to interact with the newly uploaded blob.
Expand Down
Loading

0 comments on commit e544514

Please sign in to comment.