mirror of https://github.com/apache/lucene.git
SOLR-9071: rename the getters in org.apache.solr.common.util.Pair class
This commit is contained in:
parent
30dd6dd5bc
commit
2bc376c7f5
|
@ -1493,10 +1493,10 @@ public class IndexSchema {
|
||||||
return Stream.of(Handler.values())
|
return Stream.of(Handler.values())
|
||||||
.filter(it -> name == null || it.nameLower.equals(name))
|
.filter(it -> name == null || it.nameLower.equals(name))
|
||||||
.map(it -> new Pair<>(it.realName, it.fun.apply(this)))
|
.map(it -> new Pair<>(it.realName, it.fun.apply(this)))
|
||||||
.filter(it->it.getValue() != null)
|
.filter(it->it.second() != null)
|
||||||
.collect(Collectors.toMap(
|
.collect(Collectors.toMap(
|
||||||
Pair::getKey,
|
Pair::first,
|
||||||
Pair::getValue,
|
Pair::second,
|
||||||
(v1, v2) -> v2,
|
(v1, v2) -> v2,
|
||||||
LinkedHashMap::new));
|
LinkedHashMap::new));
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,8 +101,8 @@ public class TestInjection {
|
||||||
public static boolean injectRandomDelayInCoreCreation() {
|
public static boolean injectRandomDelayInCoreCreation() {
|
||||||
if (randomDelayInCoreCreation != null) {
|
if (randomDelayInCoreCreation != null) {
|
||||||
Pair<Boolean,Integer> pair = parseValue(randomDelayInCoreCreation);
|
Pair<Boolean,Integer> pair = parseValue(randomDelayInCoreCreation);
|
||||||
boolean enabled = pair.getKey();
|
boolean enabled = pair.first();
|
||||||
int chanceIn100 = pair.getValue();
|
int chanceIn100 = pair.second();
|
||||||
if (enabled && RANDOM.nextInt(100) >= (100 - chanceIn100)) {
|
if (enabled && RANDOM.nextInt(100) >= (100 - chanceIn100)) {
|
||||||
int delay = RANDOM.nextInt(randomDelayMaxInCoreCreationInSec);
|
int delay = RANDOM.nextInt(randomDelayMaxInCoreCreationInSec);
|
||||||
log.info("Inject random core creation delay of {}s", delay);
|
log.info("Inject random core creation delay of {}s", delay);
|
||||||
|
@ -119,8 +119,8 @@ public class TestInjection {
|
||||||
public static boolean injectNonGracefullClose(CoreContainer cc) {
|
public static boolean injectNonGracefullClose(CoreContainer cc) {
|
||||||
if (cc.isShutDown() && nonGracefullClose != null) {
|
if (cc.isShutDown() && nonGracefullClose != null) {
|
||||||
Pair<Boolean,Integer> pair = parseValue(nonGracefullClose);
|
Pair<Boolean,Integer> pair = parseValue(nonGracefullClose);
|
||||||
boolean enabled = pair.getKey();
|
boolean enabled = pair.first();
|
||||||
int chanceIn100 = pair.getValue();
|
int chanceIn100 = pair.second();
|
||||||
if (enabled && RANDOM.nextInt(100) >= (100 - chanceIn100)) {
|
if (enabled && RANDOM.nextInt(100) >= (100 - chanceIn100)) {
|
||||||
if (RANDOM.nextBoolean()) {
|
if (RANDOM.nextBoolean()) {
|
||||||
throw new TestShutdownFailError("Test exception for non graceful close");
|
throw new TestShutdownFailError("Test exception for non graceful close");
|
||||||
|
@ -157,8 +157,8 @@ public class TestInjection {
|
||||||
public static boolean injectFailReplicaRequests() {
|
public static boolean injectFailReplicaRequests() {
|
||||||
if (failReplicaRequests != null) {
|
if (failReplicaRequests != null) {
|
||||||
Pair<Boolean,Integer> pair = parseValue(failReplicaRequests);
|
Pair<Boolean,Integer> pair = parseValue(failReplicaRequests);
|
||||||
boolean enabled = pair.getKey();
|
boolean enabled = pair.first();
|
||||||
int chanceIn100 = pair.getValue();
|
int chanceIn100 = pair.second();
|
||||||
if (enabled && RANDOM.nextInt(100) >= (100 - chanceIn100)) {
|
if (enabled && RANDOM.nextInt(100) >= (100 - chanceIn100)) {
|
||||||
throw new SolrException(ErrorCode.SERVER_ERROR, "Random test update fail");
|
throw new SolrException(ErrorCode.SERVER_ERROR, "Random test update fail");
|
||||||
}
|
}
|
||||||
|
@ -170,8 +170,8 @@ public class TestInjection {
|
||||||
public static boolean injectFailUpdateRequests() {
|
public static boolean injectFailUpdateRequests() {
|
||||||
if (failUpdateRequests != null) {
|
if (failUpdateRequests != null) {
|
||||||
Pair<Boolean,Integer> pair = parseValue(failUpdateRequests);
|
Pair<Boolean,Integer> pair = parseValue(failUpdateRequests);
|
||||||
boolean enabled = pair.getKey();
|
boolean enabled = pair.first();
|
||||||
int chanceIn100 = pair.getValue();
|
int chanceIn100 = pair.second();
|
||||||
if (enabled && RANDOM.nextInt(100) >= (100 - chanceIn100)) {
|
if (enabled && RANDOM.nextInt(100) >= (100 - chanceIn100)) {
|
||||||
throw new SolrException(ErrorCode.SERVER_ERROR, "Random test update fail");
|
throw new SolrException(ErrorCode.SERVER_ERROR, "Random test update fail");
|
||||||
}
|
}
|
||||||
|
@ -183,8 +183,8 @@ public class TestInjection {
|
||||||
public static boolean injectNonExistentCoreExceptionAfterUnload(String cname) {
|
public static boolean injectNonExistentCoreExceptionAfterUnload(String cname) {
|
||||||
if (nonExistentCoreExceptionAfterUnload != null) {
|
if (nonExistentCoreExceptionAfterUnload != null) {
|
||||||
Pair<Boolean,Integer> pair = parseValue(nonExistentCoreExceptionAfterUnload);
|
Pair<Boolean,Integer> pair = parseValue(nonExistentCoreExceptionAfterUnload);
|
||||||
boolean enabled = pair.getKey();
|
boolean enabled = pair.first();
|
||||||
int chanceIn100 = pair.getValue();
|
int chanceIn100 = pair.second();
|
||||||
if (enabled && RANDOM.nextInt(100) >= (100 - chanceIn100)) {
|
if (enabled && RANDOM.nextInt(100) >= (100 - chanceIn100)) {
|
||||||
throw new NonExistentCoreException("Core not found to unload: " + cname);
|
throw new NonExistentCoreException("Core not found to unload: " + cname);
|
||||||
}
|
}
|
||||||
|
@ -196,8 +196,8 @@ public class TestInjection {
|
||||||
public static boolean injectUpdateLogReplayRandomPause() {
|
public static boolean injectUpdateLogReplayRandomPause() {
|
||||||
if (updateLogReplayRandomPause != null) {
|
if (updateLogReplayRandomPause != null) {
|
||||||
Pair<Boolean,Integer> pair = parseValue(updateLogReplayRandomPause);
|
Pair<Boolean,Integer> pair = parseValue(updateLogReplayRandomPause);
|
||||||
boolean enabled = pair.getKey();
|
boolean enabled = pair.first();
|
||||||
int chanceIn100 = pair.getValue();
|
int chanceIn100 = pair.second();
|
||||||
if (enabled && RANDOM.nextInt(100) >= (100 - chanceIn100)) {
|
if (enabled && RANDOM.nextInt(100) >= (100 - chanceIn100)) {
|
||||||
long rndTime = RANDOM.nextInt(1000);
|
long rndTime = RANDOM.nextInt(1000);
|
||||||
log.info("inject random log replay delay of {}ms", rndTime);
|
log.info("inject random log replay delay of {}ms", rndTime);
|
||||||
|
@ -215,8 +215,8 @@ public class TestInjection {
|
||||||
public static boolean injectUpdateRandomPause() {
|
public static boolean injectUpdateRandomPause() {
|
||||||
if (updateRandomPause != null) {
|
if (updateRandomPause != null) {
|
||||||
Pair<Boolean,Integer> pair = parseValue(updateRandomPause);
|
Pair<Boolean,Integer> pair = parseValue(updateRandomPause);
|
||||||
boolean enabled = pair.getKey();
|
boolean enabled = pair.first();
|
||||||
int chanceIn100 = pair.getValue();
|
int chanceIn100 = pair.second();
|
||||||
if (enabled && RANDOM.nextInt(100) >= (100 - chanceIn100)) {
|
if (enabled && RANDOM.nextInt(100) >= (100 - chanceIn100)) {
|
||||||
long rndTime = RANDOM.nextInt(1000);
|
long rndTime = RANDOM.nextInt(1000);
|
||||||
log.info("inject random update delay of {}ms", rndTime);
|
log.info("inject random update delay of {}ms", rndTime);
|
||||||
|
|
|
@ -385,8 +385,8 @@ public class ZkStateReader implements Closeable {
|
||||||
if (securityNodeListener != null) {
|
if (securityNodeListener != null) {
|
||||||
addSecuritynodeWatcher(pair -> {
|
addSecuritynodeWatcher(pair -> {
|
||||||
ConfigData cd = new ConfigData();
|
ConfigData cd = new ConfigData();
|
||||||
cd.data = pair.getKey() == null || pair.getKey().length == 0 ? EMPTY_MAP : Utils.getDeepCopy((Map) fromJSON(pair.getKey()), 4, false);
|
cd.data = pair.first() == null || pair.first().length == 0 ? EMPTY_MAP : Utils.getDeepCopy((Map) fromJSON(pair.first()), 4, false);
|
||||||
cd.version = pair.getValue() == null ? -1 : pair.getValue().getVersion();
|
cd.version = pair.second() == null ? -1 : pair.second().getVersion();
|
||||||
securityData = cd;
|
securityData = cd;
|
||||||
securityNodeListener.run();
|
securityNodeListener.run();
|
||||||
});
|
});
|
||||||
|
|
|
@ -17,30 +17,36 @@
|
||||||
package org.apache.solr.common.util;
|
package org.apache.solr.common.util;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
public class Pair<K, V> implements Serializable {
|
public class Pair<T1, T2> implements Serializable {
|
||||||
private K key;
|
private final T1 first;
|
||||||
|
private final T2 second;
|
||||||
|
|
||||||
public K getKey() {
|
public T1 first() {
|
||||||
return key;
|
return first;
|
||||||
}
|
}
|
||||||
|
|
||||||
private V value;
|
public T2 second() {
|
||||||
|
return second;
|
||||||
public K _1() {
|
|
||||||
return key;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public V _2() {
|
public Pair(T1 key, T2 value) {
|
||||||
return value;
|
this.first = key;
|
||||||
|
this.second = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public V getValue() {
|
@Override
|
||||||
return value;
|
public boolean equals(Object obj) {
|
||||||
|
if (obj instanceof Pair) {
|
||||||
|
Pair that = (Pair) obj;
|
||||||
|
return Objects.equals(this.first, that.first) && Objects.equals(this.second, that.second);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Pair(K key, V value) {
|
@Override
|
||||||
this.key = key;
|
public int hashCode() {
|
||||||
this.value = value;
|
return (this.first == null ? 0 : this.first.hashCode()) ^ (this.second == null ? 0 : this.second.hashCode());
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue