|
@@ -32,17 +32,13 @@ import java.util.*;
|
|
|
|
|
|
public class PlanHourStreamJob {
|
|
public class PlanHourStreamJob {
|
|
|
|
|
|
- /**
|
|
|
|
- * 可能有数据的最早日期
|
|
|
|
- */
|
|
|
|
- private static final String OLDEST_DAY = "2019-01-01";
|
|
|
|
-
|
|
|
|
public static void main(String[] args) throws Exception {
|
|
public static void main(String[] args) throws Exception {
|
|
|
|
+ boolean isTest = false;
|
|
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
|
|
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
|
|
|
|
|
|
// 加载配置文件到 flink的全局配置中
|
|
// 加载配置文件到 flink的全局配置中
|
|
Properties props = new Properties();
|
|
Properties props = new Properties();
|
|
- props.load(PlanHourStreamJob.class.getResourceAsStream("/application.properties"));
|
|
|
|
|
|
+ props.load(AdHourStreamJob.class.getResourceAsStream(isTest ? "/application.test.properties" : "/application.properties"));
|
|
Configuration configuration = new Configuration();
|
|
Configuration configuration = new Configuration();
|
|
props.stringPropertyNames().forEach(key -> {
|
|
props.stringPropertyNames().forEach(key -> {
|
|
String value = props.getProperty(key);
|
|
String value = props.getProperty(key);
|
|
@@ -70,7 +66,7 @@ public class PlanHourStreamJob {
|
|
env.getCheckpointConfig().setCheckpointStorage(props.getProperty(ApplicationProperties.FLINK_CHECKPOINT_SAVEPOINT));
|
|
env.getCheckpointConfig().setCheckpointStorage(props.getProperty(ApplicationProperties.FLINK_CHECKPOINT_SAVEPOINT));
|
|
}
|
|
}
|
|
|
|
|
|
- KafkaSource<String> adStreamOfMinuteSource = KafkaComponent.buildKafkaSource(props, KafkaComponent.KafkaTopic.adHourTopic, KafkaComponent.KafkaTopic.KafkaGroupId.planHourConsumerGroup);
|
|
|
|
|
|
+ KafkaSource<String> adStreamOfMinuteSource = KafkaComponent.buildKafkaSource(isTest, props, KafkaComponent.KafkaTopic.adHourTopic, KafkaComponent.KafkaTopic.KafkaGroupId.planHourConsumerGroup);
|
|
DataStreamSource<String> adStreamOfMinuteIn = env.fromSource(adStreamOfMinuteSource, WatermarkStrategy.noWatermarks(), "planHourSource_kafka");
|
|
DataStreamSource<String> adStreamOfMinuteIn = env.fromSource(adStreamOfMinuteSource, WatermarkStrategy.noWatermarks(), "planHourSource_kafka");
|
|
|
|
|
|
// 广告分钟数据(前 5分钟的广告消耗数据)
|
|
// 广告分钟数据(前 5分钟的广告消耗数据)
|
|
@@ -114,6 +110,6 @@ public class PlanHourStreamJob {
|
|
.addSink(new TunnelBatchStreamSink<>(PlanStatOfHourDWD.class))
|
|
.addSink(new TunnelBatchStreamSink<>(PlanStatOfHourDWD.class))
|
|
.name("sink_plan_hour_dwd");
|
|
.name("sink_plan_hour_dwd");
|
|
|
|
|
|
- env.execute("plan_hour_stream_job");
|
|
|
|
|
|
+ env.execute(isTest ? "plan_hour_stream_job_test" : "plan_hour_stream_job");
|
|
}
|
|
}
|
|
}
|
|
}
|