Search in sources :

Example 1 with FsRepository

use of org.elasticsearch.repositories.fs.FsRepository in project crate by crate.

the class BlobStoreRepositoryRestoreTests method createRepository.

/**
 * Create a {@link Repository} with a random name *
 */
private Repository createRepository() {
    Settings settings = Settings.builder().put("location", randomAlphaOfLength(10)).build();
    RepositoryMetadata repositoryMetadata = new RepositoryMetadata(randomAlphaOfLength(10), FsRepository.TYPE, settings);
    final ClusterService clusterService = BlobStoreTestUtil.mockClusterService(repositoryMetadata);
    final FsRepository repository = new FsRepository(repositoryMetadata, createEnvironment(), xContentRegistry(), clusterService) {

        @Override
        protected void assertSnapshotOrGenericThread() {
        // eliminate thread name check as we create repo manually
        }
    };
    clusterService.addStateApplier(event -> repository.updateState(event.state()));
    // Apply state once to initialize repo properly like RepositoriesService would
    repository.updateState(clusterService.state());
    repository.start();
    return repository;
}
Also used : ClusterService(org.elasticsearch.cluster.service.ClusterService) RepositoryMetadata(org.elasticsearch.cluster.metadata.RepositoryMetadata) Settings(org.elasticsearch.common.settings.Settings) FsRepository(org.elasticsearch.repositories.fs.FsRepository)

Aggregations

RepositoryMetadata (org.elasticsearch.cluster.metadata.RepositoryMetadata)1 ClusterService (org.elasticsearch.cluster.service.ClusterService)1 Settings (org.elasticsearch.common.settings.Settings)1 FsRepository (org.elasticsearch.repositories.fs.FsRepository)1