Java Code Examples for org.apache.flink.cep.Event#createTypeSerializer()
The following examples show how to use
org.apache.flink.cep.Event#createTypeSerializer() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CepOperatorTestUtilities.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
public static <K> CepOperator<Event, K, Map<String, List<Event>>> getKeyedCepOpearator( boolean isProcessingTime, NFACompiler.NFAFactory<Event> nfaFactory, EventComparator<Event> comparator, OutputTag<Event> outputTag) { return new CepOperator<>( Event.createTypeSerializer(), isProcessingTime, nfaFactory, comparator, null, new PatternProcessFunction<Event, Map<String, List<Event>>>() { private static final long serialVersionUID = -7143807777582726991L; @Override public void processMatch( Map<String, List<Event>> match, Context ctx, Collector<Map<String, List<Event>>> out) throws Exception { out.collect(match); } }, outputTag); }
Example 2
Source File: CepOperatorTestUtilities.java From flink with Apache License 2.0 | 6 votes |
public static <K> CepOperator<Event, K, Map<String, List<Event>>> getKeyedCepOpearator( boolean isProcessingTime, NFACompiler.NFAFactory<Event> nfaFactory, EventComparator<Event> comparator, OutputTag<Event> outputTag) { return new CepOperator<>( Event.createTypeSerializer(), isProcessingTime, nfaFactory, comparator, null, new PatternProcessFunction<Event, Map<String, List<Event>>>() { private static final long serialVersionUID = -7143807777582726991L; @Override public void processMatch( Map<String, List<Event>> match, Context ctx, Collector<Map<String, List<Event>>> out) throws Exception { out.collect(match); } }, outputTag); }
Example 3
Source File: CepOperatorTestUtilities.java From flink with Apache License 2.0 | 6 votes |
public static <K> CepOperator<Event, K, Map<String, List<Event>>> getKeyedCepOpearator( boolean isProcessingTime, NFACompiler.NFAFactory<Event> nfaFactory, EventComparator<Event> comparator, OutputTag<Event> outputTag) { return new CepOperator<>( Event.createTypeSerializer(), isProcessingTime, nfaFactory, comparator, null, new PatternProcessFunction<Event, Map<String, List<Event>>>() { private static final long serialVersionUID = -7143807777582726991L; @Override public void processMatch( Map<String, List<Event>> match, Context ctx, Collector<Map<String, List<Event>>> out) throws Exception { out.collect(match); } }, outputTag); }
Example 4
Source File: CepProcessFunctionContextTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
private <T> CepOperator<Event, Integer, T> createCepOperator( PatternProcessFunction<Event, T> processFunction, NFACompiler.NFAFactory<Event> nfaFactory, boolean isProcessingTime) throws Exception { return new CepOperator<>( Event.createTypeSerializer(), isProcessingTime, nfaFactory, null, null, processFunction, null); }
Example 5
Source File: CepOperatorBuilder.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
public <K> CepOperator<Event, K, OUT> build() { return new CepOperator<>(Event.createTypeSerializer(), isProcessingTime, nfaFactory, comparator, skipStrategy, function, lateDataOutputTag); }
Example 6
Source File: CepProcessFunctionContextTest.java From flink with Apache License 2.0 | 5 votes |
private <T> CepOperator<Event, Integer, T> createCepOperator( PatternProcessFunction<Event, T> processFunction, NFACompiler.NFAFactory<Event> nfaFactory, boolean isProcessingTime) throws Exception { return new CepOperator<>( Event.createTypeSerializer(), isProcessingTime, nfaFactory, null, null, processFunction, null); }
Example 7
Source File: CepOperatorBuilder.java From flink with Apache License 2.0 | 5 votes |
public <K> CepOperator<Event, K, OUT> build() { return new CepOperator<>(Event.createTypeSerializer(), isProcessingTime, nfaFactory, comparator, skipStrategy, function, lateDataOutputTag); }
Example 8
Source File: CepProcessFunctionContextTest.java From flink with Apache License 2.0 | 5 votes |
private <T> CepOperator<Event, Integer, T> createCepOperator( PatternProcessFunction<Event, T> processFunction, NFACompiler.NFAFactory<Event> nfaFactory, boolean isProcessingTime) throws Exception { return new CepOperator<>( Event.createTypeSerializer(), isProcessingTime, nfaFactory, null, null, processFunction, null); }
Example 9
Source File: CepOperatorBuilder.java From flink with Apache License 2.0 | 5 votes |
public <K> CepOperator<Event, K, OUT> build() { return new CepOperator<>(Event.createTypeSerializer(), isProcessingTime, nfaFactory, comparator, skipStrategy, function, lateDataOutputTag); }
Example 10
Source File: CEPOperatorTest.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
/** * Tests that the internal time of a CEP operator advances only given watermarks. See FLINK-5033 */ @Test public void testKeyedAdvancingTimeWithoutElements() throws Exception { final Event startEvent = new Event(42, "start", 1.0); final long watermarkTimestamp1 = 5L; final long watermarkTimestamp2 = 13L; final Map<String, List<Event>> expectedSequence = new HashMap<>(2); expectedSequence.put("start", Collections.<Event>singletonList(startEvent)); final OutputTag<Tuple2<Map<String, List<Event>>, Long>> timedOut = new OutputTag<Tuple2<Map<String, List<Event>>, Long>>("timedOut") {}; final KeyedOneInputStreamOperatorTestHarness<Integer, Event, Map<String, List<Event>>> harness = new KeyedOneInputStreamOperatorTestHarness<>( new CepOperator<>( Event.createTypeSerializer(), false, new NFAFactory(true), null, null, new TimedOutProcessFunction(timedOut), null), new KeySelector<Event, Integer>() { private static final long serialVersionUID = 7219185117566268366L; @Override public Integer getKey(Event value) throws Exception { return value.getId(); } }, BasicTypeInfo.INT_TYPE_INFO); try { String rocksDbPath = tempFolder.newFolder().getAbsolutePath(); RocksDBStateBackend rocksDBStateBackend = new RocksDBStateBackend(new MemoryStateBackend()); rocksDBStateBackend.setDbStoragePath(rocksDbPath); harness.setStateBackend(rocksDBStateBackend); harness.setup( new KryoSerializer<>( (Class<Map<String, List<Event>>>) (Object) Map.class, new ExecutionConfig())); harness.open(); harness.processElement(new StreamRecord<>(startEvent, 3L)); harness.processWatermark(new Watermark(watermarkTimestamp1)); harness.processWatermark(new Watermark(watermarkTimestamp2)); Queue<Object> result = harness.getOutput(); Queue<StreamRecord<Tuple2<Map<String, List<Event>>, Long>>> sideOutput = harness.getSideOutput(timedOut); assertEquals(2L, result.size()); assertEquals(1L, sideOutput.size()); Object watermark1 = result.poll(); assertTrue(watermark1 instanceof Watermark); assertEquals(watermarkTimestamp1, ((Watermark) watermark1).getTimestamp()); Tuple2<Map<String, List<Event>>, Long> leftResult = sideOutput.poll().getValue(); assertEquals(watermarkTimestamp2, (long) leftResult.f1); assertEquals(expectedSequence, leftResult.f0); Object watermark2 = result.poll(); assertTrue(watermark2 instanceof Watermark); assertEquals(watermarkTimestamp2, ((Watermark) watermark2).getTimestamp()); } finally { harness.close(); } }
Example 11
Source File: CEPOperatorTest.java From flink with Apache License 2.0 | 4 votes |
/** * Tests that the internal time of a CEP operator advances only given watermarks. See FLINK-5033 */ @Test public void testKeyedAdvancingTimeWithoutElements() throws Exception { final Event startEvent = new Event(42, "start", 1.0); final long watermarkTimestamp1 = 5L; final long watermarkTimestamp2 = 13L; final Map<String, List<Event>> expectedSequence = new HashMap<>(2); expectedSequence.put("start", Collections.<Event>singletonList(startEvent)); final OutputTag<Tuple2<Map<String, List<Event>>, Long>> timedOut = new OutputTag<Tuple2<Map<String, List<Event>>, Long>>("timedOut") {}; final KeyedOneInputStreamOperatorTestHarness<Integer, Event, Map<String, List<Event>>> harness = new KeyedOneInputStreamOperatorTestHarness<>( new CepOperator<>( Event.createTypeSerializer(), false, new NFAFactory(true), null, null, new TimedOutProcessFunction(timedOut), null), new KeySelector<Event, Integer>() { private static final long serialVersionUID = 7219185117566268366L; @Override public Integer getKey(Event value) throws Exception { return value.getId(); } }, BasicTypeInfo.INT_TYPE_INFO); try { String rocksDbPath = tempFolder.newFolder().getAbsolutePath(); RocksDBStateBackend rocksDBStateBackend = new RocksDBStateBackend(new MemoryStateBackend()); rocksDBStateBackend.setDbStoragePath(rocksDbPath); harness.setStateBackend(rocksDBStateBackend); harness.setup( new KryoSerializer<>( (Class<Map<String, List<Event>>>) (Object) Map.class, new ExecutionConfig())); harness.open(); harness.processElement(new StreamRecord<>(startEvent, 3L)); harness.processWatermark(new Watermark(watermarkTimestamp1)); harness.processWatermark(new Watermark(watermarkTimestamp2)); Queue<Object> result = harness.getOutput(); Queue<StreamRecord<Tuple2<Map<String, List<Event>>, Long>>> sideOutput = harness.getSideOutput(timedOut); assertEquals(2L, result.size()); assertEquals(1L, sideOutput.size()); Object watermark1 = result.poll(); assertTrue(watermark1 instanceof Watermark); assertEquals(watermarkTimestamp1, ((Watermark) watermark1).getTimestamp()); Tuple2<Map<String, List<Event>>, Long> leftResult = sideOutput.poll().getValue(); assertEquals(watermarkTimestamp2, (long) leftResult.f1); assertEquals(expectedSequence, leftResult.f0); Object watermark2 = result.poll(); assertTrue(watermark2 instanceof Watermark); assertEquals(watermarkTimestamp2, ((Watermark) watermark2).getTimestamp()); } finally { harness.close(); } }
Example 12
Source File: CEPOperatorTest.java From flink with Apache License 2.0 | 4 votes |
/** * Tests that the internal time of a CEP operator advances only given watermarks. See FLINK-5033 */ @Test public void testKeyedAdvancingTimeWithoutElements() throws Exception { final Event startEvent = new Event(42, "start", 1.0); final long watermarkTimestamp1 = 5L; final long watermarkTimestamp2 = 13L; final Map<String, List<Event>> expectedSequence = new HashMap<>(2); expectedSequence.put("start", Collections.<Event>singletonList(startEvent)); final OutputTag<Tuple2<Map<String, List<Event>>, Long>> timedOut = new OutputTag<Tuple2<Map<String, List<Event>>, Long>>("timedOut") {}; final KeyedOneInputStreamOperatorTestHarness<Integer, Event, Map<String, List<Event>>> harness = new KeyedOneInputStreamOperatorTestHarness<>( new CepOperator<>( Event.createTypeSerializer(), false, new NFAFactory(true), null, null, new TimedOutProcessFunction(timedOut), null), new KeySelector<Event, Integer>() { private static final long serialVersionUID = 7219185117566268366L; @Override public Integer getKey(Event value) throws Exception { return value.getId(); } }, BasicTypeInfo.INT_TYPE_INFO); try { String rocksDbPath = tempFolder.newFolder().getAbsolutePath(); RocksDBStateBackend rocksDBStateBackend = new RocksDBStateBackend(new MemoryStateBackend()); rocksDBStateBackend.setDbStoragePath(rocksDbPath); harness.setStateBackend(rocksDBStateBackend); harness.setup( new KryoSerializer<>( (Class<Map<String, List<Event>>>) (Object) Map.class, new ExecutionConfig())); harness.open(); harness.processElement(new StreamRecord<>(startEvent, 3L)); harness.processWatermark(new Watermark(watermarkTimestamp1)); harness.processWatermark(new Watermark(watermarkTimestamp2)); Queue<Object> result = harness.getOutput(); Queue<StreamRecord<Tuple2<Map<String, List<Event>>, Long>>> sideOutput = harness.getSideOutput(timedOut); assertEquals(2L, result.size()); assertEquals(1L, sideOutput.size()); Object watermark1 = result.poll(); assertTrue(watermark1 instanceof Watermark); assertEquals(watermarkTimestamp1, ((Watermark) watermark1).getTimestamp()); Tuple2<Map<String, List<Event>>, Long> leftResult = sideOutput.poll().getValue(); assertEquals(watermarkTimestamp2, (long) leftResult.f1); assertEquals(expectedSequence, leftResult.f0); Object watermark2 = result.poll(); assertTrue(watermark2 instanceof Watermark); assertEquals(watermarkTimestamp2, ((Watermark) watermark2).getTimestamp()); } finally { harness.close(); } }