@Override public void prepare(WorkerTopologyContext context, GlobalStreamId stream, List<Integer> targetTasks) { this.targetTasks = targetTasks; if (this.fields != null) { this.outFields = context.getComponentOutputFields(stream); } }
/** * {@inheritDoc} */ @Override public void prepare(WorkerTopologyContext context, GlobalStreamId stream, List<Integer> targetTasks) { this.targetTasks = targetTasks; this.partitionKeyIndexes = new ArrayList<>(); Fields componentOutputFields = context.getComponentOutputFields(stream); for (String partitionKeyName : partitionKeyNames) { partitionKeyIndexes.add(componentOutputFields.fieldIndex(partitionKeyName)); } }
String streamId = entry.getKey(); Map<String, Grouping> componentGrouping = entry.getValue(); Fields outFields = workerTopologyContext.getComponentOutputFields(componentId, streamId); Map<String, LoadAwareCustomStreamGrouping> componentGrouper = new HashMap<String, LoadAwareCustomStreamGrouping>(); for (Map.Entry<String, Grouping> cg : componentGrouping.entrySet()) {
@Test public void testChooseTasksFields() { PartialKeyGrouping pkg = new PartialKeyGrouping(new Fields("test")); WorkerTopologyContext context = mock(WorkerTopologyContext.class); when(context.getComponentOutputFields(any(GlobalStreamId.class))).thenReturn(new Fields("test")); pkg.prepare(context, mock(GlobalStreamId.class), Lists.newArrayList(0, 1, 2, 3, 4, 5)); Values message = new Values("key1"); List<Integer> choice1 = pkg.chooseTasks(0, message); assertThat(choice1.size(), is(1)); List<Integer> choice2 = pkg.chooseTasks(0, message); assertThat(choice2, is(not(choice1))); List<Integer> choice3 = pkg.chooseTasks(0, message); assertThat(choice3, is(not(choice2))); assertThat(choice3, is(choice1)); } }
@Override public void prepare(WorkerTopologyContext context, GlobalStreamId stream, List<Integer> targetTasks) { this.targetTasks = targetTasks; targetTaskStats = new long[this.targetTasks.size()]; if (this.fields != null) { this.outFields = context.getComponentOutputFields(stream); } }
/** * {@inheritDoc} */ @Override public void prepare(WorkerTopologyContext context, GlobalStreamId stream, List<Integer> targetTasks) { this.targetTasks = targetTasks; this.partitionKeyIndexes = new ArrayList<>(); Fields componentOutputFields = context.getComponentOutputFields(stream); for (String partitionKeyName : partitionKeyNames) { partitionKeyIndexes.add(componentOutputFields.fieldIndex(partitionKeyName)); } }