Package org.makersoft.shards

Examples of org.makersoft.shards.Shard


      Map<SqlSessionFactory, Set<ShardId>> sqlSessionFactoryShardIdMap,
      ShardIdResolver shardIdResolver) {
    List<Shard> list = Lists.newArrayList();
    for (Map.Entry<SqlSessionFactory, Set<ShardId>> entry : sqlSessionFactoryShardIdMap
        .entrySet()) {
      Shard shard = new ShardImpl(entry.getValue(), entry.getKey());
      list.add(shard);

    }

    return list;
View Full Code Here


    }
    return shards;
  }

  private SqlSession getSqlSessionForStatement(String statement, List<Shard> shardsToConsider) {
    Shard shard = getShardForStatement(statement, shardsToConsider);
    if (shard == null) {
      return null;
    }
    return shard.establishSqlSession();
  }
View Full Code Here

  @Override
  public ShardId getShardIdForStatementOrParameter(String statement, Object parameter,
      List<Shard> shardsToConsider) {
    // TODO(fengkuok) optimize this by keeping an identity map of objects to shardId
    Shard shard = getShardForStatement(statement, shardsToConsider);
    if (shard == null) {
      return null;
    } else if (shard.getShardIds().size() == 1) {
      return shard.getShardIds().iterator().next();
    } else {
      //TODO(fengkuok) 似乎从来不会走到这个逻辑
      IdGenerator idGenerator = shardedSqlSessionFactory.getIdGenerator();
      if (idGenerator != null) {
        return idGenerator.extractShardId(this.extractId(parameter));
View Full Code Here

TOP

Related Classes of org.makersoft.shards.Shard

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.