Package com.taobao.tddl.jdbc.group

Examples of com.taobao.tddl.jdbc.group.DataSourceWrapper


    return null;
  }

  public DataSourceWrapper get(String dsKey) {
    for (int i = 0; i < priorityGroups.length; i++) {
      DataSourceWrapper ds = priorityGroups[i].get(dsKey);
      if (ds != null) {
        return ds;
      }
    }
    return null;
View Full Code Here


    DBSelector r_DBSelector = null;
    DBSelector w_DBSelector = null;

    // ���ֻ��һ��db������OneDBSelector
    if (dswList.size() == 1) {
      DataSourceWrapper dsw2 = dswList.get(0);
      r_DBSelector = new OneDBSelector(dsw2);
      r_DBSelector.setDbType(dsw2.getDBType());
      w_DBSelector = r_DBSelector;
    } else {
      // ��д���ȼ�Map
      Map<Integer/* ���ȼ� */, List<DataSourceWrapper>/* ���ȼ�Ϊkey��DS �б� */> rPriority2DswList = new HashMap<Integer, List<DataSourceWrapper>>();
      Map<Integer, List<DataSourceWrapper>> wPriority2DswList = new HashMap<Integer, List<DataSourceWrapper>>();
View Full Code Here

      // ������group����һ����ʵdataSource�����������group����
      // ���dataSource������ �������һ��dataSource������Ϊ׼
      DataSource dataSource = fetcher.getDataSource(dsKey);
      DBType fetcherDbType = fetcher.getDataSourceDBType(dsKey);
      // dbType = fetcherDbType == null ? dbType : fetcherDbType;
      DataSourceWrapper dsw = new DataSourceWrapper(dsKey, weightStr,
          dataSource, fetcherDbType, i);
      dss.add(dsw);
    }
    return dss;
  }
View Full Code Here

  private AbstractDBSelector createDBSelector2(
      List<DataSourceWrapper> dswList, boolean isRead) {
    AbstractDBSelector dbSelector;
    if (dswList.size() == 1) {
      DataSourceWrapper dsw = dswList.get(0);
      dbSelector = new OneDBSelector(dsw);
      dbSelector.setDbType(dsw.getDBType());
    } else {
      dbSelector = createEquityDbManager(dswList, isRead,
          groupExtraConfig);
    }
    return dbSelector;
View Full Code Here

    Connection conn = null;
    Statement stmt = null;

    TGroupDataSource ds = new TGroupDataSource();
    DataSourceWrapper dsw = new DataSourceWrapper("db1", "rw", ds1, DBType.MYSQL);
    ds.init(dsw);

    conn = ds.getConnection();
    stmt = conn.createStatement();
    stmt.executeUpdate("delete from crud");
    stmt.close();
    conn.close();

    ds = new TGroupDataSource();
    dsw = new DataSourceWrapper("db2", "rw", ds2, DBType.MYSQL);
    ds.init(dsw);
    conn = ds.getConnection();
    stmt = conn.createStatement();
    stmt.executeUpdate("delete from crud");
    stmt.close();
    conn.close();

    ds = new TGroupDataSource();
    dsw = new DataSourceWrapper("db3", "rw", ds3, DBType.MYSQL);
    ds.init(dsw);
    conn = ds.getConnection();
    stmt = conn.createStatement();
    stmt.executeUpdate("delete from crud");
    stmt.close();
View Full Code Here

  }
 
  //��һ�����ݿ�"ds1"���ұ����ϣ�������hudson���ܣ���Ϊ�����Ϲص���
  //@Test
  public void tryLockTest() throws Exception {
    DataSourceWrapper dsw1 = new DataSourceWrapper("ds1", "R20W", DataSourceFactory.getLocalMySQLDataSource(),
        DBType.MYSQL);
    DataSourceWrapper dsw2 = new DataSourceWrapper("ds2", "R10", DataSourceFactory.getMySQLDataSource(),
        DBType.MYSQL);

    ds.init(dsw1, dsw2);

    int size = 3;
View Full Code Here

  private class MyDataSourceFetcher implements DataSourceFetcher {
    private DBType dbType = DBType.MYSQL;

    @Override
    public DataSource getDataSource(String dsKey) {
      DataSourceWrapper dsw = dataSourceWrapperMap.get(dsKey);
      if (dsw != null) {
        dbType = dsw.getDBType();
        return dsw.getWrappedDataSource();
      } else {
        if (createTAtomDataSource) {
          TAtomDataSource atom = createTAtomDataSource(dsKey);
          dbType = DBType.valueOf(atom.getDbType().name());
          return atom;
View Full Code Here

  }
 
  @Test
  public void ����DataSourceWrapper() throws Exception {
    List<DataSourceWrapper> dataSourceWrappers = new ArrayList<DataSourceWrapper>();
    dataSourceWrappers.add(new DataSourceWrapper("dbKey1","rw", DataSourceFactory.getMySQLDataSource(1), DBType.MYSQL));
    dataSourceWrappers.add(new DataSourceWrapper("dbKey2","r", DataSourceFactory.getMySQLDataSource(2), DBType.MYSQL));

    TGroupDataSource ds = new TGroupDataSource();
    ds.setDbGroupKey("myDbGroupKey");
    ds.init(dataSourceWrappers);
View Full Code Here

TOP

Related Classes of com.taobao.tddl.jdbc.group.DataSourceWrapper

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.