use of io.crate.metadata.Routing in project crate by crate.
the class RemoteCollectorTest method prepare.
@Before
public void prepare() {
MockitoAnnotations.initMocks(this);
UUID jobId = UUID.randomUUID();
RoutedCollectPhase collectPhase = new RoutedCollectPhase(jobId, 0, "remoteCollect", new Routing(Map.of("remoteNode", Map.of("dummyTable", IntArrayList.from(1)))), RowGranularity.DOC, Collections.singletonList(createReference("name", DataTypes.STRING)), Collections.emptyList(), WhereClause.MATCH_ALL.queryOrFallback(), DistributionInfo.DEFAULT_BROADCAST);
transportJobAction = mock(TransportJobAction.class);
TasksService tasksService = new TasksService(clusterService, new JobsLogs(() -> true));
numBroadcastCalls = new AtomicInteger(0);
transportKillJobsNodeAction = new TransportKillJobsNodeAction(tasksService, clusterService, mock(TransportService.class)) {
@Override
public void broadcast(KillJobsRequest request, ActionListener<Long> listener) {
numBroadcastCalls.incrementAndGet();
}
};
consumer = new TestingRowConsumer();
remoteCollector = new RemoteCollector(jobId, new SessionSettings("dummyUser", SearchPath.createSearchPathFrom("dummySchema")), "localNode", "remoteNode", transportJobAction, transportKillJobsNodeAction, Runnable::run, tasksService, RamAccounting.NO_ACCOUNTING, consumer, collectPhase);
}
use of io.crate.metadata.Routing in project crate by crate.
the class DocLevelCollectTest method testCollectWithPartitionedColumns.
@Test
public void testCollectWithPartitionedColumns() throws Throwable {
RelationName relationName = new RelationName(Schemas.DOC_SCHEMA_NAME, PARTITIONED_TABLE_NAME);
TableInfo tableInfo = schemas.getTableInfo(relationName);
Routing routing = tableInfo.getRouting(clusterService().state(), new RoutingProvider(Randomness.get().nextInt(), Collections.emptyList()), WhereClause.MATCH_ALL, RoutingProvider.ShardSelection.ANY, SessionContext.systemSessionContext());
RoutedCollectPhase collectNode = getCollectNode(Arrays.asList(tableInfo.getReference(new ColumnIdent("id")), tableInfo.getReference(new ColumnIdent("date"))), routing, WhereClause.MATCH_ALL);
Bucket result = collect(collectNode);
assertThat(result, containsInAnyOrder(isRow(1, 0L), isRow(2, 1L)));
}
use of io.crate.metadata.Routing in project crate by crate.
the class HandlerSideLevelCollectTest method testClusterLevel.
@Test
public void testClusterLevel() throws Exception {
Schemas schemas = internalCluster().getInstance(Schemas.class);
TableInfo tableInfo = schemas.getTableInfo(new RelationName("sys", "cluster"));
Routing routing = tableInfo.getRouting(clusterService().state(), routingProvider, WhereClause.MATCH_ALL, RoutingProvider.ShardSelection.ANY, SessionContext.systemSessionContext());
Reference clusterNameRef = new Reference(new ReferenceIdent(SysClusterTableInfo.IDENT, new ColumnIdent("name")), RowGranularity.CLUSTER, DataTypes.STRING, 1, null);
RoutedCollectPhase collectNode = collectNode(routing, List.of(clusterNameRef), RowGranularity.CLUSTER);
Bucket result = collect(collectNode);
assertThat(result.size(), is(1));
assertThat(((String) result.iterator().next().get(0)), Matchers.startsWith("SUITE-"));
}
use of io.crate.metadata.Routing in project crate by crate.
the class SystemCollectSourceTest method testOrderBySymbolsDoNotAppearTwiceInRows.
@Test
public void testOrderBySymbolsDoNotAppearTwiceInRows() throws Exception {
SystemCollectSource systemCollectSource = internalCluster().getDataNodeInstance(SystemCollectSource.class);
Reference shardId = new Reference(new ReferenceIdent(new RelationName("sys", "shards"), "id"), RowGranularity.SHARD, DataTypes.INTEGER, 0, null);
RoutedCollectPhase collectPhase = new RoutedCollectPhase(UUID.randomUUID(), 1, "collect", new Routing(Map.of()), RowGranularity.SHARD, Collections.singletonList(shardId), List.of(), WhereClause.MATCH_ALL.queryOrFallback(), DistributionInfo.DEFAULT_BROADCAST);
collectPhase.orderBy(new OrderBy(Collections.singletonList(shardId), new boolean[] { false }, new boolean[] { false }));
Iterable<? extends Row> rows = systemCollectSource.toRowsIterableTransformation(collectPhase, CoordinatorTxnCtx.systemTransactionContext(), unassignedShardRefResolver(), false).apply(Collections.singletonList(new UnassignedShard(1, "foo", mock(ClusterService.class), true, ShardRoutingState.UNASSIGNED)));
Row next = rows.iterator().next();
assertThat(next.numColumns(), is(1));
}
use of io.crate.metadata.Routing in project crate by crate.
the class SystemCollectSourceTest method testReadIsolation.
@Test
public void testReadIsolation() throws Exception {
SystemCollectSource systemCollectSource = internalCluster().getDataNodeInstance(SystemCollectSource.class);
RoutedCollectPhase collectPhase = new RoutedCollectPhase(UUID.randomUUID(), 1, "collect", new Routing(Map.of()), RowGranularity.SHARD, List.of(), List.of(), WhereClause.MATCH_ALL.queryOrFallback(), DistributionInfo.DEFAULT_BROADCAST);
// No read isolation
List<String> noReadIsolationIterable = new ArrayList<>();
noReadIsolationIterable.add("a");
noReadIsolationIterable.add("b");
CoordinatorTxnCtx txnCtx = CoordinatorTxnCtx.systemTransactionContext();
Iterable<? extends Row> rows = systemCollectSource.toRowsIterableTransformation(collectPhase, txnCtx, unassignedShardRefResolver(), false).apply(noReadIsolationIterable);
assertThat(StreamSupport.stream(rows.spliterator(), false).count(), is(2L));
noReadIsolationIterable.add("c");
assertThat(StreamSupport.stream(rows.spliterator(), false).count(), is(3L));
// Read isolation
List<String> readIsolationIterable = new ArrayList<>();
readIsolationIterable.add("a");
readIsolationIterable.add("b");
rows = systemCollectSource.toRowsIterableTransformation(collectPhase, txnCtx, unassignedShardRefResolver(), true).apply(readIsolationIterable);
assertThat(StreamSupport.stream(rows.spliterator(), false).count(), is(2L));
readIsolationIterable.add("c");
assertThat(StreamSupport.stream(rows.spliterator(), false).count(), is(2L));
}
Aggregations