/*
 * Copyright 2016-2018 shardingsphere.io.
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * </p>
 */
package io.shardingsphere.shardingjdbc.orchestration.internal.rule;

import io.shardingsphere.api.config.MasterSlaveRuleConfiguration;
import io.shardingsphere.api.config.ShardingRuleConfiguration;
import io.shardingsphere.core.rule.ShardingRule;

import java.util.Collection;
import java.util.LinkedList;

/**
 * Orchestration sharding rule.
 *
 * @author panjuan
 */
public final class OrchestrationShardingRule extends ShardingRule {
    
    private final Collection<OrchestrationMasterSlaveRule> masterSlaveRules = new LinkedList<>();
    
    public OrchestrationShardingRule(final ShardingRuleConfiguration shardingRuleConfig, final Collection<String> dataSourceNames) {
        super(shardingRuleConfig, dataSourceNames);
        initMasterSlaveRules(shardingRuleConfig);
    }
    
    private void initMasterSlaveRules(final ShardingRuleConfiguration shardingRuleConfig) {
        for (MasterSlaveRuleConfiguration each : shardingRuleConfig.getMasterSlaveRuleConfigs()) {
            masterSlaveRules.add(new OrchestrationMasterSlaveRule(each));
        }
    }
}

@@ -677,24 +677,111 @@
 rnal.rule;%0A%0A
+import com.google.common.base.Function;%0Aimport com.google.common.collect.Collections2;%0A
 import io.sh
@@ -826,32 +826,32 @@
 eConfiguration;%0A
-
 import io.shardi
@@ -889,32 +889,84 @@
 eConfiguration;%0A
+import io.shardingsphere.core.rule.MasterSlaveRule;%0A
 import io.shardi
@@ -995,24 +995,58 @@
 rdingRule;%0A%0A
+import javax.annotation.Nullable;%0A
 import java.
@@ -1857,10 +1857,394 @@
 %7D%0A    %7D%0A
+    %0A    @Override%0A    public Collection%3CMasterSlaveRule%3E getMasterSlaveRules() %7B%0A        return Collections2.transform(masterSlaveRules, new Function%3COrchestrationMasterSlaveRule, MasterSlaveRule%3E() %7B%0A            %0A            @Override%0A            public MasterSlaveRule apply(final OrchestrationMasterSlaveRule input) %7B%0A                return input;%0A            %7D%0A        %7D);%0A    %7D%0A
 %7D%0A

add getMasterSlaveRules()