代码拉取完成,页面将自动刷新
HystrixPlugins.getInstance().registerConcurrencyStrategy(new MyHystrixConcurrencyStrategy());
具体的spi实现,可以查看hystrix的实现代码:
public HystrixConcurrencyStrategy getConcurrencyStrategy() {
if (concurrencyStrategy.get() == null) {
// check for an implementation from Archaius first
// 1
Object impl = getPluginImplementation(HystrixConcurrencyStrategy.class);
if (impl == null) {
// nothing set via Archaius so initialize with default
concurrencyStrategy.compareAndSet(null, HystrixConcurrencyStrategyDefault.getInstance());
// we don't return from here but call get() again in case of thread-race so the winner will always get returned
} else {
// we received an implementation from Archaius so use it
concurrencyStrategy.compareAndSet(null, (HystrixConcurrencyStrategy) impl);
}
}
return concurrencyStrategy.get();
}
上图,1处,会去查找实现类:
private <T> T getPluginImplementation(Class<T> pluginClass) {
// 1
T p = getPluginImplementationViaProperties(pluginClass, dynamicProperties);
if (p != null) return p;
// 2
return findService(pluginClass, classLoader);
}
如上,1处,会去动态属性中获取,这个动态属性,怎么动态呢?具体的了解不多,如果集成了Netflix Archaius组件,Netflix Archaius 可以动态修改属性,然后这里就能感知到。 如果1处查找失败,会去2处查找,2处就是jdk的spi机制,也是我们demo中使用的方式。
关于插件相关的东西,更多可以查看: https://github.com/Netflix/Hystrix/wiki/Plugins
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。