|
19 | 19 | import org.opensearch.common.settings.Setting;
|
20 | 20 | import org.opensearch.repositories.RepositoriesService;
|
21 | 21 | import org.opensearch.repositories.Repository;
|
22 |
| -import org.opensearch.repositories.RepositoryVerificationException; |
23 | 22 | import org.opensearch.threadpool.ThreadPool;
|
24 | 23 |
|
25 | 24 | import java.util.ArrayList;
|
26 | 25 | import java.util.Collections;
|
27 | 26 | import java.util.List;
|
28 | 27 | import java.util.Locale;
|
29 |
| -import java.util.concurrent.CountDownLatch; |
30 |
| -import java.util.concurrent.TimeUnit; |
31 | 28 | import java.util.function.Supplier;
|
32 | 29 |
|
33 | 30 | /**
|
@@ -87,50 +84,11 @@ public RemoteStoreService(Supplier<RepositoriesService> repositoriesService, Thr
|
87 | 84 | * repository mentioned. This verification will happen on a local node to validate if the node is able to connect
|
88 | 85 | * to the repository.
|
89 | 86 | */
|
90 |
| - public void verifyRepository(List<Repository> repositories, DiscoveryNode localNode) { |
91 |
| - /* |
| 87 | + public void verifyRepositoriesLocally(List<Repository> repositories, DiscoveryNode localNode) { |
92 | 88 | for (Repository repository : repositories) {
|
93 |
| - String verificationToken = repository.startVerification(); |
94 | 89 | String repositoryName = repository.getMetadata().name();
|
95 |
| - try { |
96 |
| - repository.verify(verificationToken, localNode); |
97 |
| - logger.info(() -> new ParameterizedMessage("successfully verified [{}] repository", repositoryName)); |
98 |
| - } catch (Exception e) { |
99 |
| - logger.warn(() -> new ParameterizedMessage("[{}] failed to verify repository", repository), e); |
100 |
| - throw new RepositoryVerificationException(repositoryName, e.getMessage()); |
101 |
| - } |
102 |
| - } |
103 |
| - Replace the below code with this once #9088 is merged. |
104 |
| - */ |
105 |
| - |
106 |
| - for (Repository repository : repositories) { |
107 |
| - String verificationToken = repository.startVerification(); |
108 |
| - String repositoryName = repository.getMetadata().name(); |
109 |
| - CountDownLatch repositoryVerificationLatch = new CountDownLatch(1); |
110 |
| - threadPool.executor(ThreadPool.Names.GENERIC).execute(() -> { |
111 |
| - try { |
112 |
| - repository.verify(verificationToken, localNode); |
113 |
| - logger.info(() -> new ParameterizedMessage("successfully verified [{}] repository", repositoryName)); |
114 |
| - repositoryVerificationLatch.countDown(); |
115 |
| - } catch (Exception e) { |
116 |
| - logger.warn(() -> new ParameterizedMessage("[{}] failed to verify repository", repository), e); |
117 |
| - throw new RepositoryVerificationException(repositoryName, e.getMessage()); |
118 |
| - } |
119 |
| - }); |
120 |
| - |
121 |
| - // TODO: See if using listener here which is async makes sense, made this sync as |
122 |
| - // we need the repository registration for remote store backed node to be completed before the |
123 |
| - // bootstrap completes. |
124 |
| - try { |
125 |
| - if (repositoryVerificationLatch.await(1000, TimeUnit.MILLISECONDS) == false) { |
126 |
| - throw new RepositoryVerificationException( |
127 |
| - repository.getMetadata().name(), |
128 |
| - "could not complete " + "repository verification within timeout." |
129 |
| - ); |
130 |
| - } |
131 |
| - } catch (InterruptedException e) { |
132 |
| - throw new RepositoryVerificationException(repository.getMetadata().name(), e.getMessage()); |
133 |
| - } |
| 90 | + repository.verifyLocally(localNode); |
| 91 | + logger.info(() -> new ParameterizedMessage("successfully verified [{}] repository", repositoryName)); |
134 | 92 | }
|
135 | 93 | }
|
136 | 94 |
|
|
0 commit comments