1818 */
1919package org .elasticsearch .index .shard ;
2020
21- import org .apache .logging .log4j .Logger ;
2221import org .elasticsearch .common .xcontent .XContentFactory ;
2322import org .elasticsearch .index .engine .Engine ;
2423import org .elasticsearch .index .mapper .DocumentMapperForType ;
3332 */
3433public class TranslogOpToEngineOpConverter {
3534 private final MapperService mapperService ;
36- private final Logger logger ;
3735 private final ShardId shardId ;
3836
39- protected TranslogOpToEngineOpConverter (ShardId shardId , MapperService mapperService , Logger logger ) {
37+ protected TranslogOpToEngineOpConverter (ShardId shardId , MapperService mapperService ) {
4038 this .shardId = shardId ;
4139 this .mapperService = mapperService ;
42- this .logger = logger ;
4340 }
4441
4542 protected DocumentMapperForType docMapper (String type ) {
@@ -49,28 +46,25 @@ protected DocumentMapperForType docMapper(String type) {
4946 public Engine .Operation convertToEngineOp (Translog .Operation operation , Engine .Operation .Origin origin ) {
5047 switch (operation .opType ()) {
5148 case INDEX :
52- Translog .Index index = (Translog .Index ) operation ;
49+ final Translog .Index index = (Translog .Index ) operation ;
5350 // we set canHaveDuplicates to true all the time such that we de-optimze the translog case and ensure that all
5451 // autoGeneratedID docs that are coming from the primary are updated correctly.
55- Engine .Index engineIndex = IndexShard .prepareIndex (docMapper (index .type ()),
52+ final Engine .Index engineIndex = IndexShard .prepareIndex (docMapper (index .type ()),
5653 source (shardId .getIndexName (), index .type (), index .id (), index .source (), XContentFactory .xContentType (index .source ()))
5754 .routing (index .routing ()).parent (index .parent ()), index .seqNo (), index .primaryTerm (),
5855 index .version (), index .versionType ().versionTypeForReplicationAndRecovery (), origin ,
5956 index .getAutoGeneratedIdTimestamp (), true );
6057 return engineIndex ;
6158 case DELETE :
62- Translog .Delete delete = (Translog .Delete ) operation ;
59+ final Translog .Delete delete = (Translog .Delete ) operation ;
6360 final Engine .Delete engineDelete = new Engine .Delete (delete .type (), delete .id (), delete .uid (), delete .seqNo (),
6461 delete .primaryTerm (), delete .version (), delete .versionType ().versionTypeForReplicationAndRecovery (),
6562 origin , System .nanoTime ());
6663 return engineDelete ;
6764 case NO_OP :
6865 final Translog .NoOp noOp = (Translog .NoOp ) operation ;
69- final long seqNo = noOp .seqNo ();
70- final long primaryTerm = noOp .primaryTerm ();
71- final String reason = noOp .reason ();
7266 final Engine .NoOp engineNoOp =
73- new Engine .NoOp (seqNo , primaryTerm , origin , System .nanoTime (), reason );
67+ new Engine .NoOp (noOp . seqNo (), noOp . primaryTerm () , origin , System .nanoTime (), noOp . reason () );
7468 return engineNoOp ;
7569 default :
7670 throw new IllegalStateException ("No operation defined for [" + operation + "]" );
0 commit comments