@Test(expectedExceptions = IllegalStateException.class) public void testUpdateBucketRange_failed_overlapped() throws Exception { bucketManager.updateBucketRange(Range.closed(99, 100), "shard1", "shard2", false); }
public void updateBucketRange(Range<Integer> range, String fromShardId, String toShardId, boolean migrationComplete) { ShardState shardState = lookupBucketTable(range); if (shardState == null) { throw new IllegalStateException("Bucket range not found"); } if (fromShardId == null || toShardId == null) { throw new IllegalStateException("fromShardId or toShardId cannot be null"); } if (!migrationComplete) { handleMigrationInProgress(range, fromShardId, toShardId, shardState); } else { handleMigrationComplete(range, fromShardId, toShardId, shardState); } }
BucketManager { public void updateBucketRange(Range<Integer> range, String fromShardId, String toShardId, boolean migrationComplete) { ShardState shardState = lookupBucketTable(range); if (shardState == null) { throw new IllegalStateException("Bucket range not found"); } if (fromShardId == null || toShardId == null) { throw new IllegalStateException("fromShardId or toShardId cannot be null"); } if (!migrationComplete) { handleMigrationInProgress(range, fromShardId, toShardId, shardState); } else { handleMigrationComplete(range, fromShardId, toShardId, shardState); } } }
BucketManager { public void updateBucketRange(Range<Integer> range, String fromShardId, String toShardId, boolean migrationComplete) { ShardState shardState = lookupBucketTable(range); if (shardState == null) { throw new IllegalStateException("Bucket range not found"); } if (fromShardId == null || toShardId == null) { throw new IllegalStateException("fromShardId or toShardId cannot be null"); } if (!migrationComplete) { handleMigrationInProgress(range, fromShardId, toShardId, shardState); } else { handleMigrationComplete(range, fromShardId, toShardId, shardState); } } BucketManager(Config config); }
BucketManager { public void updateBucketRange(Range<Integer> range, String fromShardId, String toShardId, boolean migrationComplete) { ShardState shardState = lookupBucketTable(range); if (shardState == null) { throw new IllegalStateException("Bucket range not found"); } if (fromShardId == null || toShardId == null) { throw new IllegalStateException("fromShardId or toShardId cannot be null"); } if (!migrationComplete) { handleMigrationInProgress(range, fromShardId, toShardId, shardState); } else { handleMigrationComplete(range, fromShardId, toShardId, shardState); } } BucketManager(Config config); ShardState lookupBucketTable(int bucketId); ShardState lookupBucketTable(Range<Integer> range); void updateBucketRange(Range<Integer> range, String fromShardId, String toShardId,
                                  boolean migrationComplete); int getNumberOfBuckets(); RangeMap<Integer, ShardState> getBucketMap(); void rollbackBuckets(Range<Integer> range); String getBucketString(String shardId); }
BucketManager { public void updateBucketRange(Range<Integer> range, String fromShardId, String toShardId, boolean migrationComplete) { ShardState shardState = lookupBucketTable(range); if (shardState == null) { throw new IllegalStateException("Bucket range not found"); } if (fromShardId == null || toShardId == null) { throw new IllegalStateException("fromShardId or toShardId cannot be null"); } if (!migrationComplete) { handleMigrationInProgress(range, fromShardId, toShardId, shardState); } else { handleMigrationComplete(range, fromShardId, toShardId, shardState); } } BucketManager(Config config); ShardState lookupBucketTable(int bucketId); ShardState lookupBucketTable(Range<Integer> range); void updateBucketRange(Range<Integer> range, String fromShardId, String toShardId,
                                  boolean migrationComplete); int getNumberOfBuckets(); RangeMap<Integer, ShardState> getBucketMap(); void rollbackBuckets(Range<Integer> range); String getBucketString(String shardId);  }