Browse Source

Add returning modified status of `updateProperty` method in SentinelProperty

Signed-off-by: Eric Zhao <sczyh16@gmail.com>
master
Eric Zhao 5 years ago
parent
commit
8d84349607
3 changed files with 9 additions and 5 deletions
  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 View File

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

@Override
public void updateValue(T newValue) {
public boolean updateValue(T newValue) {
if (isEqual(value, newValue)) {
return;
return false;
}
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) {
listener.configUpdate(newValue);
}
return true;
}

private boolean isEqual(T oldValue, T newValue) {


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

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

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

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

@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 View File

@@ -56,6 +56,7 @@ public interface SentinelProperty<T> {
* added on this only when new {@code newValue} is not Equals to the old 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);
}

Loading…
Cancel
Save