Search in sources :

Example 6 with CloudAppendBlob

use of com.microsoft.azure.storage.blob.CloudAppendBlob in project camel by apache.

the class BlobServiceProducer method deleteAppendBlob.

private void deleteAppendBlob(Exchange exchange) throws Exception {
    CloudAppendBlob client = BlobServiceUtil.createAppendBlobClient(getConfiguration());
    doDeleteBlock(client, exchange);
}
Also used : CloudAppendBlob(com.microsoft.azure.storage.blob.CloudAppendBlob)

Example 7 with CloudAppendBlob

use of com.microsoft.azure.storage.blob.CloudAppendBlob in project camel by apache.

the class BlobServiceUtil method createAppendBlobClient.

public static CloudAppendBlob createAppendBlobClient(BlobServiceConfiguration cfg) throws Exception {
    CloudAppendBlob client = (CloudAppendBlob) getConfiguredClient(cfg);
    if (client == null) {
        URI uri = prepareStorageBlobUri(cfg);
        StorageCredentials creds = getAccountCredentials(cfg);
        client = new CloudAppendBlob(uri, creds);
    }
    return client;
}
Also used : StorageCredentials(com.microsoft.azure.storage.StorageCredentials) CloudAppendBlob(com.microsoft.azure.storage.blob.CloudAppendBlob) URI(java.net.URI)

Example 8 with CloudAppendBlob

use of com.microsoft.azure.storage.blob.CloudAppendBlob in project camel by apache.

the class BlobServiceUtilTest method testGetConfiguredClientUriMismatch.

@Test
public void testGetConfiguredClientUriMismatch() throws Exception {
    CloudAppendBlob client = new CloudAppendBlob(URI.create("https://camelazure.blob.core.windows.net/container/blob"));
    JndiRegistry registry = (JndiRegistry) ((PropertyPlaceholderDelegateRegistry) context.getRegistry()).getRegistry();
    registry.bind("azureBlobClient", client);
    BlobServiceComponent component = new BlobServiceComponent(context);
    BlobServiceEndpoint endpoint = (BlobServiceEndpoint) component.createEndpoint("azure-blob://camelazure/container/blob2?azureBlobClient=#azureBlobClient&publicForRead=true" + "&blobType=appendBlob");
    try {
        BlobServiceUtil.getConfiguredClient(endpoint.getConfiguration());
        fail();
    } catch (IllegalArgumentException ex) {
        assertEquals("Invalid Client URI", ex.getMessage());
    }
}
Also used : JndiRegistry(org.apache.camel.impl.JndiRegistry) CloudAppendBlob(com.microsoft.azure.storage.blob.CloudAppendBlob) Test(org.junit.Test)

Example 9 with CloudAppendBlob

use of com.microsoft.azure.storage.blob.CloudAppendBlob in project jackrabbit-oak by apache.

the class AzureJournalReaderTest method createJournalReader.

protected JournalReader createJournalReader(String s) throws IOException {
    try {
        CloudAppendBlob blob = container.getAppendBlobReference("journal/journal.log.001");
        blob.createOrReplace();
        blob.appendText(s);
        return new JournalReader(new AzureJournalFile(container.getDirectoryReference("journal"), "journal.log"));
    } catch (StorageException | URISyntaxException e) {
        throw new IOException(e);
    }
}
Also used : CloudAppendBlob(com.microsoft.azure.storage.blob.CloudAppendBlob) AzureJournalFile(org.apache.jackrabbit.oak.segment.azure.AzureJournalFile) URISyntaxException(java.net.URISyntaxException) IOException(java.io.IOException) StorageException(com.microsoft.azure.storage.StorageException) JournalReader(org.apache.jackrabbit.oak.segment.file.JournalReader)

Example 10 with CloudAppendBlob

use of com.microsoft.azure.storage.blob.CloudAppendBlob in project jackrabbit-oak by apache.

the class ReverseFileReaderTest method createFile.

private List<String> createFile(int lines, int maxLineLength) throws IOException, URISyntaxException, StorageException {
    Random random = new Random();
    List<String> entries = new ArrayList<>();
    CloudAppendBlob blob = getBlob();
    for (int i = 0; i < lines; i++) {
        int entrySize = random.nextInt(maxLineLength) + 1;
        String entry = randomString(entrySize);
        try {
            blob.appendText(entry + '\n');
        } catch (StorageException e) {
            throw new IOException(e);
        }
        entries.add(entry);
    }
    entries.add("");
    Collections.reverse(entries);
    return entries;
}
Also used : Random(java.util.Random) CloudAppendBlob(com.microsoft.azure.storage.blob.CloudAppendBlob) ArrayList(java.util.ArrayList) IOException(java.io.IOException) StorageException(com.microsoft.azure.storage.StorageException)

Aggregations

CloudAppendBlob (com.microsoft.azure.storage.blob.CloudAppendBlob)10 StorageException (com.microsoft.azure.storage.StorageException)3 IOException (java.io.IOException)3 StorageCredentials (com.microsoft.azure.storage.StorageCredentials)2 URISyntaxException (java.net.URISyntaxException)2 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2 CloudBlob (com.microsoft.azure.storage.blob.CloudBlob)1 ListBlobItem (com.microsoft.azure.storage.blob.ListBlobItem)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1 URI (java.net.URI)1 Random (java.util.Random)1 CamelContext (org.apache.camel.CamelContext)1 ProducerTemplate (org.apache.camel.ProducerTemplate)1 RouteBuilder (org.apache.camel.builder.RouteBuilder)1 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)1 JndiRegistry (org.apache.camel.impl.JndiRegistry)1 AzureJournalFile (org.apache.jackrabbit.oak.segment.azure.AzureJournalFile)1