当前位置: 首页>>代码示例>>Java>>正文


Java AccessCondition.generateEmptyCondition方法代码示例

本文整理汇总了Java中com.microsoft.azure.storage.AccessCondition.generateEmptyCondition方法的典型用法代码示例。如果您正苦于以下问题:Java AccessCondition.generateEmptyCondition方法的具体用法?Java AccessCondition.generateEmptyCondition怎么用?Java AccessCondition.generateEmptyCondition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.microsoft.azure.storage.AccessCondition的用法示例。


在下文中一共展示了AccessCondition.generateEmptyCondition方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: free

import com.microsoft.azure.storage.AccessCondition; //导入方法依赖的package包/类
/**
 * Free the lease and stop the keep-alive thread.
 * @throws StorageException
 */
public void free() throws StorageException {
  AccessCondition accessCondition = AccessCondition.generateEmptyCondition();
  accessCondition.setLeaseID(leaseID);
  try {
    blobWrapper.getBlob().releaseLease(accessCondition);
  } catch (StorageException e) {
    if (e.getErrorCode().equals("BlobNotFound")) {

      // Don't do anything -- it's okay to free a lease
      // on a deleted file. The delete freed the lease
      // implicitly.
    } else {

      // This error is not anticipated, so re-throw it.
      LOG.warn("Unanticipated exception when trying to free lease " + leaseID
          + " on " +  blobWrapper.getStorageUri());
      throw(e);
    }
  } finally {

    // Even if releasing the lease fails (e.g. because the file was deleted),
    // make sure to record that we freed the lease, to terminate the
    // keep-alive thread.
    leaseFreed = true;
    LOG.debug("Freed lease " + leaseID + " on " + blobWrapper.getUri()
        + " managed by thread " + renewer.getName());
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:33,代码来源:SelfRenewingLease.java

示例2: testSelfRenewingLease

import com.microsoft.azure.storage.AccessCondition; //导入方法依赖的package包/类
@Test
// Acquire and free a Lease object. Wait for more than the lease
// timeout, to make sure the lease renews itself.
public void testSelfRenewingLease() throws IllegalArgumentException, IOException,
  InterruptedException, StorageException {

  SelfRenewingLease lease;
  final String FILE_KEY = "file";
  fs.create(new Path(FILE_KEY));
  NativeAzureFileSystem nfs = (NativeAzureFileSystem) fs;
  String fullKey = nfs.pathToKey(nfs.makeAbsolute(new Path(FILE_KEY)));
  AzureNativeFileSystemStore store = nfs.getStore();
  lease = store.acquireLease(fullKey);
  assertTrue(lease.getLeaseID() != null);

  // The sleep time for the keep-alive thread is 40 seconds, so sleep just
  // a little beyond that, to make sure the keep-alive thread wakes up
  // and renews the lease.
  Thread.sleep(42000);
  lease.free();

  // Check that the lease is really freed.
  CloudBlob blob = lease.getCloudBlob();

  // Try to acquire it again, using direct Azure blob access.
  // If that succeeds, then the lease was already freed.
  String differentLeaseID = null;
  try {
    differentLeaseID = blob.acquireLease(15, null);
  } catch (Exception e) {
    e.printStackTrace();
    fail("Caught exception trying to directly re-acquire lease from Azure");
  } finally {
    assertTrue(differentLeaseID != null);
    AccessCondition accessCondition = AccessCondition.generateEmptyCondition();
    accessCondition.setLeaseID(differentLeaseID);
    blob.releaseLease(accessCondition);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:40,代码来源:NativeAzureFileSystemBaseTest.java


注:本文中的com.microsoft.azure.storage.AccessCondition.generateEmptyCondition方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。