DataLakeLeaseAsyncClient Class
- java.
lang. Object - com.
azure. storage. file. datalake. specialized. DataLakeLeaseAsyncClient
- com.
public final class DataLakeLeaseAsyncClient
This class provides a client that contains all the leasing operations for DataLakeFileSystemAsyncClient, DataLakeFileAsyncClient and DataLakeDirectoryAsyncClient. This client acts as a supplement to those clients and only handles leasing operations.
Instantiating a DataLakeLeaseAsyncClient
DataLakeLeaseAsyncClient dataLakeLeaseAsyncClient = new DataLakeLeaseClientBuilder()
.fileAsyncClient(fileAsyncClient)
.buildAsyncClient();
DataLakeLeaseAsyncClient dataLakeLeaseAsyncClient = new DataLakeLeaseClientBuilder()
.directoryAsyncClient(directoryAsyncClient)
.buildAsyncClient();
DataLakeLeaseAsyncClient dataLakeLeaseAsyncClient = new DataLakeLeaseClientBuilder()
.fileSystemAsyncClient(dataLakeFileSystemAsyncClient)
.buildAsyncClient();
View DataLakeLeaseClientBuilder for additional ways to construct the client.
For more information about leasing see the file system leasing or path leasing documentation.
Method Summary
Methods inherited from java.lang.Object
Method Details
acquireLease
public Mono<String> acquireLease(int durationInSeconds)
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<Response<String>> acquireLeaseWithResponse(int durationInSeconds, RequestConditions modifiedRequestConditions)
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
// Optional HTTP request conditions that can be used to narrow the scope of the request.
// The request conditions can be used to have the leasing request only succeed if the resource has been
// modified and/or unmodified within a certain time frame and/or matches and/or doesn't match a specific ETag,
// or any ETag.
RequestConditions modifiedRequestConditions = yourOptionalRequestConditions;
client.acquireLeaseWithResponse(60, modifiedRequestConditions).subscribe(response ->
System.out.printf("Lease ID is %s%n", response.getValue()));
Parameters:
Returns:
breakLease
public Mono<Integer> breakLease()
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<Response<Integer>> breakLeaseWithResponse(Integer breakPeriodInSeconds, RequestConditions modifiedRequestConditions)
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;
// Optional HTTP request conditions that can be used to narrow the scope of the request.
// The request conditions can be used to have the leasing request only succeed if the resource has been
// modified and/or unmodified within a certain time frame and/or matches and/or doesn't match a specific ETag,
// or any ETag.
RequestConditions modifiedRequestConditions = yourOptionalRequestConditions;
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<String> changeLease(String proposedId)
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<Response<String>> changeLeaseWithResponse(String proposedId, RequestConditions modifiedRequestConditions)
Changes the lease ID.
Code Samples
// Optional HTTP request conditions that can be used to narrow the scope of the request.
// The request conditions can be used to have the leasing request only succeed if the resource has been
// modified and/or unmodified within a certain time frame and/or matches and/or doesn't match a specific ETag,
// or any ETag.
RequestConditions modifiedRequestConditions = yourOptionalRequestConditions;
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 file system or path URL depending on which the lease client is associated.
Returns:
releaseLease
public Mono<Void> releaseLease()
Releases the previously acquired lease.
Code Samples
client.releaseLease().subscribe(response -> System.out.println("Completed release lease"));
Returns:
releaseLeaseWithResponse
public Mono<Response<Void>> releaseLeaseWithResponse(RequestConditions modifiedRequestConditions)
Releases the previously acquired lease.
Code Samples
// Optional HTTP request conditions that can be used to narrow the scope of the request.
// The request conditions can be used to have the leasing request only succeed if the resource has been
// modified and/or unmodified within a certain time frame and/or matches and/or doesn't match a specific ETag,
// or any ETag.
RequestConditions modifiedRequestConditions = yourOptionalRequestConditions;
client.releaseLeaseWithResponse(modifiedRequestConditions).subscribe(response ->
System.out.printf("Release lease completed with status %d%n", response.getStatusCode()));
Parameters:
Returns:
renewLease
public Mono<String> renewLease()
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<Response<String>> renewLeaseWithResponse(RequestConditions modifiedRequestConditions)
Renews the previously acquired lease.
Code Samples
// Optional HTTP request conditions that can be used to narrow the scope of the request.
// The request conditions can be used to have the leasing request only succeed if the resource has been
// modified and/or unmodified within a certain time frame and/or matches and/or doesn't match a specific ETag,
// or any ETag.
RequestConditions modifiedRequestConditions = yourOptionalRequestConditions;
client.renewLeaseWithResponse(modifiedRequestConditions).subscribe(response ->
System.out.printf("Renewed lease ID is %s%n", response.getValue()));
Parameters:
Returns: