use of org.apache.flink.core.io.LocatableInputSplit in project flink by apache.
the class LocatableSplitAssignerTest method testSerialSplitAssignmentAllForRemoteHost.
@Test
public void testSerialSplitAssignmentAllForRemoteHost() {
try {
final String[] hosts = { "host1", "host1", "host1", "host2", "host2", "host3" };
final int NUM_SPLITS = 10 * hosts.length;
// load some splits
Set<LocatableInputSplit> splits = new HashSet<LocatableInputSplit>();
for (int i = 0; i < NUM_SPLITS; i++) {
splits.add(new LocatableInputSplit(i, hosts[i % hosts.length]));
}
// get all available splits
LocatableInputSplitAssigner ia = new LocatableInputSplitAssigner(splits);
InputSplit is = null;
while ((is = ia.getNextInputSplit("testhost", 0)) != null) {
assertTrue(splits.remove(is));
}
// check we had all
assertTrue(splits.isEmpty());
assertNull(ia.getNextInputSplit("anotherHost", 0));
assertEquals(NUM_SPLITS, ia.getNumberOfRemoteAssignments());
assertEquals(0, ia.getNumberOfLocalAssignments());
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
Aggregations