@Test public void testAssignmentMoreTasksThanNeeded() throws Exception { List<PartitionDefinition> results = RestService.assignPartitions(pds, 6, 7); assertThat(results.size(), is(0)); } }
@Test public void testAssignmentRemainderTasksGroup3() throws Exception { List<PartitionDefinition> results = RestService.assignPartitions(pds, 2, 4); assertThat(results.size(), is(1)); assertThat(results.get(0), is(pd5)); }
@Test public void testAssignmentDividingTasks() throws Exception { List<PartitionDefinition> results = RestService.assignPartitions(pds, 0, 2); assertThat(results.size(), is(3)); assertThat(results.get(0), is(pd1)); assertThat(results.get(1), is(pd2)); assertThat(results.get(2), is(pd3)); }
@Test public void testAssignmentRemainderTasksGroup12() throws Exception { List<PartitionDefinition> results = RestService.assignPartitions(pds, 3, 5); assertThat(results.size(), is(1)); assertThat(results.get(0), is(pd5)); }
@Test public void testAssignmentRemainderTasksGroup11() throws Exception { List<PartitionDefinition> results = RestService.assignPartitions(pds, 0, 5); assertThat(results.size(), is(2)); assertThat(results.get(0), is(pd1)); assertThat(results.get(1), is(pd2)); }
@Test public void testAssignmentOptimalNumberOfTasks() throws Exception { List<PartitionDefinition> results = RestService.assignPartitions(pds, 1, 6); assertThat(results.size(), is(1)); assertThat(results.get(0), is(pd2)); }
@Test public void testAssignmentRemainderTasksGroup4() throws Exception { List<PartitionDefinition> results = RestService.assignPartitions(pds, 3, 4); assertThat(results.size(), is(1)); assertThat(results.get(0), is(pd6)); }
@Test public void testAssignmentRemainderTasksGroup1() throws Exception { List<PartitionDefinition> results = RestService.assignPartitions(pds, 0, 4); assertThat(results.size(), is(2)); assertThat(results.get(0), is(pd1)); assertThat(results.get(1), is(pd2)); }
@Test public void testAssignmentRemainderTasksGroup2() throws Exception { List<PartitionDefinition> results = RestService.assignPartitions(pds, 1, 4); assertThat(results.size(), is(2)); assertThat(results.get(0), is(pd3)); assertThat(results.get(1), is(pd4)); }
@Test public void testAssignmentOnlyOneTask() throws Exception { List<PartitionDefinition> results = RestService.assignPartitions(pds, 0, 1); assertThat(results.size(), is(6)); assertEquals(pds, results); }
@Override public void open(Map conf, TopologyContext context, SpoutOutputCollector collector) { this.collector = collector; LinkedHashMap copy = new LinkedHashMap(conf); copy.putAll(spoutConfig); StormSettings settings = new StormSettings(copy); InitializationUtils.setValueReaderIfNotSet(settings, JdkValueReader.class, log); ackReads = settings.getStormSpoutReliable(); if (ackReads) { inTransitQueue = new LinkedHashMap<Object, Object>(); replayQueue = new LinkedList<Object[]>(); retries = new HashMap<Object, Integer>(); queueSize = settings.getStormSpoutReliableQueueSize(); tupleRetries = settings.getStormSpoutReliableRetriesPerTuple(); tupleFailure = settings.getStormSpoutReliableTupleFailureHandling(); } int totalTasks = context.getComponentTasks(context.getThisComponentId()).size(); int currentTask = context.getThisTaskIndex(); // match the partitions based on the current topology List<PartitionDefinition> partitions = RestService.findPartitions(settings, log); List<PartitionDefinition> assigned = RestService.assignPartitions(partitions, currentTask, totalTasks); iterator = RestService.multiReader(settings, assigned, log); }
@Override public void open(Map conf, TopologyContext context, SpoutOutputCollector collector) { this.collector = collector; LinkedHashMap copy = new LinkedHashMap(conf); copy.putAll(spoutConfig); StormSettings settings = new StormSettings(copy); InitializationUtils.setValueReaderIfNotSet(settings, JdkValueReader.class, log); ackReads = settings.getStormSpoutReliable(); if (ackReads) { inTransitQueue = new LinkedHashMap<Object, Object>(); replayQueue = new LinkedList<Object[]>(); retries = new HashMap<Object, Integer>(); queueSize = settings.getStormSpoutReliableQueueSize(); tupleRetries = settings.getStormSpoutReliableRetriesPerTuple(); tupleFailure = settings.getStormSpoutReliableTupleFailureHandling(); } int totalTasks = context.getComponentTasks(context.getThisComponentId()).size(); int currentTask = context.getThisTaskIndex(); // match the partitions based on the current topology List<PartitionDefinition> partitions = RestService.findPartitions(settings, log); List<PartitionDefinition> assigned = RestService.assignPartitions(partitions, currentTask, totalTasks); iterator = RestService.multiReader(settings, assigned, log); }