RecoveryID should not be a per JVM but per Node
Today the RecovyerID is taken from a static atomic long which is essentially a per JVM ID. We run the tests within the same JVM and that means we don't really simulate what happens in production environments. Instead we should use a per node generated ID.
This commit is contained in:
parent
9a9cc0b8e4
commit
eef505ed51
|
@ -69,6 +69,7 @@ import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentMap;
|
import java.util.concurrent.ConcurrentMap;
|
||||||
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
|
|
||||||
import static com.google.common.collect.Maps.newHashMap;
|
import static com.google.common.collect.Maps.newHashMap;
|
||||||
import static org.elasticsearch.ExceptionsHelper.detailedMessage;
|
import static org.elasticsearch.ExceptionsHelper.detailedMessage;
|
||||||
|
@ -108,6 +109,7 @@ public class IndicesClusterStateService extends AbstractLifecycleComponent<Indic
|
||||||
private final FailedEngineHandler failedEngineHandler = new FailedEngineHandler();
|
private final FailedEngineHandler failedEngineHandler = new FailedEngineHandler();
|
||||||
|
|
||||||
private final boolean sendRefreshMapping;
|
private final boolean sendRefreshMapping;
|
||||||
|
private final AtomicLong recoveryIdGenerator = new AtomicLong();
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public IndicesClusterStateService(Settings settings, IndicesService indicesService, ClusterService clusterService,
|
public IndicesClusterStateService(Settings settings, IndicesService indicesService, ClusterService clusterService,
|
||||||
|
@ -711,7 +713,7 @@ public class IndicesClusterStateService extends AbstractLifecycleComponent<Indic
|
||||||
|
|
||||||
RecoveryState.Type type = shardRouting.primary() ? RecoveryState.Type.RELOCATION : RecoveryState.Type.REPLICA;
|
RecoveryState.Type type = shardRouting.primary() ? RecoveryState.Type.RELOCATION : RecoveryState.Type.REPLICA;
|
||||||
final StartRecoveryRequest request = new StartRecoveryRequest(indexShard.shardId(), sourceNode, nodes.localNode(),
|
final StartRecoveryRequest request = new StartRecoveryRequest(indexShard.shardId(), sourceNode, nodes.localNode(),
|
||||||
false, indexShard.store().list(), type);
|
false, indexShard.store().list(), type, recoveryIdGenerator.incrementAndGet());
|
||||||
recoveryTarget.startRecovery(request, indexShard, new PeerRecoveryListener(request, shardRouting, indexService, indexMetaData));
|
recoveryTarget.startRecovery(request, indexShard, new PeerRecoveryListener(request, shardRouting, indexService, indexMetaData));
|
||||||
|
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
|
|
|
@ -36,8 +36,6 @@ import java.util.concurrent.atomic.AtomicLong;
|
||||||
*/
|
*/
|
||||||
public class StartRecoveryRequest extends TransportRequest {
|
public class StartRecoveryRequest extends TransportRequest {
|
||||||
|
|
||||||
private static final AtomicLong recoveryIdGenerator = new AtomicLong();
|
|
||||||
|
|
||||||
private long recoveryId;
|
private long recoveryId;
|
||||||
|
|
||||||
private ShardId shardId;
|
private ShardId shardId;
|
||||||
|
@ -65,8 +63,8 @@ public class StartRecoveryRequest extends TransportRequest {
|
||||||
* @param existingFiles
|
* @param existingFiles
|
||||||
*/
|
*/
|
||||||
public StartRecoveryRequest(ShardId shardId, DiscoveryNode sourceNode, DiscoveryNode targetNode, boolean markAsRelocated, Map<String,
|
public StartRecoveryRequest(ShardId shardId, DiscoveryNode sourceNode, DiscoveryNode targetNode, boolean markAsRelocated, Map<String,
|
||||||
StoreFileMetaData> existingFiles, RecoveryState.Type recoveryType) {
|
StoreFileMetaData> existingFiles, RecoveryState.Type recoveryType, long recoveryId) {
|
||||||
this.recoveryId = recoveryIdGenerator.incrementAndGet();
|
this.recoveryId = recoveryId;
|
||||||
this.shardId = shardId;
|
this.shardId = shardId;
|
||||||
this.sourceNode = sourceNode;
|
this.sourceNode = sourceNode;
|
||||||
this.targetNode = targetNode;
|
this.targetNode = targetNode;
|
||||||
|
|
Loading…
Reference in New Issue