use of com.microsoft.tooling.msservices.model.storage.BlobContainer in project azure-tools-for-java by Microsoft.
the class StorageAccountNode method refreshItems.
@Override
protected void refreshItems() throws AzureCmdException {
//TelemetryManager.postEvent(TelemetryCommon.HDInsightExplorerStorageAccountExpand, null, null);
if (storageAccount.getAccountType() == StorageAccountTypeEnum.BLOB) {
HDStorageAccount blobStorageAccount = (HDStorageAccount) storageAccount;
String defaultContainer = blobStorageAccount.getDefaultContainer();
List<BlobContainer> containerList = StorageClientSDKManager.getManager().getBlobContainers(((HDStorageAccount) storageAccount).getConnectionString());
for (BlobContainer blobContainer : containerList) {
addChildNode(new BlobContainerNode(this, blobStorageAccount, blobContainer, !StringHelper.isNullOrWhiteSpace(defaultContainer) && defaultContainer.equals(blobContainer.getName())));
}
} else if (storageAccount.getAccountType() == StorageAccountTypeEnum.ADLS) {
// TODO: adls support
}
}
use of com.microsoft.tooling.msservices.model.storage.BlobContainer in project azure-tools-for-java by Microsoft.
the class SparkSubmitHelper method uploadFileToHDFS.
public String uploadFileToHDFS(Project project, String localFile, IHDIStorageAccount storageAccount, String defaultContainerName, String uploadFolderPath) throws Exception {
final File file = new File(localFile);
if (storageAccount.getAccountType() == StorageAccountTypeEnum.BLOB) {
try (FileInputStream fileInputStream = new FileInputStream(file)) {
try (BufferedInputStream bufferedInputStream = new BufferedInputStream(fileInputStream)) {
final CallableSingleArg<Void, Long> callable = new CallableSingleArg<Void, Long>() {
@Override
public Void call(Long uploadedBytes) throws Exception {
double progress = ((double) uploadedBytes) / file.length();
return null;
}
};
HDStorageAccount blobStorageAccount = (HDStorageAccount) storageAccount;
BlobContainer defaultContainer = getSparkClusterDefaultContainer(blobStorageAccount, defaultContainerName);
String path = String.format("SparkSubmission/%s/%s", uploadFolderPath, file.getName());
String uploadedPath = String.format("wasb://%s@%s/%s", defaultContainerName, blobStorageAccount.getFullStorageBlobName(), path);
HDInsightUtil.showInfoOnSubmissionMessageWindow(project, String.format("Info : Begin uploading file %s to Azure Blob Storage Account %s ...", localFile, uploadedPath));
StorageClientSDKManager.getManager().uploadBlobFileContent(blobStorageAccount.getConnectionString(), defaultContainer, path, bufferedInputStream, callable, 1024 * 1024, file.length());
HDInsightUtil.showInfoOnSubmissionMessageWindow(project, String.format("Info : Submit file to azure blob '%s' successfully.", uploadedPath));
return uploadedPath;
}
}
} else if (storageAccount.getAccountType() == StorageAccountTypeEnum.ADLS) {
String uploadPath = String.format("adl://%s.azuredatalakestore.net%s%s", storageAccount.getName(), storageAccount.getDefaultContainerOrRootPath(), "SparkSubmission");
HDInsightUtil.showInfoOnSubmissionMessageWindow(project, String.format("Info : Begin uploading file %s to Azure Datalake store %s ...", localFile, uploadPath));
String uploadedPath = StreamUtil.uploadArtifactToADLS(file, storageAccount, uploadFolderPath);
HDInsightUtil.showInfoOnSubmissionMessageWindow(project, String.format("Info : Submit file to Azure Datalake store '%s' successfully.", uploadedPath));
return uploadedPath;
} else {
throw new UnsupportedOperationException("unknown storage account type");
}
}
use of com.microsoft.tooling.msservices.model.storage.BlobContainer in project azure-tools-for-java by Microsoft.
the class BlobExplorerFileEditorProvider method accept.
@Override
public boolean accept(@NotNull Project project, @NotNull VirtualFile virtualFile) {
StorageAccount storageAccount = virtualFile.getUserData(UIHelperImpl.STORAGE_KEY);
ClientStorageAccount clientStorageAccount = virtualFile.getUserData(UIHelperImpl.CLIENT_STORAGE_KEY);
BlobContainer blobContainer = virtualFile.getUserData(CONTAINER_KEY);
return ((storageAccount != null || clientStorageAccount != null) && blobContainer != null);
}
Aggregations