alpinegizmo commented on a change in pull request #31:
URL: https://github.com/apache/flink-training/pull/31#discussion_r694274227



##########
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);

Review comment:
       I dislike the ExerciseBase class, because its existence makes the 
exercises more complex to understand. I added parallelism to that class when I 
decided to execute the tests with a parallelism of 1, which I now regret.
   
   I'm not convinced it's worthwhile to control the parallelism in the 
exercises -- I don't want to pollute the exercises with inessential details, or 
things that shouldn't be there in production. I think it's more important to 
keep the code looking simple than to reduce the logging a bit. There's so much 
logging on startup anyway.
   
   And I don't really want to include something like 
createConfiguredEnvironment as used in the troubleshooting exercises in the 
starter exercises, because it's very scary looking, and it's not possible for a 
beginner to understand what's going on and whether or not they should have 
similar code in their own applications.
   
   




-- 
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]


Reply via email to