mirror of
https://github.com/actiontech/dble.git
synced 2026-01-02 02:40:28 -06:00
Merge pull request #2296 from LUAgam/fix/674-10
fix: inner 674(cherry pick from master #2271)
This commit is contained in:
@@ -50,7 +50,8 @@ public class PhysicalDbGroup {
|
||||
private final LoadBalancer loadBalancer = new RandomLoadBalancer();
|
||||
private final ReentrantReadWriteLock adjustLock = new ReentrantReadWriteLock();
|
||||
|
||||
private boolean useless = true;
|
||||
private boolean shardingUseless = true;
|
||||
private boolean rwSplitUseless = true;
|
||||
|
||||
public PhysicalDbGroup(String name, DbGroupConfig config, PhysicalDbInstance writeDbInstances, PhysicalDbInstance[] readDbInstances, int rwSplitMode) {
|
||||
this.groupName = name;
|
||||
@@ -127,11 +128,23 @@ public class PhysicalDbGroup {
|
||||
}
|
||||
|
||||
public boolean isUseless() {
|
||||
return useless;
|
||||
return shardingUseless && rwSplitUseless;
|
||||
}
|
||||
|
||||
public void setUseless(boolean useless) {
|
||||
this.useless = useless;
|
||||
public boolean isShardingUseless() {
|
||||
return shardingUseless;
|
||||
}
|
||||
|
||||
public boolean isRwSplitUseless() {
|
||||
return rwSplitUseless;
|
||||
}
|
||||
|
||||
public void setShardingUseless(boolean shardingUseless) {
|
||||
this.shardingUseless = shardingUseless;
|
||||
}
|
||||
|
||||
public void setRwSplitUseless(boolean rwSplitUseless) {
|
||||
this.rwSplitUseless = rwSplitUseless;
|
||||
}
|
||||
|
||||
private boolean checkSlaveSynStatus() {
|
||||
@@ -442,6 +455,6 @@ public class PhysicalDbGroup {
|
||||
pool.getDbGroupConfig().getRwSplitMode() == this.dbGroupConfig.getRwSplitMode() &&
|
||||
pool.getDbGroupConfig().getDelayThreshold() == this.dbGroupConfig.getDelayThreshold() &&
|
||||
pool.getDbGroupConfig().isDisableHA() == this.dbGroupConfig.isDisableHA() &&
|
||||
pool.getGroupName().equals(this.groupName) && pool.isUseless() == this.isUseless();
|
||||
pool.getGroupName().equals(this.groupName) && pool.isShardingUseless() == this.isShardingUseless() && pool.isRwSplitUseless() == this.isRwSplitUseless();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -158,7 +158,7 @@ public class ConfigInitializer implements ProblemReporter {
|
||||
if (allUseShardingNode.contains(shardingNodeName)) {
|
||||
shardingNodeGroup = entry.getValue().getDbGroup();
|
||||
if (shardingNodeGroup != null) {
|
||||
shardingNodeGroup.setUseless(false);
|
||||
shardingNodeGroup.setShardingUseless(false);
|
||||
} else {
|
||||
throw new ConfigException("dbGroup not exists " + entry.getValue().getDbGroupName());
|
||||
}
|
||||
@@ -180,10 +180,10 @@ public class ConfigInitializer implements ProblemReporter {
|
||||
group = this.dbGroups.get(rwSplitUserConfig.getDbGroup());
|
||||
if (group == null) {
|
||||
throw new ConfigException("The user's group[" + rwSplitUserConfig.getName() + "." + rwSplitUserConfig.getDbGroup() + "] for rwSplit isn't configured in db.xml.");
|
||||
} else if (!group.isUseless()) {
|
||||
} else if (!group.isShardingUseless()) {
|
||||
throw new ConfigException("The group[" + rwSplitUserConfig.getName() + "." + rwSplitUserConfig.getDbGroup() + "] has been used by sharding node, can't be used by rwSplit.");
|
||||
} else {
|
||||
group.setUseless(false);
|
||||
group.setRwSplitUseless(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user