Fix shard ID logging in DWSDIT#testAckedIndexing
This commit fixes a minor issue with the shard ID that is logged while indexing in DiscoveryWithServiceDisruptionsIT#testAckedIndexing. The issue is that the operation routing hash could lead to a negative remainder modulo the number of primaries (if the hash itself is negative) but should instead be the normalized positive remainder. This issue only impacts the logging of the shard ID as the actual shard ID used during indexing is computed elsewhere but would cause the shard ID in the affected logging statement to not match shard IDs that are logged elsewhere.
This commit is contained in:
parent
24ac9506bd
commit
7de8d2881b
|
@ -45,6 +45,7 @@ import org.elasticsearch.common.Nullable;
|
|||
import org.elasticsearch.common.Priority;
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.collect.Tuple;
|
||||
import org.elasticsearch.common.math.MathUtils;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.discovery.zen.ZenDiscovery;
|
||||
|
@ -465,7 +466,7 @@ public class DiscoveryWithServiceDisruptionsIT extends ESIntegTestCase {
|
|||
logger.info("[{}] Acquired semaphore and it has {} permits left", name, semaphore.availablePermits());
|
||||
try {
|
||||
id = Integer.toString(idGenerator.incrementAndGet());
|
||||
int shard = Murmur3HashFunction.hash(id) % numPrimaries;
|
||||
int shard = MathUtils.mod(Murmur3HashFunction.hash(id), numPrimaries);
|
||||
logger.trace("[{}] indexing id [{}] through node [{}] targeting shard [{}]", name, id, node, shard);
|
||||
IndexResponse response = client.prepareIndex("test", "type", id).setSource("{}").setTimeout("1s").get();
|
||||
assertThat(response.getVersion(), equalTo(1l));
|
||||
|
|
Loading…
Reference in New Issue