Package com.taobao.tddl.common

Examples of com.taobao.tddl.common.WeightRandom


  public EquityDbManager(Map<String, DataSourceWrapper> dataSourceWrapperMap, Map<String, Integer> weightMap) {
    this.dataSourceMap = new HashMap<String, DataSourceHolder>(dataSourceWrapperMap.size());
    for (Map.Entry<String, DataSourceWrapper> e : dataSourceWrapperMap.entrySet()) {
      this.dataSourceMap.put(e.getKey(), new DataSourceHolder(e.getValue()));
    }
    this.weightRandom = new WeightRandom(weightMap);
  }
View Full Code Here


    super.groupExtraConfig = groupExtraConfig;
    this.dataSourceMap = new HashMap<String, DataSourceHolder>(dataSourceWrapperMap.size());
    for (Map.Entry<String, DataSourceWrapper> e : dataSourceWrapperMap.entrySet()) {
      this.dataSourceMap.put(e.getKey(), new DataSourceHolder(e.getValue()));
    }
    this.weightRandom = new WeightRandom(weightMap);
  }
View Full Code Here

      int times, Object... args) throws SQLException {
    //�����֧�����ԣ���times��Ϊ1�Ϳ�����
    if (!this.isSupportRetry) {
      times = 1;
    }
    WeightRandom wr = this.weightRandom;
    List<SQLException> exceptions = new ArrayList<SQLException>(0);
    List<String> excludeKeys = new ArrayList<String>(0);
    if (failedDataSources != null) {
      exceptions.addAll(failedDataSources.values());
      times = times - failedDataSources.size(); //�۳��Ѿ�ʧ�ܵ������Դ���
      for (SQLException e : failedDataSources.values()) {
        if (!exceptionSorter.isExceptionFatal(e)) {
          //��һ���쳣����ʵ����������쳣����map�޷�֪��˳��ֻ�ܱ������������ݿⲻ�����쳣�����׳�
          //�Dz���Ӧ���ڷ��ַ����ݿ�fatal֮��������׳��������Ƿŵ�failedDataSources���map��?(guangxia)
          return tryer.onSQLException(exceptions, exceptionSorter, args);
        }
      }
    }
    for (int i = 0; i < times; i++) {
      String name = selectAliveKey(wr, excludeKeys);
      if (name == null) {
        // Ϊ����չ
        exceptions.add(new NoMoreDataSourceException("tryTime:" + i + ", excludeKeys:" + excludeKeys
            + ", weightConfig:" + wr.getWeightConfig()));
        break;
      }

      DataSourceHolder dsHolder = dataSourceMap.get(name);
      if (dsHolder == null) {
View Full Code Here

TOP

Related Classes of com.taobao.tddl.common.WeightRandom

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.