alpinegizmo commented on a change in pull request #31:
URL: https://github.com/apache/flink-training/pull/31#discussion_r694278082
##########
File path:
long-ride-alerts/src/main/java/org/apache/flink/training/exercises/longrides/LongRidesExercise.java
##########
@@ -18,62 +18,96 @@
package org.apache.flink.training.exercises.longrides;
+import org.apache.flink.api.common.eventtime.WatermarkStrategy;
+import org.apache.flink.api.common.typeinfo.TypeInformation;
import org.apache.flink.configuration.Configuration;
import org.apache.flink.streaming.api.TimerService;
import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.api.functions.KeyedProcessFunction;
+import org.apache.flink.streaming.api.functions.sink.PrintSinkFunction;
+import org.apache.flink.streaming.api.functions.sink.SinkFunction;
+import org.apache.flink.streaming.api.functions.source.SourceFunction;
import org.apache.flink.training.exercises.common.datatypes.TaxiRide;
import org.apache.flink.training.exercises.common.sources.TaxiRideGenerator;
-import org.apache.flink.training.exercises.common.utils.ExerciseBase;
import
org.apache.flink.training.exercises.common.utils.MissingSolutionException;
import org.apache.flink.util.Collector;
+import java.time.Duration;
+
/**
- * The "Long Ride Alerts" exercise of the Flink training in the docs.
+ * The "Long Ride Alerts" exercise.
+ *
+ * <p>The goal for this exercise is to emit the rideIds for taxi rides with a
duration of more than
+ * two hours. You should assume that TaxiRide events can be lost, but there
are no duplicates.
*
- * <p>The goal for this exercise is to emit START events for taxi rides that
have not been matched
- * by an END event during the first 2 hours of the ride.
+ * <p>You should eventually clear any state you create.
*/
-public class LongRidesExercise extends ExerciseBase {
+public class LongRidesExercise {
+ private SourceFunction<TaxiRide> source;
+ private SinkFunction<Long> sink;
+
+ /** Creates a job using the source and sink provided. */
+ public LongRidesExercise(SourceFunction<TaxiRide> source,
SinkFunction<Long> sink) {
+ this.source = source;
+ this.sink = sink;
+ }
/**
- * Main method.
+ * Creates and executes the long rides pipeline.
*
- * @throws Exception which occurs during job execution.
+ * <p>@throws Exception which occurs during job execution.
*/
- public static void main(String[] args) throws Exception {
+ public void execute() throws Exception {
// set up streaming execution environment
StreamExecutionEnvironment env =
StreamExecutionEnvironment.getExecutionEnvironment();
- env.setParallelism(ExerciseBase.parallelism);
// start the data generator
- DataStream<TaxiRide> rides = env.addSource(rideSourceOrTest(new
TaxiRideGenerator()));
+ DataStream<TaxiRide> rides = env.addSource(source,
TypeInformation.of(TaxiRide.class));
Review comment:
That type information was needed in some intermediate version -- but
fortunately, it's no longer useful.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]