Bläddra i källkod

Add returning modified status of `updateProperty` method in SentinelProperty

Signed-off-by: Eric Zhao <sczyh16@gmail.com>
master
Eric Zhao 5 år sedan
förälder
incheckning
8d84349607
3 ändrade filer med 9 tillägg och 5 borttagningar
  1. +3
    -3
      sentinel-core/src/main/java/com/alibaba/csp/sentinel/property/DynamicSentinelProperty.java
  2. +4
    -1
      sentinel-core/src/main/java/com/alibaba/csp/sentinel/property/NoOpSentinelProperty.java
  3. +2
    -1
      sentinel-core/src/main/java/com/alibaba/csp/sentinel/property/SentinelProperty.java

+ 3
- 3
sentinel-core/src/main/java/com/alibaba/csp/sentinel/property/DynamicSentinelProperty.java Visa fil

@@ -46,9 +46,9 @@ public class DynamicSentinelProperty<T> implements SentinelProperty<T> {
} }


@Override @Override
public void updateValue(T newValue) {
public boolean updateValue(T newValue) {
if (isEqual(value, newValue)) { if (isEqual(value, newValue)) {
return;
return false;
} }
RecordLog.info("[DynamicSentinelProperty] Config will be updated to: " + newValue); RecordLog.info("[DynamicSentinelProperty] Config will be updated to: " + newValue);


@@ -56,7 +56,7 @@ public class DynamicSentinelProperty<T> implements SentinelProperty<T> {
for (PropertyListener<T> listener : listeners) { for (PropertyListener<T> listener : listeners) {
listener.configUpdate(newValue); listener.configUpdate(newValue);
} }
return true;
} }


private boolean isEqual(T oldValue, T newValue) { private boolean isEqual(T oldValue, T newValue) {


+ 4
- 1
sentinel-core/src/main/java/com/alibaba/csp/sentinel/property/NoOpSentinelProperty.java Visa fil

@@ -21,6 +21,7 @@ package com.alibaba.csp.sentinel.property;
* @author leyou * @author leyou
*/ */
public final class NoOpSentinelProperty implements SentinelProperty<Object> { public final class NoOpSentinelProperty implements SentinelProperty<Object> {

@Override @Override
public void addListener(PropertyListener<Object> listener) { } public void addListener(PropertyListener<Object> listener) { }


@@ -28,5 +29,7 @@ public final class NoOpSentinelProperty implements SentinelProperty<Object> {
public void removeListener(PropertyListener<Object> listener) { } public void removeListener(PropertyListener<Object> listener) { }


@Override @Override
public void updateValue(Object newValue) { }
public boolean updateValue(Object newValue) {
return true;
}
} }

+ 2
- 1
sentinel-core/src/main/java/com/alibaba/csp/sentinel/property/SentinelProperty.java Visa fil

@@ -56,6 +56,7 @@ public interface SentinelProperty<T> {
* added on this only when new {@code newValue} is not Equals to the old value. * added on this only when new {@code newValue} is not Equals to the old value.
* *
* @param newValue the new value. * @param newValue the new value.
* @return true if the value in property has been updated, otherwise false
*/ */
void updateValue(T newValue);
boolean updateValue(T newValue);
} }

Laddar…
Avbryt
Spara