Search in sources :

Example 36 with StorageException

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

the class AzureBlobStoreBackend method deleteRecord.

@Override
public void deleteRecord(DataIdentifier identifier) throws DataStoreException {
    if (null == identifier)
        throw new NullPointerException("identifier");
    String key = getKeyName(identifier);
    long start = System.currentTimeMillis();
    ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
    try {
        Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
        boolean result = getAzureContainer().getBlockBlobReference(key).deleteIfExists();
        LOG.debug("Blob {}. identifier={} duration={}", result ? "deleted" : "delete requested, but it does not exist (perhaps already deleted)", key, (System.currentTimeMillis() - start));
    } catch (StorageException e) {
        LOG.info("Error deleting blob. identifier={}", key, e);
        throw new DataStoreException(e);
    } catch (URISyntaxException e) {
        throw new DataStoreException(e);
    } finally {
        if (contextClassLoader != null) {
            Thread.currentThread().setContextClassLoader(contextClassLoader);
        }
    }
}
Also used : DataStoreException(org.apache.jackrabbit.core.data.DataStoreException) URISyntaxException(java.net.URISyntaxException) StorageException(com.microsoft.azure.storage.StorageException)

Example 37 with StorageException

use of com.microsoft.azure.storage.StorageException in project elasticsearch by elastic.

the class AzureBlobStoreContainerTests method newBlobStore.

@Override
protected BlobStore newBlobStore() throws IOException {
    try {
        RepositoryMetaData repositoryMetaData = new RepositoryMetaData("azure", "ittest", Settings.EMPTY);
        AzureStorageServiceMock client = new AzureStorageServiceMock();
        return new AzureBlobStore(repositoryMetaData, Settings.EMPTY, client);
    } catch (URISyntaxException | StorageException e) {
        throw new IOException(e);
    }
}
Also used : RepositoryMetaData(org.elasticsearch.cluster.metadata.RepositoryMetaData) AzureStorageServiceMock(org.elasticsearch.cloud.azure.storage.AzureStorageServiceMock) AzureBlobStore(org.elasticsearch.cloud.azure.blobstore.AzureBlobStore) URISyntaxException(java.net.URISyntaxException) IOException(java.io.IOException) StorageException(com.microsoft.azure.storage.StorageException)

Example 38 with StorageException

use of com.microsoft.azure.storage.StorageException in project druid by druid-io.

the class AzureDataSegmentKillerTest method killWithErrorTest.

@Test(expected = SegmentLoadingException.class)
public void killWithErrorTest() throws SegmentLoadingException, URISyntaxException, StorageException {
    String dirPath = Paths.get(blobPath).getParent().toString();
    expect(azureStorage.emptyCloudBlobDirectory(containerName, dirPath)).andThrow(new StorageException("", "", 400, null, null));
    replayAll();
    AzureDataSegmentKiller killer = new AzureDataSegmentKiller(azureStorage);
    killer.kill(dataSegment);
    verifyAll();
}
Also used : StorageException(com.microsoft.azure.storage.StorageException) Test(org.junit.Test)

Example 39 with StorageException

use of com.microsoft.azure.storage.StorageException in project zeppelin by apache.

the class AzureNotebookRepo method getNote.

private Note getNote(String noteId) throws IOException {
    InputStream ins = null;
    try {
        CloudFileDirectory dir = rootDir.getDirectoryReference(noteId);
        CloudFile file = dir.getFileReference("note.json");
        ins = file.openRead();
    } catch (URISyntaxException | StorageException e) {
        String msg = String.format("Error reading notebook %s from Azure storage", noteId);
        LOG.error(msg, e);
        throw new IOException(msg, e);
    }
    String json = IOUtils.toString(ins, conf.getString(ZeppelinConfiguration.ConfVars.ZEPPELIN_ENCODING));
    ins.close();
    GsonBuilder gsonBuilder = new GsonBuilder();
    gsonBuilder.setPrettyPrinting();
    Gson gson = gsonBuilder.registerTypeAdapter(Date.class, new NotebookImportDeserializer()).create();
    Note note = gson.fromJson(json, Note.class);
    for (Paragraph p : note.getParagraphs()) {
        if (p.getStatus() == Job.Status.PENDING || p.getStatus() == Job.Status.RUNNING) {
            p.setStatus(Job.Status.ABORT);
        }
    }
    return note;
}
Also used : CloudFileDirectory(com.microsoft.azure.storage.file.CloudFileDirectory) GsonBuilder(com.google.gson.GsonBuilder) InputStream(java.io.InputStream) Gson(com.google.gson.Gson) URISyntaxException(java.net.URISyntaxException) IOException(java.io.IOException) NotebookImportDeserializer(org.apache.zeppelin.notebook.NotebookImportDeserializer) Date(java.util.Date) Paragraph(org.apache.zeppelin.notebook.Paragraph) CloudFile(com.microsoft.azure.storage.file.CloudFile) Note(org.apache.zeppelin.notebook.Note) StorageException(com.microsoft.azure.storage.StorageException)

Example 40 with StorageException

use of com.microsoft.azure.storage.StorageException in project zeppelin by apache.

the class AzureNotebookRepo method remove.

@Override
public void remove(String noteId, AuthenticationInfo subject) throws IOException {
    try {
        CloudFileDirectory dir = rootDir.getDirectoryReference(noteId);
        delete(dir);
    } catch (URISyntaxException | StorageException e) {
        String msg = String.format("Error deleting notebook %s from Azure storage", noteId);
        LOG.error(msg, e);
        throw new IOException(msg, e);
    }
}
Also used : CloudFileDirectory(com.microsoft.azure.storage.file.CloudFileDirectory) URISyntaxException(java.net.URISyntaxException) IOException(java.io.IOException) StorageException(com.microsoft.azure.storage.StorageException)

Aggregations

StorageException (com.microsoft.azure.storage.StorageException)55 URISyntaxException (java.net.URISyntaxException)34 IOException (java.io.IOException)31 Path (org.apache.hadoop.fs.Path)13 FileNotFoundException (java.io.FileNotFoundException)10 DataStoreException (org.apache.jackrabbit.core.data.DataStoreException)10 CloudBlockBlob (com.microsoft.azure.storage.blob.CloudBlockBlob)8 InputStream (java.io.InputStream)7 JsonParseException (com.fasterxml.jackson.core.JsonParseException)5 JsonMappingException (com.fasterxml.jackson.databind.JsonMappingException)5 CloudStorageAccount (com.microsoft.azure.storage.CloudStorageAccount)5 CloudBlob (com.microsoft.azure.storage.blob.CloudBlob)5 EOFException (java.io.EOFException)5 InvalidKeyException (java.security.InvalidKeyException)5 FileAlreadyExistsException (org.apache.hadoop.fs.FileAlreadyExistsException)5 AccessCondition (com.microsoft.azure.storage.AccessCondition)4 BlobRequestOptions (com.microsoft.azure.storage.blob.BlobRequestOptions)4 CloudBlobClient (com.microsoft.azure.storage.blob.CloudBlobClient)4 CloudBlobContainer (com.microsoft.azure.storage.blob.CloudBlobContainer)4 CloudBlobDirectory (com.microsoft.azure.storage.blob.CloudBlobDirectory)4