你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
BlobLeaseAsyncClient Class
- java.
lang. Object - com.
azure. storage. blob. specialized. BlobLeaseAsyncClient
- com.
public final class BlobLeaseAsyncClient
This class provides a client that contains all the leasing operations for BlobContainerAsyncClient and BlobAsyncClient. This client acts as a supplement to those clients and only handles leasing operations.
Instantiating a BlobLeaseAsyncClient
BlobLeaseAsyncClient blobLeaseAsyncClient = new BlobLeaseClientBuilder()
.blobAsyncClient(blobAsyncClient)
.buildAsyncClient();
BlobLeaseAsyncClient blobLeaseAsyncClient = new BlobLeaseClientBuilder()
.containerAsyncClient(blobContainerAsyncClient)
.buildAsyncClient();
View BlobLeaseClientBuilder for additional ways to construct the client.
For more information about leasing see the container leasing or blob leasing documentation.
Method Summary
Methods inherited from java.lang.Object
Method Details
acquireLease
public Mono
Acquires a lease for write and delete operations. The lease duration must be between 15 and 60 seconds or -1 for an infinite duration.
Code Samples
client.acquireLease(60).subscribe(response -> System.out.printf("Lease ID is %s%n", response));
Parameters:
Returns:
acquireLeaseWithResponse
public Mono
Acquires a lease for write and delete operations. The lease duration must be between 15 and 60 seconds, or -1 for an infinite duration.
Code Samples
BlobLeaseRequestConditions requestConditions = new BlobLeaseRequestConditions()
.setIfModifiedSince(OffsetDateTime.now().minusDays(3));
BlobAcquireLeaseOptions options = new BlobAcquireLeaseOptions(60)
.setRequestConditions(requestConditions);
client.acquireLeaseWithResponse(options).subscribe(response ->
System.out.printf("Lease ID is %s%n", response.getValue()));
Parameters:
Returns:
acquireLeaseWithResponse
public Mono
Acquires a lease for write and delete operations. The lease duration must be between 15 and 60 seconds, or -1 for an infinite duration.
Code Samples
RequestConditions modifiedRequestConditions = new RequestConditions()
.setIfModifiedSince(OffsetDateTime.now().minusDays(3));
client.acquireLeaseWithResponse(60, modifiedRequestConditions).subscribe(response ->
System.out.printf("Lease ID is %s%n", response.getValue()));
Parameters:
Returns:
breakLease
public Mono
Breaks the previously acquired lease, if it exists.
Code Samples
client.breakLease().subscribe(response ->
System.out.printf("The broken lease has %d seconds remaining on the lease", response));
Returns:
breakLeaseWithResponse
public Mono
Breaks the previously acquired lease, if it exists.
If null
is passed for breakPeriodInSeconds
a fixed duration lease will break after the remaining lease period elapses and an infinite lease will break immediately.
Code Samples
Integer retainLeaseInSeconds = 5;
BlobLeaseRequestConditions requestConditions = new BlobLeaseRequestConditions()
.setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
BlobBreakLeaseOptions options = new BlobBreakLeaseOptions()
.setBreakPeriod(Duration.ofSeconds(retainLeaseInSeconds))
.setRequestConditions(requestConditions);
client.breakLeaseWithResponse(options).subscribe(response ->
System.out.printf("The broken lease has %d seconds remaining on the lease", response.getValue()));
Parameters:
Returns:
breakLeaseWithResponse
public Mono
Breaks the previously acquired lease, if it exists.
If null
is passed for breakPeriodInSeconds
a fixed duration lease will break after the remaining lease period elapses and an infinite lease will break immediately.
Code Samples
Integer retainLeaseInSeconds = 5;
RequestConditions modifiedRequestConditions = new RequestConditions()
.setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
client.breakLeaseWithResponse(retainLeaseInSeconds, modifiedRequestConditions).subscribe(response ->
System.out.printf("The broken lease has %d seconds remaining on the lease", response.getValue()));
Parameters:
Returns:
changeLease
public Mono
Changes the lease ID.
Code Samples
client.changeLease("proposedId").subscribe(response -> System.out.printf("Changed lease ID is %s%n", response));
Parameters:
Returns:
changeLeaseWithResponse
public Mono
Changes the lease ID.
Code Samples
BlobLeaseRequestConditions requestConditions = new BlobLeaseRequestConditions()
.setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
BlobChangeLeaseOptions options = new BlobChangeLeaseOptions("proposedId")
.setRequestConditions(requestConditions);
client.changeLeaseWithResponse(options).subscribe(response ->
System.out.printf("Changed lease ID is %s%n", response.getValue()));
Parameters:
Returns:
changeLeaseWithResponse
public Mono
Changes the lease ID.
Code Samples
RequestConditions modifiedRequestConditions = new RequestConditions()
.setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
client.changeLeaseWithResponse("proposedId", modifiedRequestConditions).subscribe(response ->
System.out.printf("Changed lease ID is %s%n", response.getValue()));
Parameters:
Returns:
getAccountName
public String getAccountName()
Get associated account name.
Returns:
getLeaseId
public String getLeaseId()
Get the lease ID for this lease.
Returns:
getResourceUrl
public String getResourceUrl()
Gets the URL of the lease client.
The lease will either be a container or blob URL depending on which the lease client is associated.
Returns:
releaseLease
public Mono
Releases the previously acquired lease.
Code Samples
client.releaseLease().subscribe(response -> System.out.println("Completed release lease"));
Returns:
releaseLeaseWithResponse
public Mono
Releases the previously acquired lease.
Code Samples
RequestConditions modifiedRequestConditions = new RequestConditions()
.setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
client.releaseLeaseWithResponse(modifiedRequestConditions).subscribe(response ->
System.out.printf("Release lease completed with status %d%n", response.getStatusCode()));
Parameters:
Returns:
releaseLeaseWithResponse
public Mono
Releases the previously acquired lease.
Code Samples
BlobLeaseRequestConditions requestConditions = new BlobLeaseRequestConditions()
.setIfModifiedSince(OffsetDateTime.now().minusDays(3));
BlobReleaseLeaseOptions options = new BlobReleaseLeaseOptions()
.setRequestConditions(requestConditions);
client.releaseLeaseWithResponse(options).subscribe(response ->
System.out.printf("Release lease completed with status %d%n", response.getStatusCode()));
Parameters:
Returns:
renewLease
public Mono
Renews the previously acquired lease.
Code Samples
client.renewLease().subscribe(response -> System.out.printf("Renewed lease ID is %s%n", response));
Returns:
renewLeaseWithResponse
public Mono
Renews the previously acquired lease.
Code Samples
RequestConditions modifiedRequestConditions = new RequestConditions()
.setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));
client.renewLeaseWithResponse(modifiedRequestConditions).subscribe(response ->
System.out.printf("Renewed lease ID is %s%n", response.getValue()));
Parameters:
Returns:
renewLeaseWithResponse
public Mono
Renews the previously acquired lease.
Code Samples
BlobLeaseRequestConditions requestConditions = new BlobLeaseRequestConditions()
.setIfModifiedSince(OffsetDateTime.now().minusDays(3));
BlobRenewLeaseOptions options = new BlobRenewLeaseOptions()
.setRequestConditions(requestConditions);
client.renewLeaseWithResponse(options).subscribe(response ->
System.out.printf("Lease ID is %s%n", response.getValue()));
Parameters:
Returns: