private AzurePersistence createAzurePersistence() throws StorageException, URISyntaxException, InvalidKeyException { CloudBlobDirectory cloudBlobDirectory = null; if (accountName != null && uri != null) { String key = System.getenv("AZURE_SECRET_KEY"); StorageCredentials credentials = new StorageCredentialsAccountAndKey(accountName, key); cloudBlobDirectory = AzureUtilities.cloudBlobDirectoryFrom(credentials, uri, dir); } else if (connectionString != null && containerName != null) { cloudBlobDirectory = AzureUtilities.cloudBlobDirectoryFrom(connectionString, containerName, dir); } if (cloudBlobDirectory == null) { throw new IllegalArgumentException("Could not connect to Azure storage. Too few connection parameters specified!"); } return new AzurePersistence(cloudBlobDirectory); }
private AzurePersistence createAzurePersistence() throws StorageException, URISyntaxException, InvalidKeyException { CloudBlobDirectory cloudBlobDirectory = null; if (accountName != null && uri != null) { String key = System.getenv("AZURE_SECRET_KEY"); StorageCredentials credentials = new StorageCredentialsAccountAndKey(accountName, key); cloudBlobDirectory = AzureUtilities.cloudBlobDirectoryFrom(credentials, uri, dir); } else if (connectionString != null && containerName != null) { cloudBlobDirectory = AzureUtilities.cloudBlobDirectoryFrom(connectionString, containerName, dir); } if (cloudBlobDirectory == null) { throw new IllegalArgumentException("Could not connect to Azure storage. Too few connection parameters specified!"); } return new AzurePersistence(cloudBlobDirectory); }
public static CloudBlobDirectory createCloudBlobDirectory(String path) { Map<String, String> config = parseAzureConfigurationFromUri(path); String accountName = config.get(KEY_ACCOUNT_NAME); String key = System.getenv("AZURE_SECRET_KEY"); StorageCredentials credentials = null; try { credentials = new StorageCredentialsAccountAndKey(accountName, key); } catch (IllegalArgumentException e) { throw new IllegalArgumentException( "Could not connect to the Azure Storage. Please verify if AZURE_SECRET_KEY environment variable " + "is correctly set!"); } String uri = config.get(KEY_STORAGE_URI); String dir = config.get(KEY_DIR); try { return AzureUtilities.cloudBlobDirectoryFrom(credentials, uri, dir); } catch (URISyntaxException | StorageException e) { throw new IllegalArgumentException( "Could not connect to the Azure Storage. Please verify the path provided!"); } }
public static CloudBlobDirectory createCloudBlobDirectory(String path) { Map<String, String> config = parseAzureConfigurationFromUri(path); String accountName = config.get(KEY_ACCOUNT_NAME); String key = System.getenv("AZURE_SECRET_KEY"); StorageCredentials credentials = null; try { credentials = new StorageCredentialsAccountAndKey(accountName, key); } catch (IllegalArgumentException e) { throw new IllegalArgumentException( "Could not connect to the Azure Storage. Please verify if AZURE_SECRET_KEY environment variable " + "is correctly set!"); } String uri = config.get(KEY_STORAGE_URI); String dir = config.get(KEY_DIR); try { return AzureUtilities.cloudBlobDirectoryFrom(credentials, uri, dir); } catch (URISyntaxException | StorageException e) { throw new IllegalArgumentException( "Could not connect to the Azure Storage. Please verify the path provided!"); } }
@Override public NodeStore init(DataStoreBlobStore blobStore, File storeFile) throws Exception { Properties props = AzureDataStoreUtils.getAzureConfig(); String accessKey = props.getProperty(AzureConstants.AZURE_STORAGE_ACCOUNT_NAME); String secretKey = props.getProperty(AzureConstants.AZURE_STORAGE_ACCOUNT_KEY); container = props.getProperty(AzureConstants.AZURE_BLOB_CONTAINER_NAME); container = container + System.currentTimeMillis(); // Create the azure segment container String connectionString = getAzureConnectionString(accessKey, secretKey, container, AZURE_DIR); AzureUtilities.cloudBlobDirectoryFrom(connectionString, container, AZURE_DIR); // get the azure uri expected by the command storePath = getAzureUri(accessKey, container, AZURE_DIR); // initialize azure segment for test setup SegmentNodeStorePersistence segmentNodeStorePersistence = ToolUtils.newSegmentNodeStorePersistence(ToolUtils.SegmentStoreType.AZURE, storePath); fileStore = fileStoreBuilder(storeFile).withBlobStore(blobStore) .withCustomPersistence(segmentNodeStorePersistence).build(); store = SegmentNodeStoreBuilders.builder(fileStore).build(); return store; }