shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/ClusterContextManagerCoordinator.java
/**
     * Renew data source configuration.
     *
     * @param event data source changed event.
     * @throws SQLException SQL exception
     */
Renew data source configuration.
@param event data source changed event.
@throws SQLException SQL exception
Renew data source configuration . @param event data source changed event . @throws SQLException SQL exception
@Subscribe
    public synchronized void renew(final DataSourceChangedEvent event) throws SQLException {
        String schemaName = event.getSchemaName();
        MetaDataContexts changedMetaDataContext = buildChangedMetaDataContext(contextManager.getMetaDataContexts().getMetaDataMap().get(schemaName), event.getDataSourceConfigurations());
        contextManager.getMetaDataContexts().getOptimizerContext().getMetaData().getSchemas().putAll(changedMetaDataContext.getOptimizerContext().getMetaData().getSchemas());
        Map<String, ShardingSphereMetaData> metaDataMap = new HashMap<>(contextManager.getMetaDataContexts().getMetaDataMap());
        metaDataMap.putAll(changedMetaDataContext.getMetaDataMap());
        Collection<DataSource> pendingClosedDataSources = getPendingClosedDataSources(schemaName, event.getDataSourceConfigurations());
        contextManager.renewMetaDataContexts(rebuildMetaDataContexts(metaDataMap));
        renewTransactionContext(schemaName, contextManager.getMetaDataContexts().getMetaData(schemaName).getResource());
        closeDataSources(schemaName, pendingClosedDataSources);
    }
@ Subscribe public synchronized void renew ( final DataSourceChangedEvent event ) throws SQLException { String schemaName = event . getSchemaName ( ) ; MetaDataContexts changedMetaDataContext = buildChangedMetaDataContext ( contextManager . getMetaDataContexts ( ) . getMetaDataMap ( ) . get ( schemaName ) , event . getDataSourceConfigurations ( ) ) ; contextManager . getMetaDataContexts ( ) . getOptimizerContext ( ) . getMetaData ( ) . getSchemas ( ) . putAll ( changedMetaDataContext . getOptimizerContext ( ) . getMetaData ( ) . getSchemas ( ) ) ; Map < String , ShardingSphereMetaData > metaDataMap = new HashMap < > ( contextManager . getMetaDataContexts ( ) . getMetaDataMap ( ) ) ; metaDataMap . putAll ( changedMetaDataContext . getMetaDataMap ( ) ) ; Collection < DataSource > pendingClosedDataSources = getPendingClosedDataSources ( schemaName , event . getDataSourceConfigurations ( ) ) ; contextManager . renewMetaDataContexts ( rebuildMetaDataContexts ( metaDataMap ) ) ; renewTransactionContext ( schemaName , contextManager . getMetaDataContexts ( ) . getMetaData ( schemaName ) . getResource ( ) ) ; closeDataSources ( schemaName , pendingClosedDataSources ) ; }
Renew data source configuration.
Renew data source configuration .