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:
Simon Willnauer 2014-05-16 14:03:18 +02:00
parent 9a9cc0b8e4
commit eef505ed51
2 changed files with 5 additions and 5 deletions

View File

@ -69,6 +69,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.atomic.AtomicLong;
import static com.google.common.collect.Maps.newHashMap;
import static org.elasticsearch.ExceptionsHelper.detailedMessage;
@ -108,6 +109,7 @@ public class IndicesClusterStateService extends AbstractLifecycleComponent<Indic
private final FailedEngineHandler failedEngineHandler = new FailedEngineHandler();
private final boolean sendRefreshMapping;
private final AtomicLong recoveryIdGenerator = new AtomicLong();
@Inject
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;
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));
} catch (Throwable e) {

View File

@ -36,8 +36,6 @@ import java.util.concurrent.atomic.AtomicLong;
*/
public class StartRecoveryRequest extends TransportRequest {
private static final AtomicLong recoveryIdGenerator = new AtomicLong();
private long recoveryId;
private ShardId shardId;
@ -65,8 +63,8 @@ public class StartRecoveryRequest extends TransportRequest {
* @param existingFiles
*/
public StartRecoveryRequest(ShardId shardId, DiscoveryNode sourceNode, DiscoveryNode targetNode, boolean markAsRelocated, Map<String,
StoreFileMetaData> existingFiles, RecoveryState.Type recoveryType) {
this.recoveryId = recoveryIdGenerator.incrementAndGet();
StoreFileMetaData> existingFiles, RecoveryState.Type recoveryType, long recoveryId) {
this.recoveryId = recoveryId;
this.shardId = shardId;
this.sourceNode = sourceNode;
this.targetNode = targetNode;