use of org.apache.heron.api.topology.TopologyBuilder in project heron by twitter.
the class BaseWindowedBoltTest method testSettingSlidingTimeWindow.
@Test
public void testSettingSlidingTimeWindow() {
final Object[][] args = new Object[][] { { -1L, 10L }, { 10L, -1L }, { 0L, 10L }, { 10L, 0L }, { 0L, 0L }, { -1L, -1L }, { 5L, 10L }, { 1L, 1L }, { 10L, 5L }, { 100L, 10L }, { 100L, 100L }, { 200L, 100L }, { 500L, 100L }, { null, null }, { null, 1L }, { 1L, null }, { null, -1L }, { -1L, null } };
for (Object[] arg : args) {
TopologyBuilder builder = new TopologyBuilder();
Object arg0 = arg[0];
Object arg1 = arg[1];
try {
Duration windowLengthDuration = null;
if (arg0 != null) {
windowLengthDuration = Duration.ofMillis((Long) arg0);
}
Duration slidingIntervalDuration = null;
if (arg1 != null) {
slidingIntervalDuration = Duration.ofMillis((Long) arg1);
}
builder.setBolt("testBolt", new TestBolt().withWindow(windowLengthDuration, slidingIntervalDuration));
if (arg0 == null || arg1 == null) {
fail(String.format("Window length or sliding window length cannot be null -- " + "windowLengthDuration: %s slidingIntervalDuration: %s", arg0, arg1));
}
if ((Long) arg0 <= 0 || (Long) arg1 <= 0) {
fail(String.format("Window length or sliding window length cannot be zero or less -- " + "windowLengthDuration: %s slidingIntervalDuration: %s", arg0, arg1));
}
} catch (IllegalArgumentException e) {
if (arg0 != null && arg1 != null && (Long) arg0 > 0 && (Long) arg1 > 0) {
fail(String.format("Exception: %s thrown on valid input -- windowLengthDuration: %s " + "slidingIntervalDuration: %s", e.getMessage(), arg0, arg1));
}
}
}
}
use of org.apache.heron.api.topology.TopologyBuilder in project heron by twitter.
the class BaseWindowedBoltTest method testSettingSlidingCountWindow.
@Test
public void testSettingSlidingCountWindow() {
final Object[][] args = new Object[][] { { -1, 10 }, { 10, -1 }, { 0, 10 }, { 10, 0 }, { 0, 0 }, { -1, -1 }, { 5, 10 }, { 1, 1 }, { 10, 5 }, { 100, 10 }, { 100, 100 }, { 200, 100 }, { 500, 100 }, { null, null }, { null, 1 }, { 1, null }, { null, -1 }, { -1, null } };
for (Object[] arg : args) {
TopologyBuilder builder = new TopologyBuilder();
Object arg0 = arg[0];
Object arg1 = arg[1];
try {
BaseWindowedBolt.Count windowLengthCount = null;
if (arg0 != null) {
windowLengthCount = BaseWindowedBolt.Count.of((Integer) arg0);
}
BaseWindowedBolt.Count slidingIntervalCount = null;
if (arg1 != null) {
slidingIntervalCount = BaseWindowedBolt.Count.of((Integer) arg1);
}
builder.setBolt("testBolt", new TestBolt().withWindow(windowLengthCount, slidingIntervalCount));
if (arg0 == null || arg1 == null) {
fail(String.format("Window length or sliding window length cannot be null -- " + "windowLengthCount: %s slidingIntervalCount: %s", arg0, arg1));
}
if ((Integer) arg0 <= 0 || (Integer) arg1 <= 0) {
fail(String.format("Window length or sliding window length cannot be zero or less -- " + "windowLengthCount: %s slidingIntervalCount: %s", arg0, arg1));
}
} catch (IllegalArgumentException e) {
if (arg0 != null && arg1 != null && (Integer) arg0 > 0 && (Integer) arg1 > 0) {
fail(String.format("Exception: %s thrown on valid input -- windowLengthCount: %s " + "slidingIntervalCount: %s", e.getMessage(), arg0, arg1));
}
}
}
}
use of org.apache.heron.api.topology.TopologyBuilder in project heron by twitter.
the class BaseWindowedBoltTest method testSettingLagTime.
@Test
public void testSettingLagTime() {
final Object[] args = new Object[] { -1L, 0L, 1L, 2L, 5L, 10L, null };
for (Object arg : args) {
TopologyBuilder builder = new TopologyBuilder();
Object arg0 = arg;
try {
Duration lagTime = null;
if (arg0 != null) {
lagTime = Duration.ofMillis((Long) arg0);
}
builder.setBolt("testBolt", new TestBolt().withLag(lagTime));
if (arg0 == null) {
fail(String.format("Window lag duration cannot be null -- lagTime: %s", arg0));
}
if ((Long) arg0 <= 0) {
fail(String.format("Window lag cannot be zero or less -- lagTime: %s", arg0));
}
} catch (IllegalArgumentException e) {
if (arg0 != null && (Long) arg0 > 0) {
fail(String.format("Exception: %s thrown on valid input -- lagTime: %s", e.getMessage(), arg0));
}
}
}
}
use of org.apache.heron.api.topology.TopologyBuilder in project heron by twitter.
the class BaseWindowedBoltTest method testSettingTumblingCountWindow.
@Test
public void testSettingTumblingCountWindow() {
final Object[] args = new Object[] { -1, 0, 1, 2, 5, 10, null };
for (Object arg : args) {
TopologyBuilder builder = new TopologyBuilder();
Object arg0 = arg;
try {
BaseWindowedBolt.Count windowLengthCount = null;
if (arg0 != null) {
windowLengthCount = BaseWindowedBolt.Count.of((Integer) arg0);
}
builder.setBolt("testBolt", new TestBolt().withTumblingWindow(windowLengthCount));
if (arg0 == null) {
fail(String.format("Window length cannot be null -- windowLengthCount: %s", arg0));
}
if ((Integer) arg0 <= 0) {
fail(String.format("Window length cannot be zero or less -- windowLengthCount: %s", arg0));
}
} catch (IllegalArgumentException e) {
if (arg0 != null && (Integer) arg0 > 0) {
fail(String.format("Exception: %s thrown on valid input -- windowLengthCount: %s", e.getMessage(), arg0));
}
}
}
}
use of org.apache.heron.api.topology.TopologyBuilder in project heron by twitter.
the class Runner method run.
/**
* Runs the computation
* @param name The name of the topology
* @param config Any config that is passed to the topology
* @param builder The builder used to keep track of the sources.
*/
public void run(String name, Config config, Builder builder) {
BuilderImpl bldr = (BuilderImpl) builder;
TopologyBuilder topologyBuilder = bldr.build();
try {
HeronSubmitter.submitTopology(name, config.getHeronConfig(), topologyBuilder.createTopology());
} catch (AlreadyAliveException | InvalidTopologyException e) {
e.printStackTrace();
}
}
Aggregations