Examples of ShardId


Examples of org.makersoft.shards.ShardId

    return this.insert(statement, Maps.newHashMap());
  }

  @Override
  public int insert(String statement, Object parameter) {
    ShardId shardId = this.selectShardIdForNewObject(statement, parameter);
    if (shardId == null) {
      shardId = this.getShardIdForStatementOrParameter(statement, parameter);
    }

    Assert.notNull(shardId);
View Full Code Here

Examples of org.makersoft.shards.ShardId

      for (Shard shard : potentialShards) {
        shardIds.addAll(shard.getShardIds());
      }
    } else {
      //
      ShardId shardId = this.getShardIdForStatementOrParameter(statement, parameter);
      shardIds = Lists.newArrayList(shardId);
    }

    Assert.isTrue(!shardIds.isEmpty());
View Full Code Here

Examples of org.makersoft.shards.ShardId

      for (Shard shard : potentialShards) {
        shardIds.addAll(shard.getShardIds());
      }
    } else {
      // 此种情况下按先从主分区查询statement如果不存在则查询全部分区来定位
      ShardId shardId = this.getShardIdForStatementOrParameter(statement, parameter);
      shardIds = Lists.newArrayList(shardId);
    }

    Assert.isTrue(!shardIds.isEmpty());
View Full Code Here

Examples of org.makersoft.shards.ShardId

   * @param shardId  分区Id
   * @param dataSource  数据源
   * @param sqlSessionFactory   mybaits中的{@link SqlSessionFactory}
   */
  public ShardConfigurationImpl(Integer shardId, DataSource dataSource, SqlSessionFactory sqlSessionFactory){
    this(shardId, Lists.newArrayList(new ShardId(shardId)), dataSource, sqlSessionFactory);
  }
View Full Code Here

Examples of org.makersoft.shards.ShardId

  private static final String PREFIX_VALUE = "prefix_";
  private static final String SUFFIX_VALUE = "_suffix";

  @Before
  public void setup() throws Exception {
    shardId = new ShardId(0);
    shardId.setPrefix("prefix");
    shardId.setSuffix("suffix");
  }
View Full Code Here

Examples of org.makersoft.shards.ShardId

  // private static String ZERO_STRING = "00000000000000000000000000000000";
  // private static String ID_TYPE_PROPERTY = "sharded-uuid-type";

  private int getShardId() {
    ShardId shardId = ShardedSqlSessionImpl.getCurrentSubgraphShardId();
    Assert.notNull(shardId);

    return Integer.valueOf(shardId.getId());
  }
View Full Code Here

Examples of org.makersoft.shards.ShardId

  }

  @Override
  public ShardId extractShardId(Serializable identifier) {
    String hexId = (String) identifier;
    return new ShardId(Integer.decode("0x" + hexId.substring(0, 4)));
  }
View Full Code Here

Examples of org.makersoft.shards.ShardId

    String hexId = (String) identifier;
    return new ShardId(Integer.decode("0x" + hexId.substring(0, 4)));
  }

  public static void main(String[] args) throws Exception {
    ShardedSqlSessionImpl.setCurrentSubgraphShardId(new ShardId(0));

    IdGenerator gen = new ShardedUUIDGenerator();
    IdGenerator gen2 = new ShardedUUIDGenerator();

    for (int i = 0; i < Integer.MAX_VALUE; i++) {
View Full Code Here

Examples of org.makersoft.shards.ShardId

  @Test
  public void testExtractShardId() throws Exception {
    Assert.assertNotNull(idGenerator);

    ShardId shardId = idGenerator.extractShardId(idGenerator.generate(null, null));

    Assert.assertEquals(ShardedUUIDGeneratorTests.shardId, shardId);
  }
View Full Code Here

Examples of org.makersoft.shards.ShardId

      new MyBaseHasShardIdList(shardIdList);
      Assert.fail("expected iae");
    } catch (IllegalArgumentException iae) {
      // good
    }
    shardIdList.add(new ShardId(0));
    BaseHasShardIdList bhsil = new MyBaseHasShardIdList(shardIdList);
    ShardId anotherId = new ShardId(1);
    shardIdList.add(anotherId);
    // demonstrate that external changes to the list that was passed in
    // aren't reflected inside the object
    Assert.assertFalse(bhsil.getShardIds().contains(anotherId));
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.