Skip to content

Commit

Permalink
Restore authority password after commit migration (refresh metadata) (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
RaigorJiang authored Oct 15, 2024
1 parent 5fac6ae commit 996cd13
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package org.apache.shardingsphere.mode.manager;

import com.google.common.base.Strings;
import com.sphereex.dbplusengine.mode.decorator.GlobalRuleConfigurationDecorator;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
Expand All @@ -38,9 +39,11 @@
import org.apache.shardingsphere.infra.metadata.database.schema.builder.GenericSchemaBuilderMaterial;
import org.apache.shardingsphere.infra.metadata.database.schema.manager.GenericSchemaManager;
import org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereSchema;
import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
import org.apache.shardingsphere.infra.rule.builder.global.GlobalRulesBuilder;
import org.apache.shardingsphere.infra.state.cluster.ClusterState;
import org.apache.shardingsphere.infra.state.cluster.ClusterStateContext;
import org.apache.shardingsphere.infra.util.SphereEx;
import org.apache.shardingsphere.metadata.persist.MetaDataBasedPersistService;
import org.apache.shardingsphere.mode.manager.context.ConfigurationContextManager;
import org.apache.shardingsphere.mode.manager.context.ResourceMetaDataContextManager;
Expand Down Expand Up @@ -184,9 +187,18 @@ private MetaDataContexts createMetaDataContexts(final ShardingSphereDatabase dat
MetaDataContexts result = new MetaDataContexts(metaDataPersistService,
new ShardingSphereMetaData(changedDatabases, metaDataContexts.get().getMetaData().getGlobalResourceMetaData(), changedGlobalMetaData, props));
switchingResource.closeStaleDataSources();
restoreGlobalRules(result);
return result;
}

@SphereEx
private void restoreGlobalRules(final MetaDataContexts metaDataContexts) {
Collection<ShardingSphereRule> globalRules = new GlobalRuleConfigurationDecorator().restore(
metaDataContexts.getMetaData().getGlobalRuleMetaData().getRules(), metaDataContexts.getStatistics(), instanceContext);
metaDataContexts.getMetaData().getGlobalRuleMetaData().getRules().clear();
metaDataContexts.getMetaData().getGlobalRuleMetaData().getRules().addAll(globalRules);
}

/**
* Delete schema names.
*
Expand Down

0 comments on commit 996cd13

Please sign in to comment.