mirror of
https://github.com/actiontech/dble.git
synced 2026-05-25 01:09:29 -05: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 LoadBalancer loadBalancer = new RandomLoadBalancer();
|
||||||
private final ReentrantReadWriteLock adjustLock = new ReentrantReadWriteLock();
|
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) {
|
public PhysicalDbGroup(String name, DbGroupConfig config, PhysicalDbInstance writeDbInstances, PhysicalDbInstance[] readDbInstances, int rwSplitMode) {
|
||||||
this.groupName = name;
|
this.groupName = name;
|
||||||
@@ -127,11 +128,23 @@ public class PhysicalDbGroup {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isUseless() {
|
public boolean isUseless() {
|
||||||
return useless;
|
return shardingUseless && rwSplitUseless;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUseless(boolean useless) {
|
public boolean isShardingUseless() {
|
||||||
this.useless = useless;
|
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() {
|
private boolean checkSlaveSynStatus() {
|
||||||
@@ -442,6 +455,6 @@ public class PhysicalDbGroup {
|
|||||||
pool.getDbGroupConfig().getRwSplitMode() == this.dbGroupConfig.getRwSplitMode() &&
|
pool.getDbGroupConfig().getRwSplitMode() == this.dbGroupConfig.getRwSplitMode() &&
|
||||||
pool.getDbGroupConfig().getDelayThreshold() == this.dbGroupConfig.getDelayThreshold() &&
|
pool.getDbGroupConfig().getDelayThreshold() == this.dbGroupConfig.getDelayThreshold() &&
|
||||||
pool.getDbGroupConfig().isDisableHA() == this.dbGroupConfig.isDisableHA() &&
|
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)) {
|
if (allUseShardingNode.contains(shardingNodeName)) {
|
||||||
shardingNodeGroup = entry.getValue().getDbGroup();
|
shardingNodeGroup = entry.getValue().getDbGroup();
|
||||||
if (shardingNodeGroup != null) {
|
if (shardingNodeGroup != null) {
|
||||||
shardingNodeGroup.setUseless(false);
|
shardingNodeGroup.setShardingUseless(false);
|
||||||
} else {
|
} else {
|
||||||
throw new ConfigException("dbGroup not exists " + entry.getValue().getDbGroupName());
|
throw new ConfigException("dbGroup not exists " + entry.getValue().getDbGroupName());
|
||||||
}
|
}
|
||||||
@@ -180,10 +180,10 @@ public class ConfigInitializer implements ProblemReporter {
|
|||||||
group = this.dbGroups.get(rwSplitUserConfig.getDbGroup());
|
group = this.dbGroups.get(rwSplitUserConfig.getDbGroup());
|
||||||
if (group == null) {
|
if (group == null) {
|
||||||
throw new ConfigException("The user's group[" + rwSplitUserConfig.getName() + "." + rwSplitUserConfig.getDbGroup() + "] for rwSplit isn't configured in db.xml.");
|
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.");
|
throw new ConfigException("The group[" + rwSplitUserConfig.getName() + "." + rwSplitUserConfig.getDbGroup() + "] has been used by sharding node, can't be used by rwSplit.");
|
||||||
} else {
|
} else {
|
||||||
group.setUseless(false);
|
group.setRwSplitUseless(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user