24
24
import org .apache .lucene .index .SegmentInfos ;
25
25
import org .elasticsearch .ElasticsearchException ;
26
26
import org .elasticsearch .ExceptionsHelper ;
27
+ import org .elasticsearch .cluster .action .index .MappingUpdatedAction ;
27
28
import org .elasticsearch .common .inject .Inject ;
28
29
import org .elasticsearch .common .io .stream .InputStreamStreamInput ;
29
30
import org .elasticsearch .common .lucene .Lucene ;
30
31
import org .elasticsearch .common .settings .Settings ;
31
32
import org .elasticsearch .common .unit .TimeValue ;
33
+ import org .elasticsearch .index .engine .Engine ;
32
34
import org .elasticsearch .index .gateway .IndexShardGateway ;
33
35
import org .elasticsearch .index .gateway .IndexShardGatewayRecoveryException ;
36
+ import org .elasticsearch .index .service .IndexService ;
34
37
import org .elasticsearch .index .settings .IndexSettings ;
35
38
import org .elasticsearch .index .shard .AbstractIndexShardComponent ;
36
39
import org .elasticsearch .index .shard .IndexShardState ;
57
60
public class LocalIndexShardGateway extends AbstractIndexShardComponent implements IndexShardGateway {
58
61
59
62
private final ThreadPool threadPool ;
60
-
63
+ private final MappingUpdatedAction mappingUpdatedAction ;
64
+ private final IndexService indexService ;
61
65
private final InternalIndexShard indexShard ;
62
66
63
67
private final RecoveryState recoveryState = new RecoveryState ();
@@ -66,9 +70,12 @@ public class LocalIndexShardGateway extends AbstractIndexShardComponent implemen
66
70
private final TimeValue syncInterval ;
67
71
68
72
@ Inject
69
- public LocalIndexShardGateway (ShardId shardId , @ IndexSettings Settings indexSettings , ThreadPool threadPool , IndexShard indexShard ) {
73
+ public LocalIndexShardGateway (ShardId shardId , @ IndexSettings Settings indexSettings , ThreadPool threadPool , MappingUpdatedAction mappingUpdatedAction ,
74
+ IndexService indexService , IndexShard indexShard ) {
70
75
super (shardId , indexSettings );
71
76
this .threadPool = threadPool ;
77
+ this .mappingUpdatedAction = mappingUpdatedAction ;
78
+ this .indexService = indexService ;
72
79
this .indexShard = (InternalIndexShard ) indexShard ;
73
80
74
81
syncInterval = componentSettings .getAsTime ("sync" , TimeValue .timeValueSeconds (5 ));
@@ -224,7 +231,10 @@ public void recover(boolean indexShouldExists, RecoveryState recoveryState) thro
224
231
break ;
225
232
}
226
233
try {
227
- indexShard .performRecoveryOperation (operation );
234
+ Engine .IndexingOperation potentialIndexOperation = indexShard .performRecoveryOperation (operation );
235
+ if (potentialIndexOperation != null ) {
236
+ mappingUpdatedAction .updateMappingOnMaster (indexService .index ().name (), potentialIndexOperation .docMapper (), indexService .indexUUID ());
237
+ }
228
238
recoveryState .getTranslog ().addTranslogOperations (1 );
229
239
} catch (ElasticsearchException e ) {
230
240
if (e .status () == RestStatus .BAD_REQUEST ) {
0 commit comments