本文整理汇总了Java中com.microsoft.azure.storage.file.CloudFileClient.getShareReference方法的典型用法代码示例。如果您正苦于以下问题:Java CloudFileClient.getShareReference方法的具体用法?Java CloudFileClient.getShareReference怎么用?Java CloudFileClient.getShareReference使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.microsoft.azure.storage.file.CloudFileClient
的用法示例。
在下文中一共展示了CloudFileClient.getShareReference方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: AzureNotebookRepo
import com.microsoft.azure.storage.file.CloudFileClient; //导入方法依赖的package包/类
public AzureNotebookRepo(ZeppelinConfiguration conf)
throws URISyntaxException, InvalidKeyException, StorageException {
this.conf = conf;
user = conf.getString(ZeppelinConfiguration.ConfVars.ZEPPELIN_NOTEBOOK_AZURE_USER);
shareName = conf.getString(ZeppelinConfiguration.ConfVars.ZEPPELIN_NOTEBOOK_AZURE_SHARE);
CloudStorageAccount account = CloudStorageAccount.parse(
conf.getString(ZeppelinConfiguration.ConfVars.ZEPPELIN_NOTEBOOK_AZURE_CONNECTION_STRING));
CloudFileClient client = account.createCloudFileClient();
CloudFileShare share = client.getShareReference(shareName);
share.createIfNotExists();
CloudFileDirectory userDir = StringUtils.isBlank(user) ?
share.getRootDirectoryReference() :
share.getRootDirectoryReference().getDirectoryReference(user);
userDir.createIfNotExists();
rootDir = userDir.getDirectoryReference("notebook");
rootDir.createIfNotExists();
}
示例2: testCloudStorageAccountClientUriVerify
import com.microsoft.azure.storage.file.CloudFileClient; //导入方法依赖的package包/类
@Test
public void testCloudStorageAccountClientUriVerify() throws URISyntaxException, StorageException {
StorageCredentialsAccountAndKey cred = new StorageCredentialsAccountAndKey(ACCOUNT_NAME, ACCOUNT_KEY);
CloudStorageAccount cloudStorageAccount = new CloudStorageAccount(cred, true);
CloudBlobClient blobClient = cloudStorageAccount.createCloudBlobClient();
CloudBlobContainer container = blobClient.getContainerReference("container1");
assertEquals(cloudStorageAccount.getBlobEndpoint().toString() + "/container1", container.getUri().toString());
CloudQueueClient queueClient = cloudStorageAccount.createCloudQueueClient();
CloudQueue queue = queueClient.getQueueReference("queue1");
assertEquals(cloudStorageAccount.getQueueEndpoint().toString() + "/queue1", queue.getUri().toString());
CloudTableClient tableClient = cloudStorageAccount.createCloudTableClient();
CloudTable table = tableClient.getTableReference("table1");
assertEquals(cloudStorageAccount.getTableEndpoint().toString() + "/table1", table.getUri().toString());
CloudFileClient fileClient = cloudStorageAccount.createCloudFileClient();
CloudFileShare share = fileClient.getShareReference("share1");
assertEquals(cloudStorageAccount.getFileEndpoint().toString() + "/share1", share.getUri().toString());
}
示例3: testFileMaximumExecutionTime
import com.microsoft.azure.storage.file.CloudFileClient; //导入方法依赖的package包/类
@Test
@Category({ DevFabricTests.class, DevStoreTests.class, SecondaryTests.class })
public void testFileMaximumExecutionTime() throws URISyntaxException, StorageException {
OperationContext opContext = new OperationContext();
setDelay(opContext, 2500);
opContext.getResponseReceivedEventHandler().addListener(new StorageEvent<ResponseReceivedEvent>() {
@Override
public void eventOccurred(ResponseReceivedEvent eventArg) {
// Set status code to 500 to force a retry
eventArg.getRequestResult().setStatusCode(500);
}
});
// set the maximum execution time
FileRequestOptions options = new FileRequestOptions();
options.setMaximumExecutionTimeInMs(2000);
options.setTimeoutIntervalInMs(1000);
CloudFileClient fileClient = TestHelper.createCloudFileClient();
CloudFileShare share = fileClient.getShareReference(generateRandomName("share"));
try {
// 1. download attributes will fail as the share does not exist
// 2. the executor will attempt to retry as we set the status code to 500
// 3. maximum execution time should prevent the retry from being made
share.downloadAttributes(null, options, opContext);
fail("Maximum execution time was reached but request did not fail.");
}
catch (StorageException e) {
assertEquals(SR.MAXIMUM_EXECUTION_TIMEOUT_EXCEPTION, e.getMessage());
}
}
示例4: process
import com.microsoft.azure.storage.file.CloudFileClient; //导入方法依赖的package包/类
@RequestMapping(value = "/file", method = RequestMethod.GET)
public String process(HttpServletResponse response) {
LOG.info("FileRestController process start...");
StringBuffer result = new StringBuffer();
try {
result.append("Connecting to storage account..." + CR);
if (account == null)
{
account = factory.createAccountByServiceInstanceName("mystorage");
if (account == null)
{
String message = "CloudStorageAccount object not injected, lookup by name failed.";
LOG.error(message);
throw new RuntimeException(message);
}
}
result.append("Creating file client..." + CR);
CloudFileClient fileClient = account.createCloudFileClient();
result.append("Creating file share..." + CR);
CloudFileShare share = fileClient.getShareReference("productshare");
if (share.createIfNotExists()) {
result.append("Created file share..." + CR);
}
CloudFileDirectory rootDir = share.getRootDirectoryReference();
result.append("Creating products directory..." + CR);
CloudFileDirectory dir = rootDir.getDirectoryReference("products");
if (dir.createIfNotExists()) {
result.append("Created products directory..." + CR);
} else {
result.append("Products directory already exists..." + CR);
System.out.println("sampledir already exists");
}
result.append("Creating Product.txt file..." + CR);
CloudFile cloudFile = dir.getFileReference("Product.txt");
cloudFile.create(1024L);
cloudFile.openWriteExisting();
String contents = "PCF is a great product!";
result.append("Writing to file..." + CR);
InputStream in = new ByteArrayInputStream(contents.getBytes());
cloudFile.upload(in, contents.length());
result.append("Reading from file..." + CR);
String output = cloudFile.downloadText();
result.append("Contents = " + output + CR);
} catch (Exception e) {
LOG.error("Error processing request ", e);
}
result.append("Processed Date = " + new Date(System.currentTimeMillis()) + CR);
LOG.info("FileRestController process end");
return result.toString();
}
开发者ID:pivotal-partner-solution-architecture,项目名称:azure-service-broker-client,代码行数:64,代码来源:FileRestController.java