use of org.apache.storm.topology.IComponent in project flink by apache.
the class WrapperSetupHelperTest method testRawType.
@Test(expected = IllegalArgumentException.class)
public void testRawType() throws Exception {
IComponent boltOrSpout;
if (this.r.nextBoolean()) {
boltOrSpout = mock(IRichSpout.class);
} else {
boltOrSpout = mock(IRichBolt.class);
}
final SetupOutputFieldsDeclarer declarer = new SetupOutputFieldsDeclarer();
declarer.declare(new Fields("dummy1", "dummy2"));
PowerMockito.whenNew(SetupOutputFieldsDeclarer.class).withNoArguments().thenReturn(declarer);
WrapperSetupHelper.getNumberOfAttributes(boltOrSpout, new HashSet<String>(singleton(Utils.DEFAULT_STREAM_ID)));
}
use of org.apache.storm.topology.IComponent in project flink by apache.
the class WrapperSetupHelperTest method testEmptyDeclarerBolt.
@Test
public void testEmptyDeclarerBolt() {
IComponent boltOrSpout;
if (this.r.nextBoolean()) {
boltOrSpout = mock(IRichSpout.class);
} else {
boltOrSpout = mock(IRichBolt.class);
}
Assert.assertEquals(new HashMap<String, Integer>(), WrapperSetupHelper.getNumberOfAttributes(boltOrSpout, null));
}
use of org.apache.storm.topology.IComponent in project storm by apache.
the class StreamBuilder method addSink.
private void addSink(TopologyBuilder topologyBuilder, SinkNode sinkNode) {
IComponent bolt = sinkNode.getBolt();
BoltDeclarer boltDeclarer;
if (bolt instanceof IRichBolt) {
boltDeclarer = topologyBuilder.setBolt(sinkNode.getComponentId(), (IRichBolt) bolt, sinkNode.getParallelism());
} else if (bolt instanceof IBasicBolt) {
boltDeclarer = topologyBuilder.setBolt(sinkNode.getComponentId(), (IBasicBolt) bolt, sinkNode.getParallelism());
} else {
throw new IllegalArgumentException("Expect IRichBolt or IBasicBolt in addBolt");
}
for (Node parent : parentNodes(sinkNode)) {
for (String stream : sinkNode.getParentStreams(parent)) {
declareGrouping(boltDeclarer, parent, stream, nodeGroupingInfo.get(parent, stream));
}
}
}
use of org.apache.storm.topology.IComponent in project flink by apache.
the class WrapperSetupHelperTest method testTupleTypes.
private void testTupleTypes(final int numberOfAttributes) throws Exception {
String[] schema;
if (numberOfAttributes == -1) {
schema = new String[1];
} else {
schema = new String[numberOfAttributes];
}
for (int i = 0; i < schema.length; ++i) {
schema[i] = "a" + i;
}
IComponent boltOrSpout;
if (this.r.nextBoolean()) {
boltOrSpout = mock(IRichSpout.class);
} else {
boltOrSpout = mock(IRichBolt.class);
}
final SetupOutputFieldsDeclarer declarer = new SetupOutputFieldsDeclarer();
declarer.declare(new Fields(schema));
PowerMockito.whenNew(SetupOutputFieldsDeclarer.class).withNoArguments().thenReturn(declarer);
HashMap<String, Integer> attributes = new HashMap<String, Integer>();
attributes.put(Utils.DEFAULT_STREAM_ID, numberOfAttributes);
Assert.assertEquals(attributes, WrapperSetupHelper.getNumberOfAttributes(boltOrSpout, numberOfAttributes == -1 ? new HashSet<String>(singleton(Utils.DEFAULT_STREAM_ID)) : null));
}
use of org.apache.storm.topology.IComponent in project flink by apache.
the class WrapperSetupHelperTest method testToManyAttributes.
@Test(expected = IllegalArgumentException.class)
public void testToManyAttributes() throws Exception {
IComponent boltOrSpout;
if (this.r.nextBoolean()) {
boltOrSpout = mock(IRichSpout.class);
} else {
boltOrSpout = mock(IRichBolt.class);
}
final SetupOutputFieldsDeclarer declarer = new SetupOutputFieldsDeclarer();
final String[] schema = new String[26];
for (int i = 0; i < schema.length; ++i) {
schema[i] = "a" + i;
}
declarer.declare(new Fields(schema));
PowerMockito.whenNew(SetupOutputFieldsDeclarer.class).withNoArguments().thenReturn(declarer);
WrapperSetupHelper.getNumberOfAttributes(boltOrSpout, null);
}
Aggregations