private List<Shard> selectShardsByShardIds(List<ShardId> shardIds) {
    List<Shard> list = new ArrayList<Shard>(this.shardConfig.getAllShards().size());
    for (Shard shard : this.shardConfig.getAllShards()) {
      for (ShardId shardId : shardIds) {
        if (shard.getShardIds().contains(shardId) && list.contains(shard) == false) {
          list.add(shard);
        }
      }
    }
    if (list.size() > 0) {
      if (logger.isDebugEnabled()) {
        logger.debug(String.format("selected shards : %s ", list.toString()));
      }
    } else {
      if (this.shardConfig.getDefaultShard() != null) {
        list.add(this.shardConfig.getDefaultShard());

        if (logger.isDebugEnabled()) {
          logger.debug("No shard selected ,use defaultShard.");
        }
      } else {
        logger.error("No shard selected and no defaultShard configed.");
      }
    }
    return list;
  }
 protected final void checkDaoConfig() {
   if (this.shardConfig == null) {
     throw new RuntimeException("No shard config specified.");
   }
   for (Shard shard : this.shardConfig.getAllShards()) {
     if (shard.getDataSource() == null) {
       throw new RuntimeException("No dataSource configured for shard.");
     }
   }
 }