Search in sources :

Example 6 with BlobContainer

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
    }
}
Also used : BlobContainer(com.microsoft.tooling.msservices.model.storage.BlobContainer) HDStorageAccount(com.microsoft.azure.hdinsight.sdk.storage.HDStorageAccount)

Example 7 with BlobContainer

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");
    }
}
Also used : CallableSingleArg(com.microsoft.tooling.msservices.helpers.CallableSingleArg) BlobContainer(com.microsoft.tooling.msservices.model.storage.BlobContainer) HDStorageAccount(com.microsoft.azure.hdinsight.sdk.storage.HDStorageAccount)

Example 8 with BlobContainer

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);
}
Also used : StorageAccount(com.microsoft.azure.management.storage.StorageAccount) ClientStorageAccount(com.microsoft.tooling.msservices.model.storage.ClientStorageAccount) BlobContainer(com.microsoft.tooling.msservices.model.storage.BlobContainer) ClientStorageAccount(com.microsoft.tooling.msservices.model.storage.ClientStorageAccount)

Aggregations

BlobContainer (com.microsoft.tooling.msservices.model.storage.BlobContainer)8 HDStorageAccount (com.microsoft.azure.hdinsight.sdk.storage.HDStorageAccount)3 AzureCmdException (com.microsoft.azuretools.azurecommons.helpers.AzureCmdException)3 StorageAccount (com.microsoft.azure.management.storage.StorageAccount)2 CallableSingleArg (com.microsoft.tooling.msservices.helpers.CallableSingleArg)2 ClientStorageAccount (com.microsoft.tooling.msservices.model.storage.ClientStorageAccount)2 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)1 Task (com.intellij.openapi.progress.Task)1 NotNull (com.microsoft.azuretools.azurecommons.helpers.NotNull)1 BufferedInputStream (java.io.BufferedInputStream)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 NotNull (org.jetbrains.annotations.NotNull)1