public class MethodInvocationDataSourceKeySelector extends Object implements DataSourceRegistryAware, com.jn.langx.cluster.loadbalance.LoadBalancer<DataSourceKey,com.jn.langx.invocation.MethodInvocation>, DataSourceKeySelector<com.jn.langx.invocation.MethodInvocation>, com.jn.langx.lifecycle.Initializable
| 构造器和说明 |
|---|
MethodInvocationDataSourceKeySelector() |
| 限定符和类型 | 方法和说明 |
|---|---|
static void |
addChoice(DataSourceKey key)
当进入具有 DataSourceKey 定义的方法时调用
|
void |
addNode(DataSourceKey node) |
void |
allocateRouter(String group,
String routerName)
为 group 划分 routers
|
void |
allocateWriteMatcher(String group,
com.jn.langx.invocation.matcher.MethodMatcher methodMatcher) |
static void |
clearChoices()
当离开根方法时调用
|
protected DataSourceKey |
doSelect(com.jn.langx.invocation.MethodInvocation methodInvocation)
指定的group下,选择某个datasource, 返回的是该组下的匹配到的 datasource key
这里面不能去设置CURRENT_SELECTED
|
static com.jn.langx.util.collection.stack.ListableStack<DataSourceKey> |
getChoices() |
static DataSourceKey |
getCurrent() |
MethodDataSourceKeyRegistry |
getDataSourceKeyRegistry() |
DataSourceRegistry |
getDataSourceRegistry() |
List<DataSourceKey> |
getNodes() |
List<DataSourceKey> |
getNodes(com.jn.langx.util.function.Predicate<DataSourceKey> predicate) |
DataSourceKeyRouter |
getRouter(String group) |
boolean |
hasNode(DataSourceKey key) |
void |
init() |
boolean |
isEmpty() |
void |
markDown(DataSourceKey key) |
void |
registerRouter(DataSourceKeyRouter router) |
void |
registerRouter(DataSourceKeyRouter router,
boolean asDefault) |
void |
registerRouters(List<DataSourceKeyRouter> routers) |
static void |
removeChoice(DataSourceKey key)
当离开具有 DataSourceKey 定义的方法时调用
|
static void |
removeCurrent()
在最里层的, 最直接的使用DataSource 的方法调用后执行该方法
|
void |
removeNode(DataSourceKey key) |
DataSourceKey |
select(com.jn.langx.invocation.MethodInvocation methodInvocation)
在真正的调用的地方调用即可
|
static void |
setCurrent(DataSourceKey key)
在最里层的, 最直接的使用DataSource 的方法调用后执行该方法
|
void |
setDataSourceKeyRegistry(MethodDataSourceKeyRegistry dataSourceKeyRegistry) |
void |
setDataSourceRegistry(DataSourceRegistry registry) |
void |
setDefaultRouter(DataSourceKeyRouter router) |
void |
setDefaultWriteOperationMatcher(com.jn.langx.invocation.matcher.MethodMatcher defaultWriteOperationMatcher) |
public void init()
throws com.jn.langx.lifecycle.InitializationException
init 在接口中 com.jn.langx.lifecycle.Initializablecom.jn.langx.lifecycle.InitializationExceptionpublic void setDataSourceRegistry(DataSourceRegistry registry)
setDataSourceRegistry 在接口中 DataSourceRegistryAwarepublic MethodDataSourceKeyRegistry getDataSourceKeyRegistry()
public void setDataSourceKeyRegistry(MethodDataSourceKeyRegistry dataSourceKeyRegistry)
public void setDefaultRouter(DataSourceKeyRouter router)
public void registerRouter(DataSourceKeyRouter router)
public void registerRouter(DataSourceKeyRouter router, boolean asDefault)
public void registerRouters(List<DataSourceKeyRouter> routers)
public void allocateWriteMatcher(String group, com.jn.langx.invocation.matcher.MethodMatcher methodMatcher)
public DataSourceKeyRouter getRouter(String group)
public static void addChoice(DataSourceKey key)
public static void removeChoice(@Nullable
DataSourceKey key)
public static com.jn.langx.util.collection.stack.ListableStack<DataSourceKey> getChoices()
public static void clearChoices()
public static void setCurrent(DataSourceKey key)
public static DataSourceKey getCurrent()
public static void removeCurrent()
public final DataSourceKey select(@Nullable com.jn.langx.invocation.MethodInvocation methodInvocation)
select 在接口中 com.jn.langx.cluster.loadbalance.LoadBalancer<DataSourceKey,com.jn.langx.invocation.MethodInvocation>select 在接口中 DataSourceKeySelector<com.jn.langx.invocation.MethodInvocation>protected DataSourceKey doSelect(@Nullable com.jn.langx.invocation.MethodInvocation methodInvocation)
这里面不能去设置CURRENT_SELECTED
public DataSourceRegistry getDataSourceRegistry()
public void addNode(DataSourceKey node)
addNode 在接口中 com.jn.langx.cluster.loadbalance.LoadBalancer<DataSourceKey,com.jn.langx.invocation.MethodInvocation>public void removeNode(DataSourceKey key)
removeNode 在接口中 com.jn.langx.cluster.loadbalance.LoadBalancer<DataSourceKey,com.jn.langx.invocation.MethodInvocation>public boolean hasNode(DataSourceKey key)
hasNode 在接口中 com.jn.langx.cluster.loadbalance.LoadBalancer<DataSourceKey,com.jn.langx.invocation.MethodInvocation>public void markDown(DataSourceKey key)
markDown 在接口中 com.jn.langx.cluster.loadbalance.LoadBalancer<DataSourceKey,com.jn.langx.invocation.MethodInvocation>public List<DataSourceKey> getNodes()
getNodes 在接口中 com.jn.langx.cluster.loadbalance.LoadBalancer<DataSourceKey,com.jn.langx.invocation.MethodInvocation>public List<DataSourceKey> getNodes(com.jn.langx.util.function.Predicate<DataSourceKey> predicate)
getNodes 在接口中 com.jn.langx.cluster.loadbalance.LoadBalancer<DataSourceKey,com.jn.langx.invocation.MethodInvocation>public boolean isEmpty()
isEmpty 在接口中 com.jn.langx.cluster.loadbalance.LoadBalancer<DataSourceKey,com.jn.langx.invocation.MethodInvocation>public void setDefaultWriteOperationMatcher(com.jn.langx.invocation.matcher.MethodMatcher defaultWriteOperationMatcher)
Copyright © 2021. All rights reserved.