@@ -112,27 +112,35 @@ public static boolean blobExists(BlobContainer container, String blobName) throw
112
112
* of this assertion must pass an executor on those when using such an implementation.
113
113
*/
114
114
public static void assertConsistency (BlobStoreRepository repository , Executor executor ) {
115
- final PlainActionFuture <Void > listener = PlainActionFuture .newFuture ();
116
- executor .execute (ActionRunnable .run (listener , () -> {
117
- final BlobContainer blobContainer = repository .blobContainer ();
118
- final long latestGen ;
119
- try (DataInputStream inputStream = new DataInputStream (blobContainer .readBlob ("index.latest" ))) {
120
- latestGen = inputStream .readLong ();
121
- } catch (NoSuchFileException e ) {
122
- throw new AssertionError ("Could not find index.latest blob for repo [" + repository + "]" );
123
- }
124
- assertIndexGenerations (blobContainer , latestGen );
125
- final RepositoryData repositoryData ;
126
- try (InputStream blob = blobContainer .readBlob ("index-" + latestGen );
127
- XContentParser parser = XContentType .JSON .xContent ().createParser (NamedXContentRegistry .EMPTY ,
128
- LoggingDeprecationHandler .INSTANCE , blob )) {
129
- repositoryData = RepositoryData .snapshotsFromXContent (parser , latestGen );
115
+ final PlainActionFuture <AssertionError > listener = PlainActionFuture .newFuture ();
116
+ executor .execute (ActionRunnable .supply (listener , () -> {
117
+ try {
118
+ final BlobContainer blobContainer = repository .blobContainer ();
119
+ final long latestGen ;
120
+ try (DataInputStream inputStream = new DataInputStream (blobContainer .readBlob ("index.latest" ))) {
121
+ latestGen = inputStream .readLong ();
122
+ } catch (NoSuchFileException e ) {
123
+ throw new AssertionError ("Could not find index.latest blob for repo [" + repository + "]" );
124
+ }
125
+ assertIndexGenerations (blobContainer , latestGen );
126
+ final RepositoryData repositoryData ;
127
+ try (InputStream blob = blobContainer .readBlob ("index-" + latestGen );
128
+ XContentParser parser = XContentType .JSON .xContent ().createParser (NamedXContentRegistry .EMPTY ,
129
+ LoggingDeprecationHandler .INSTANCE , blob )) {
130
+ repositoryData = RepositoryData .snapshotsFromXContent (parser , latestGen );
131
+ }
132
+ assertIndexUUIDs (blobContainer , repositoryData );
133
+ assertSnapshotUUIDs (repository , repositoryData );
134
+ assertShardIndexGenerations (blobContainer , repositoryData .shardGenerations ());
135
+ return null ;
136
+ } catch (AssertionError e ) {
137
+ return e ;
130
138
}
131
- assertIndexUUIDs (blobContainer , repositoryData );
132
- assertSnapshotUUIDs (repository , repositoryData );
133
- assertShardIndexGenerations (blobContainer , repositoryData .shardGenerations ());
134
139
}));
135
- listener .actionGet (TimeValue .timeValueMinutes (1L ));
140
+ final AssertionError err = listener .actionGet (TimeValue .timeValueMinutes (1L ));
141
+ if (err != null ) {
142
+ throw new AssertionError (err );
143
+ }
136
144
}
137
145
138
146
private static void assertIndexGenerations (BlobContainer repoRoot , long latestGen ) throws IOException {
0 commit comments