Commit c54dd8ce authored by KomachiSion's avatar KomachiSion
Browse files

For #147, Add example for yaml configuring method for orchestrationEncryptDataSource

parent 970544c6
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import org.apache.shardingsphere.example.common.service.CommonService;
import org.apache.shardingsphere.example.type.RegistryCenterType;
import org.apache.shardingsphere.example.type.ShardingType;
import org.apache.shardingsphere.shardingjdbc.jdbc.adapter.AbstractDataSourceAdapter;
import org.apache.shardingsphere.shardingjdbc.orchestration.api.yaml.YamlOrchestrationEncryptDataSourceFactory;
import org.apache.shardingsphere.shardingjdbc.orchestration.api.yaml.YamlOrchestrationMasterSlaveDataSourceFactory;
import org.apache.shardingsphere.shardingjdbc.orchestration.api.yaml.YamlOrchestrationShardingDataSourceFactory;

@@ -39,8 +40,9 @@ import java.sql.SQLException;
 */
public class YamlConfigurationExample {
    
    private static ShardingType shardingType = ShardingType.SHARDING_DATABASES_AND_TABLES;
//    private static ShardingType shardingType = ShardingType.SHARDING_DATABASES_AND_TABLES;
//    private static ShardingType shardingType = ShardingType.MASTER_SLAVE;
    private static ShardingType shardingType = ShardingType.ENCRYPT;
    
    private static boolean loadConfigFromRegCenter = false;
//    private static boolean loadConfigFromRegCenter = true;
@@ -66,6 +68,9 @@ public class YamlConfigurationExample {
            case MASTER_SLAVE:
                yamlFilePath = String.format("/META-INF/%s/%s/master-slave.yaml", registryCenterType.name().toLowerCase(), loadConfigFromRegCenter ? "cloud" : "local");
                return YamlOrchestrationMasterSlaveDataSourceFactory.createDataSource(getFile(yamlFilePath));
            case ENCRYPT:
                yamlFilePath = String.format("/META-INF/%s/%s/encrypt.yaml", registryCenterType.name().toLowerCase(), loadConfigFromRegCenter ? "cloud" : "local");
                return YamlOrchestrationEncryptDataSourceFactory.createDataSource(getFile(yamlFilePath));
            default:
                throw new UnsupportedOperationException(shardingType.name());
        }
+7 −0
Original line number Diff line number Diff line
orchestration:
  name: demo_yaml_ds_encrypt
  overwrite: false
  registry:
    type: zookeeper
    serverLists: localhost:2181
    namespace: orchestration-yaml-demo
+24 −0
Original line number Diff line number Diff line
orchestration:
  name: demo_yaml_ds_encrypt
  overwrite: true
  registry:
    type: zookeeper
    serverLists: localhost:2181
    namespace: orchestration-yaml-demo

dataSource: !!com.zaxxer.hikari.HikariDataSource
  driverClassName: com.mysql.jdbc.Driver
  jdbcUrl: jdbc:mysql://localhost:3306/demo_ds
  username: root
  password:

encryptRule:
  encryptors:
    order_encryptor:
      type: aes
      qualifiedColumns: t_order.status
      props:
        aes.key.value: 123456

props:
  sql.show: true
 No newline at end of file