@@ -0,0 +1,2781 @@
+/*%0A * Copyright 2016-2018 shardingsphere.io.%0A * %3Cp%3E%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *     http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A * %3C/p%3E%0A */%0A%0Apackage io.shardingsphere.jdbc.orchestration.internal.datasource;%0A%0Aimport com.google.common.eventbus.Subscribe;%0Aimport io.shardingsphere.core.event.ShardingEventBusInstance;%0Aimport io.shardingsphere.core.jdbc.adapter.AbstractDataSourceAdapter;%0Aimport io.shardingsphere.jdbc.orchestration.internal.OrchestrationFacade;%0Aimport io.shardingsphere.jdbc.orchestration.internal.event.state.CircuitStateEventBusEvent;%0Aimport lombok.AccessLevel;%0Aimport lombok.Getter;%0A%0Aimport javax.sql.DataSource;%0Aimport java.sql.Connection;%0Aimport java.sql.SQLException;%0Aimport java.util.Collection;%0Aimport java.util.LinkedHashMap;%0Aimport java.util.Map;%0A%0A/**%0A * Abstract orchestration data source.%0A *%0A * @author panjuan%0A */%0A@Getter(AccessLevel.PROTECTED)%0Apublic abstract class AbstractOrchestrationDataSource extends AbstractDataSourceAdapter implements AutoCloseable %7B%0A    %0A    private final OrchestrationFacade orchestrationFacade;%0A    %0A    private final Map%3CString, DataSource%3E dataSourceMap;%0A    %0A    private boolean isCircuitBreak;%0A    %0A    public AbstractOrchestrationDataSource(final OrchestrationFacade orchestrationFacade, final Map%3CString, DataSource%3E dataSourceMap) throws SQLException %7B%0A        super(dataSourceMap.values());%0A        this.orchestrationFacade = orchestrationFacade;%0A        this.dataSourceMap = dataSourceMap;%0A        ShardingEventBusInstance.getInstance().register(this);%0A    %7D%0A    %0A    protected final Map%3CString, DataSource%3E getAvailableDataSourceMap(final Collection%3CString%3E disabledDataSourceNames) %7B%0A        Map%3CString, DataSource%3E result = new LinkedHashMap%3C%3E(dataSourceMap);%0A        for (String each : disabledDataSourceNames) %7B%0A            result.remove(each);%0A        %7D%0A        return result;%0A    %7D%0A    %0A    @Override%0A    public abstract Connection getConnection();%0A    %0A    @Override%0A    public abstract void close();%0A    %0A    /**%0A     /**%0A     * Renew circuit breaker dataSource names.%0A     *%0A     * @param circuitStateEventBusEvent jdbc circuit event bus event%0A     */%0A    @Subscribe%0A    public void renew(final CircuitStateEventBusEvent circuitStateEventBusEvent) %7B%0A        isCircuitBreak = circuitStateEventBusEvent.isCircuitBreak();%0A    %7D%0A%7D%0A

add AbstractOrchestrationDataSource.java