Search in sources :

Example 16 with RepositoryException

use of org.elasticsearch.repositories.RepositoryException in project elasticsearch by elastic.

the class BlobStoreRepository method finalizeSnapshot.

/**
     * {@inheritDoc}
     */
@Override
public SnapshotInfo finalizeSnapshot(final SnapshotId snapshotId, final List<IndexId> indices, final long startTime, final String failure, final int totalShards, final List<SnapshotShardFailure> shardFailures, final long repositoryStateId) {
    try {
        SnapshotInfo blobStoreSnapshot = new SnapshotInfo(snapshotId, indices.stream().map(IndexId::getName).collect(Collectors.toList()), startTime, failure, System.currentTimeMillis(), totalShards, shardFailures);
        snapshotFormat.write(blobStoreSnapshot, snapshotsBlobContainer, snapshotId.getUUID());
        final RepositoryData repositoryData = getRepositoryData();
        List<SnapshotId> snapshotIds = repositoryData.getSnapshotIds();
        if (!snapshotIds.contains(snapshotId)) {
            writeIndexGen(repositoryData.addSnapshot(snapshotId, indices), repositoryStateId);
        }
        return blobStoreSnapshot;
    } catch (IOException ex) {
        throw new RepositoryException(metadata.name(), "failed to update snapshot in repository", ex);
    }
}
Also used : IndexId(org.elasticsearch.repositories.IndexId) SnapshotId(org.elasticsearch.snapshots.SnapshotId) SnapshotInfo(org.elasticsearch.snapshots.SnapshotInfo) RepositoryException(org.elasticsearch.repositories.RepositoryException) IOException(java.io.IOException) RepositoryData(org.elasticsearch.repositories.RepositoryData)

Example 17 with RepositoryException

use of org.elasticsearch.repositories.RepositoryException in project elasticsearch by elastic.

the class URLRepositoryTests method testMustBeSupportedProtocol.

public void testMustBeSupportedProtocol() throws IOException {
    Path directory = createTempDir();
    String repoPath = directory.resolve("repository").toUri().toURL().toString();
    Settings baseSettings = Settings.builder().put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString()).put(Environment.PATH_REPO_SETTING.getKey(), directory.toString()).put(URLRepository.REPOSITORIES_URL_SETTING.getKey(), repoPath).put(URLRepository.SUPPORTED_PROTOCOLS_SETTING.getKey(), "http,https").build();
    RepositoryMetaData repositoryMetaData = new RepositoryMetaData("url", URLRepository.TYPE, baseSettings);
    try {
        new URLRepository(repositoryMetaData, new Environment(baseSettings), new NamedXContentRegistry(Collections.emptyList()));
        fail("RepositoryException should have been thrown.");
    } catch (RepositoryException e) {
        assertEquals("[url] unsupported url protocol [file] from URL [" + repoPath + "]", e.getMessage());
    }
}
Also used : Path(java.nio.file.Path) RepositoryMetaData(org.elasticsearch.cluster.metadata.RepositoryMetaData) Environment(org.elasticsearch.env.Environment) RepositoryException(org.elasticsearch.repositories.RepositoryException) NamedXContentRegistry(org.elasticsearch.common.xcontent.NamedXContentRegistry) Settings(org.elasticsearch.common.settings.Settings)

Example 18 with RepositoryException

use of org.elasticsearch.repositories.RepositoryException in project elasticsearch by elastic.

the class ExceptionSerializationTests method testRepositoryException.

public void testRepositoryException() throws IOException {
    RepositoryException ex = serialize(new RepositoryException("repo", "msg"));
    assertEquals("repo", ex.repository());
    assertEquals("[repo] msg", ex.getMessage());
    ex = serialize(new RepositoryException(null, "msg"));
    assertNull(ex.repository());
    assertEquals("[_na] msg", ex.getMessage());
}
Also used : RepositoryException(org.elasticsearch.repositories.RepositoryException)

Example 19 with RepositoryException

use of org.elasticsearch.repositories.RepositoryException in project elasticsearch by elastic.

the class AzureStorageServiceImpl method createContainer.

@Override
public void createContainer(String account, LocationMode mode, String container) throws URISyntaxException, StorageException {
    try {
        CloudBlobClient client = this.getSelectedClient(account, mode);
        CloudBlobContainer blobContainer = client.getContainerReference(container);
        logger.trace("creating container [{}]", container);
        SocketAccess.doPrivilegedException(blobContainer::createIfNotExists);
    } catch (IllegalArgumentException e) {
        logger.trace((Supplier<?>) () -> new ParameterizedMessage("fails creating container [{}]", container), e);
        throw new RepositoryException(container, e.getMessage(), e);
    }
}
Also used : CloudBlobClient(com.microsoft.azure.storage.blob.CloudBlobClient) CloudBlobContainer(com.microsoft.azure.storage.blob.CloudBlobContainer) Supplier(org.apache.logging.log4j.util.Supplier) ParameterizedMessage(org.apache.logging.log4j.message.ParameterizedMessage) RepositoryException(org.elasticsearch.repositories.RepositoryException)

Example 20 with RepositoryException

