Search in sources :

Example 1 with ShardCollectSource

use of io.crate.execution.engine.collect.sources.ShardCollectSource in project crate by crate.

the class ShardCollectorProviderTest method assertNumberOfShardEntriesInShardCollectSource.

public void assertNumberOfShardEntriesInShardCollectSource(int numberOfShards) throws Exception {
    final Field shards = ShardCollectSource.class.getDeclaredField("shards");
    shards.setAccessible(true);
    final List<ShardCollectSource> shardCollectSources = StreamSupport.stream(internalCluster().getInstances(ShardCollectSource.class).spliterator(), false).collect(Collectors.toList());
    for (ShardCollectSource shardCollectSource : shardCollectSources) {
        try {
            // noinspection unchecked
            Map<ShardId, ShardCollectorProvider> shardMap = (Map<ShardId, ShardCollectorProvider>) shards.get(shardCollectSource);
            assertThat(shardMap.size(), is(numberOfShards));
        } catch (IllegalAccessException e) {
            throw new RuntimeException(e);
        }
    }
}
Also used : ShardId(org.elasticsearch.index.shard.ShardId) Field(java.lang.reflect.Field) ShardCollectSource(io.crate.execution.engine.collect.sources.ShardCollectSource) Map(java.util.Map)

Aggregations

ShardCollectSource (io.crate.execution.engine.collect.sources.ShardCollectSource)1 Field (java.lang.reflect.Field)1 Map (java.util.Map)1 ShardId (org.elasticsearch.index.shard.ShardId)1