use of com.microsoft.azure.hdinsight.sdk.storage.HDStorageAccount in project azure-tools-for-java by Microsoft.
the class StorageAccountFolderNode method refreshItems.
@Override
protected void refreshItems() throws AzureCmdException {
if (clusterDetail != null && !clusterDetail.isEmulator()) {
try {
clusterDetail.getConfigurationInfo(getProject());
addChildNode(new StorageAccountNode(this, clusterDetail.getStorageAccount(), true));
List<HDStorageAccount> additionalStorageAccount = clusterDetail.getAdditionalStorageAccounts();
if (additionalStorageAccount != null) {
for (HDStorageAccount account : additionalStorageAccount) {
addChildNode(new StorageNode(this, account, false));
}
}
} catch (Exception exception) {
DefaultLoader.getUIHelper().showException("Failed to get HDInsight cluster configuration.", exception, "HDInsight Explorer", false, true);
}
}
}
use of com.microsoft.azure.hdinsight.sdk.storage.HDStorageAccount 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");
}
}
Aggregations