From 2d1b4f58d3fb3bb75be1648977c1551aef592296 Mon Sep 17 00:00:00 2001 From: Aggelos Avgerinos Date: Wed, 5 Aug 2020 14:00:02 +0300 Subject: [PATCH] Make SwiftRepository aware of ClusterState SwiftRepository extends BlobStoreRepository which, as of this commit[1], is aware of the ClusterState. This was done to facilitate this change[2]. [1]: https://github.com/elastic/elasticsearch/commit/459d8edcc083454d75b04254effa9118157e9c0a [2]: https://github.com/elastic/elasticsearch/pull/49060 --- .../elasticsearch/swift/SwiftRepositoryPlugin.java | 7 +++++-- .../elasticsearch/swift/repositories/SwiftRepository.java | 8 ++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/wikimedia/elasticsearch/swift/SwiftRepositoryPlugin.java b/src/main/java/org/wikimedia/elasticsearch/swift/SwiftRepositoryPlugin.java index 0281d44..a6da47e 100644 --- a/src/main/java/org/wikimedia/elasticsearch/swift/SwiftRepositoryPlugin.java +++ b/src/main/java/org/wikimedia/elasticsearch/swift/SwiftRepositoryPlugin.java @@ -19,6 +19,7 @@ import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.NamedXContentRegistry; +import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.env.Environment; import org.elasticsearch.plugins.Plugin; import org.elasticsearch.plugins.RepositoryPlugin; @@ -41,9 +42,11 @@ protected SwiftService createStorageService(Settings settings) { } @Override - public Map getRepositories(Environment env, NamedXContentRegistry namedXContentRegistry) { + public Map getRepositories(Environment env, NamedXContentRegistry namedXContentRegistry, + ClusterService clusterService) { return Collections.singletonMap(SwiftRepository.TYPE, - (metadata) -> new SwiftRepository(metadata, env.settings(), namedXContentRegistry, createStorageService(env.settings()))); + (metadata) -> new SwiftRepository(metadata, env.settings(), namedXContentRegistry, createStorageService(env.settings()), + clusterService)); } @Override diff --git a/src/main/java/org/wikimedia/elasticsearch/swift/repositories/SwiftRepository.java b/src/main/java/org/wikimedia/elasticsearch/swift/repositories/SwiftRepository.java index 1817dec..fbc96fe 100644 --- a/src/main/java/org/wikimedia/elasticsearch/swift/repositories/SwiftRepository.java +++ b/src/main/java/org/wikimedia/elasticsearch/swift/repositories/SwiftRepository.java @@ -17,6 +17,7 @@ package org.wikimedia.elasticsearch.swift.repositories; import org.elasticsearch.cluster.metadata.RepositoryMetaData; +import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.blobstore.BlobPath; import org.elasticsearch.common.blobstore.BlobStore; import org.elasticsearch.common.inject.Inject; @@ -86,11 +87,14 @@ public interface Swift { * an instance of NamedXContentRegistry * @param swiftService * an instance of SwiftService + * @param clusterService + * an instance of ClusterService */ @Inject public SwiftRepository(RepositoryMetaData metadata, Settings settings, - NamedXContentRegistry namedXContentRegistry, SwiftService swiftService) { - super(metadata, settings, namedXContentRegistry); + NamedXContentRegistry namedXContentRegistry, SwiftService swiftService, + ClusterService clusterService) { + super(metadata, settings, namedXContentRegistry, clusterService); this.settings = settings; this.swiftService = swiftService; this.chunkSize = Swift.CHUNK_SIZE_SETTING.get(metadata.settings());