use of org.elasticsearch.repositories.RepositoryException in project crate by crate.

the class BlobStoreRepository method deleteSnapshot.

@Override
public void deleteSnapshot(SnapshotId snapshotId, long repositoryStateId, boolean writeShardGens, ActionListener<Void> listener) {
    if (isReadOnly()) {
        listener.onFailure(new RepositoryException(metadata.name(), "cannot delete snapshot from a readonly repository"));
    } else {
        final long latestKnownGen = latestKnownRepoGen.get();
        if (latestKnownGen > repositoryStateId) {
            listener.onFailure(new ConcurrentSnapshotExecutionException(new Snapshot(metadata.name(), snapshotId), "Another concurrent operation moved repo generation to [ " + latestKnownGen + "] but this delete assumed generation [" + repositoryStateId + "]"));
            return;
        }
        try {
            final Map<String, BlobMetadata> rootBlobs = blobContainer().listBlobs();
            final RepositoryData repositoryData = safeRepositoryData(repositoryStateId, rootBlobs);
            // Cache the indices that were found before writing out the new index-N blob so that a stuck master will never
            // delete an index that was created by another master node after writing this index-N blob.
            final Map<String, BlobContainer> foundIndices = blobStore().blobContainer(indicesPath()).children();
            doDeleteShardSnapshots(snapshotId, repositoryStateId, foundIndices, rootBlobs, repositoryData, writeShardGens, listener);
        } catch (Exception ex) {
            listener.onFailure(new RepositoryException(metadata.name(), "failed to delete snapshot [" + snapshotId + "]", ex));
        }
    }
}
Also used : BlobStoreIndexShardSnapshot(org.elasticsearch.index.snapshots.blobstore.BlobStoreIndexShardSnapshot) Snapshot(org.elasticsearch.snapshots.Snapshot) BlobMetadata(org.elasticsearch.common.blobstore.BlobMetadata) BlobContainer(org.elasticsearch.common.blobstore.BlobContainer) FsBlobContainer(org.elasticsearch.common.blobstore.fs.FsBlobContainer) ConcurrentSnapshotExecutionException(org.elasticsearch.snapshots.ConcurrentSnapshotExecutionException) RepositoryException(org.elasticsearch.repositories.RepositoryException) IndexShardSnapshotFailedException(org.elasticsearch.index.snapshots.IndexShardSnapshotFailedException) IndexFormatTooNewException(org.apache.lucene.index.IndexFormatTooNewException) InvalidArgumentException(io.crate.exceptions.InvalidArgumentException) SnapshotException(org.elasticsearch.snapshots.SnapshotException) IOException(java.io.IOException) SnapshotMissingException(org.elasticsearch.snapshots.SnapshotMissingException) NoSuchFileException(java.nio.file.NoSuchFileException) ConcurrentSnapshotExecutionException(org.elasticsearch.snapshots.ConcurrentSnapshotExecutionException) CorruptIndexException(org.apache.lucene.index.CorruptIndexException) IndexShardRestoreFailedException(org.elasticsearch.index.snapshots.IndexShardRestoreFailedException) RepositoryException(org.elasticsearch.repositories.RepositoryException) NotXContentException(org.elasticsearch.common.compress.NotXContentException) IndexShardSnapshotException(org.elasticsearch.index.snapshots.IndexShardSnapshotException) RepositoryVerificationException(org.elasticsearch.repositories.RepositoryVerificationException) IndexFormatTooOldException(org.apache.lucene.index.IndexFormatTooOldException) RepositoryData(org.elasticsearch.repositories.RepositoryData)

Aggregations

RepositoryException (org.elasticsearch.repositories.RepositoryException)24 IOException (java.io.IOException)9 RepositoryData (org.elasticsearch.repositories.RepositoryData)8 IndexId (org.elasticsearch.repositories.IndexId)6 NoSuchFileException (java.nio.file.NoSuchFileException)5 ParameterizedMessage (org.apache.logging.log4j.message.ParameterizedMessage)5 ActionListener (org.elasticsearch.action.ActionListener)5 ClusterState (org.elasticsearch.cluster.ClusterState)5 IndexShardSnapshotException (org.elasticsearch.index.snapshots.IndexShardSnapshotException)4 SnapshotException (org.elasticsearch.snapshots.SnapshotException)4 SnapshotMissingException (org.elasticsearch.snapshots.SnapshotMissingException)4 InvalidArgumentException (io.crate.exceptions.InvalidArgumentException)3 CorruptIndexException (org.apache.lucene.index.CorruptIndexException)3 IndexFormatTooNewException (org.apache.lucene.index.IndexFormatTooNewException)3 IndexFormatTooOldException (org.apache.lucene.index.IndexFormatTooOldException)3 RepositoryMetaData (org.elasticsearch.cluster.metadata.RepositoryMetaData)3 DiscoveryNode (org.elasticsearch.cluster.node.DiscoveryNode)3 BlobContainer (org.elasticsearch.common.blobstore.BlobContainer)3 BytesReference (org.elasticsearch.common.bytes.BytesReference)3 NotXContentException (org.elasticsearch.common.compress.NotXContentException)3