/** * Acquires a new infinite lease on the blob. * * @return A <code>String</code> that represents the lease ID. * * @throws StorageException * If a storage service error occurred. */ @DoesServiceRequest public final String acquireLease() throws StorageException { return this.acquireLease(null /* leaseTimeInSeconds */, null /* proposedLeaseId */); }
/** * Acquires a new infinite lease on the blob. * * @return A <code>String</code> that represents the lease ID. * * @throws StorageException * If a storage service error occurred. */ @DoesServiceRequest public final String acquireLease() throws StorageException { return this.acquireLease(null /* leaseTimeInSeconds */, null /* proposedLeaseId */); }
/** * Acquires a new lease on the blob with the specified lease time and proposed lease ID. * * @param leaseTimeInSeconds * An <code>Integer</code> which specifies the span of time for which to acquire the lease, in seconds. * If null, an infinite lease will be acquired. If not null, the value must be greater than * zero. * * @param proposedLeaseId * A <code>String</code> that represents the proposed lease ID for the new lease, * or null if no lease ID is proposed. * * @return A <code>String</code> that represents the lease ID. * * @throws StorageException * If a storage service error occurred. */ @DoesServiceRequest public final String acquireLease(final Integer leaseTimeInSeconds, final String proposedLeaseId) throws StorageException { return this.acquireLease(leaseTimeInSeconds, proposedLeaseId, null /* accessCondition */, null /* options */, null /* opContext */); }
/** * Acquires a new lease on the blob with the specified lease time and proposed lease ID. * * @param leaseTimeInSeconds * An <code>Integer</code> which specifies the span of time for which to acquire the lease, in seconds. * If null, an infinite lease will be acquired. If not null, the value must be greater than * zero. * * @param proposedLeaseId * A <code>String</code> that represents the proposed lease ID for the new lease, * or null if no lease ID is proposed. * * @return A <code>String</code> that represents the lease ID. * * @throws StorageException * If a storage service error occurred. */ @DoesServiceRequest public final String acquireLease(final Integer leaseTimeInSeconds, final String proposedLeaseId) throws StorageException { return this.acquireLease(leaseTimeInSeconds, proposedLeaseId, null /* accessCondition */, null /* options */, null /* opContext */); }
while(leaseID == null) { try { leaseID = blob.acquireLease(LEASE_TIMEOUT, null); } catch (StorageException e) {
@Test @Category(SlowTests.class) public void testBlobLeaseRenew() throws StorageException, IOException, InterruptedException, URISyntaxException { final CloudBlob blobRef = BlobTestHelper.uploadNewBlob(this.container, BlobType.BLOCK_BLOB, "test", 128, null); // Get Lease final String leaseID = blobRef.acquireLease(15, null); Thread.sleep(1000); AccessCondition leaseCondition = AccessCondition.generateLeaseCondition(leaseID); OperationContext operationContext = new OperationContext(); blobRef.renewLease(leaseCondition, null/* BlobRequestOptions */, operationContext); assertTrue(operationContext.getLastResult().getStatusCode() == HttpURLConnection.HTTP_OK); } }
differentLeaseID = blob.acquireLease(15, null); } catch (Exception e) { e.printStackTrace();
@Test public void testBlobLeaseBreak() throws StorageException, IOException, URISyntaxException { final CloudBlob blobRef = BlobTestHelper.uploadNewBlob(this.container, BlobType.BLOCK_BLOB, "test", 128, null); // Get Lease String leaseID = blobRef.acquireLease(); OperationContext operationContext = new OperationContext(); final AccessCondition leaseCondition = AccessCondition.generateLeaseCondition(leaseID); blobRef.breakLease(0, leaseCondition, null/* BlobRequestOptions */, operationContext); assertTrue(operationContext.getLastResult().getStatusCode() == HttpURLConnection.HTTP_ACCEPTED); }
differentLeaseID = blob.acquireLease(15, null); } catch (Exception e) { e.printStackTrace();
@Test public void testBlobLeaseAcquireAndRelease() throws URISyntaxException, StorageException, IOException { final int length = 128; final CloudBlob blobRef = BlobTestHelper.uploadNewBlob(this.container, BlobType.BLOCK_BLOB, "test", 128, null); // Get Lease OperationContext operationContext = new OperationContext(); final String leaseID = blobRef.acquireLease(15, null /*proposed lease id */, null /*access condition*/, null/* BlobRequestOptions */, operationContext); final AccessCondition leaseCondition = AccessCondition.generateLeaseCondition(leaseID); assertTrue(operationContext.getLastResult().getStatusCode() == HttpURLConnection.HTTP_CREATED); tryUploadWithBadLease(length, blobRef, null, StorageErrorCodeStrings.LEASE_ID_MISSING); // Try to upload with lease blobRef.upload(BlobTestHelper.getRandomDataStream(length), -1, leaseCondition, null, null); // Release lease blobRef.releaseLease(leaseCondition); // now upload with no lease specified. blobRef.upload(BlobTestHelper.getRandomDataStream(length), -1); }
final String leaseID1 = blobRef.acquireLease(15, null /*proposed lease id */, null /*access condition*/,