ZhengBing520 commented on issue #11311:
URL: https://github.com/apache/skywalking/issues/11311#issuecomment-1711037034
> try adding a `ReentrantLock` and `BoolFlag` for example:
>
> ```java
> @Override
> public void notify(ConfigChangeEvent value) {
> lock.lock();
> try {
> if (value.getEventType().equals(EventType.DELETE)) {
> settingsString = null;
> notify(new Rules());
> } else {
> settingsString = value.getNewValue();
> RulesReader rulesReader = new RulesReader(new
StringReader(value.getNewValue()));
> Rules rules = rulesReader.readRules();
> notify(rules);
> }
> notifiedByDynamicConfig.set(true);
> } finally {
> lock.unlock();
> }
> }
>
> public void notifyBeyondDynamicConfig(Rules newRules) {
> lock.lock();
> try {
> if (notifiedByDynamicConfig.get()) {
> return;
> }
> notify(newRules);
> } finally {
> lock.unlock();
> }
> }
>
> /**
> * Don't invoke before the module finishes start
> */
> private void notify(Rules newRules) {
> ```
This is a great solution, but I have an alternative that doesn't require
using locks. Could you please help me see if it's feasible.
```java
BootstrapFlow(Map<String, ModuleDefine> loadedModules) throws
CycleDependencyException, ModuleNotFoundException {
this.loadedModules = loadedModules;
startupSequence = new ArrayList<>();
makeSequence();
startupSequence.sort(Comparator.comparing(ModuleProvider::priority).reversed());
}
# ModuleProvider.java
/**
* {@code ModuleProvider}s with higher priorities will be started earlier
*
* @return the priority of this {@code ModuleProvider}.
*/
public int priority() {
return 0;
}
# AlarmModuleProvider.java
@Override
public int priority() {
ModuleDefine moduleProviderHolder = (ModuleDefine)
getManager().find(ConfigurationModule.NAME);
return moduleProviderHolder.provider().priority() + 1;
}
```
This piece of code can start successfully locally.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]