Search in sources :

Example 21 with TridentTopology

use of storm.trident.TridentTopology in project jstorm by alibaba.

the class TridentMinMaxOfDevicesTest method testTridentMinMaxOfDevices.

@Test
public void testTridentMinMaxOfDevices() {
    Fields fields = new Fields("device-id", "count");
    List<Values> content = new ArrayList<Values>();
    for (int i = 0; i < SPOUT_BATCH_SIZE; i++) content.add(new Values(i + 1));
    ShuffleValuesBatchSpout spout = new ShuffleValuesBatchSpout(fields, content, content);
    TridentTopology tridentTopology = new TridentTopology();
    Stream stream = tridentTopology.newStream("device-gen-spout", spout).each(fields, new Debug("#### devices"));
    stream.minBy("device-id").each(fields, new AssertMinDebug());
    stream.maxBy("count").each(fields, new AssertMaxDebug());
    Map config = new HashMap();
    config.put(Config.TOPOLOGY_NAME, "TridentMinMaxOfDevicesTest");
    // the test can pass if the 2 AssertDebug pass throughout the test
    JStormUnitTestRunner.submitTopology(tridentTopology.build(), config, 120, null);
}
Also used : HashMap(java.util.HashMap) Values(backtype.storm.tuple.Values) ArrayList(java.util.ArrayList) Fields(backtype.storm.tuple.Fields) TridentTopology(storm.trident.TridentTopology) Stream(storm.trident.Stream) HashMap(java.util.HashMap) Map(java.util.Map) Debug(storm.trident.operation.builtin.Debug) Test(org.junit.Test)

Aggregations

Fields (backtype.storm.tuple.Fields)21 TridentTopology (storm.trident.TridentTopology)21 Values (backtype.storm.tuple.Values)13 Stream (storm.trident.Stream)10 Test (org.junit.Test)9 FixedBatchSpout (storm.trident.testing.FixedBatchSpout)9 HashMap (java.util.HashMap)7 Map (java.util.Map)7 TridentState (storm.trident.TridentState)7 Count (storm.trident.operation.builtin.Count)7 MapGet (storm.trident.operation.builtin.MapGet)6 Sum (storm.trident.operation.builtin.Sum)6 Debug (storm.trident.operation.builtin.Debug)5 CountAsAggregator (storm.trident.testing.CountAsAggregator)5 Split (storm.trident.testing.Split)5 FilterNull (storm.trident.operation.builtin.FilterNull)4 InMemoryWindowsStoreFactory (storm.trident.windowing.InMemoryWindowsStoreFactory)4 WindowsStoreFactory (storm.trident.windowing.WindowsStoreFactory)4 LocalDRPC (backtype.storm.LocalDRPC)3 JStormUnitTestDRPCValidator (com.jstorm.example.unittests.utils.JStormUnitTestDRPCValidator)3