GroupSequenceDao extends AbstractLifecycle implements SequenceDao { @Override public SequenceRange nextRange(final String name) throws SequenceException { if (name == null) { logger.error("序列名为空！"); throw new IllegalArgumentException("序列名称不能为空"); } configLock.lock(); try { int[] randomIntSequence = RandomSequence.randomIntSequence(dscount); for (int i = 0; i < retryTimes; i++) { for (int j = 0; j < dscount; j++) { int index = randomIntSequence[j]; if (isOffState(dbGroupKeys.get(index)) || !recoverFromExcludes(index)) { continue; } final TGroupDataSource tGroupDataSource = getGroupDsByIndex(index); long oldValue; try { oldValue = getOldValue(tGroupDataSource, name); if (!isOldValueFixed(oldValue)) { continue; } } catch (SQLException e) { logger.error("取范围过程中--查询出错！" + dbGroupKeys.get(index) + ":" + name, e); excludeDataSource(index); continue; } long newValue = generateNewValue(index, oldValue, name); try { if (0 == updateNewValue(tGroupDataSource, name, oldValue, newValue)) { continue; } } catch (SQLException e) { logger.error("取范围过程中--更新出错！" + dbGroupKeys.get(index) + ":" + name, e); continue; } SequenceRange range = new SequenceRange(newValue + 1, newValue + innerStep); if (logger.isDebugEnabled()) { logger.debug("get new range, sequence name is: " + name + ", range info: " + range.toString()); } return range; } if (i == (retryTimes - 2)) { excludedKeyCount.clear(); } } logger.error("所有数据源都不可用！且重试" + this.retryTimes + "次后，仍然失败!"); throw new SequenceException("All dataSource faild to get value!"); } finally { configLock.unlock(); } }  @Override void doInit(); void adjust(String name); @Override SequenceRange nextRange(final String name); void setDscount(int dscount); int getRetryTimes(); void setRetryTimes(int retryTimes); int getInnerStep(); void setInnerStep(int innerStep); String getTableName(); void setTableName(String tableName); String getNameColumnName(); void setNameColumnName(String nameColumnName); String getValueColumnName(); void setValueColumnName(String valueColumnName); String getGmtModifiedColumnName(); void setGmtModifiedColumnName(String gmtModifiedColumnName); void setAppName(String appName); void setDbGroupKeys(List<String> dbGroupKeys); boolean isAdjust(); void setAdjust(boolean adjust); int getMaxSkipCount(); void setMaxSkipCount(int maxSkipCount); boolean isUseSlowProtect(); void setUseSlowProtect(boolean useSlowProtect); int getProtectMilliseconds(); void setProtectMilliseconds(int protectMilliseconds); String getSwitchTempTable(); void setSwitchTempTable(String switchTempTable); String getAppName(); String getUnitName(); void setUnitName(String unitName);  }
@Ignore @Test public void test_nextRange() { try { SequenceRange sequenceRange = sequenceDao.nextRange("xdh"); System.out.println(sequenceRange); } catch (SequenceException e) { e.printStackTrace(); } }