|
@@ -28,8 +28,7 @@ public class BatchSinkHour extends RichSinkFunction<CostHourDM> {
|
|
super.open(config);
|
|
super.open(config);
|
|
Properties props = new Properties();
|
|
Properties props = new Properties();
|
|
props.load(AdStatJob.class.getResourceAsStream("/application.properties"));
|
|
props.load(AdStatJob.class.getResourceAsStream("/application.properties"));
|
|
- connection = ClickhouseUtil.getConn(props, "cc-bp11803zbt0oq045io.ads.rds.aliyuncs.com",
|
|
|
|
- "8123", "data_monitoring");
|
|
|
|
|
|
+ connection = ClickhouseUtil.getConn(props);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -121,7 +120,7 @@ public class BatchSinkHour extends RichSinkFunction<CostHourDM> {
|
|
"web_register_uv_hour,\n" +
|
|
"web_register_uv_hour,\n" +
|
|
"web_register_cost_total,\n" +
|
|
"web_register_cost_total,\n" +
|
|
"web_register_cost_day,\n" +
|
|
"web_register_cost_day,\n" +
|
|
- "web_register_cost_hour) values " +
|
|
|
|
|
|
+ "web_register_cost_hour,agency_account_id) values " +
|
|
"(?,?,?,?,?,?,?,?,?,?,\n" +
|
|
"(?,?,?,?,?,?,?,?,?,?,\n" +
|
|
"?,?,?,?,?,?,?,?,?,?,\n" +
|
|
"?,?,?,?,?,?,?,?,?,?,\n" +
|
|
"?,?,?,?,?,?,?,?,?,?,\n" +
|
|
"?,?,?,?,?,?,?,?,?,?,\n" +
|
|
@@ -130,7 +129,7 @@ public class BatchSinkHour extends RichSinkFunction<CostHourDM> {
|
|
"?,?,?,?,?,?,?,?,?,?,\n" +
|
|
"?,?,?,?,?,?,?,?,?,?,\n" +
|
|
"?,?,?,?,?,?,?,?,?,?,\n" +
|
|
"?,?,?,?,?,?,?,?,?,?,\n" +
|
|
"?,?,?,?,?,?,?,?,?,?,\n" +
|
|
"?,?,?,?,?,?,?,?,?,?,\n" +
|
|
- "?,?,?,?,?,?,?)";
|
|
|
|
|
|
+ "?,?,?,?,?,?,?,?)";
|
|
log.error(costhour.toString());
|
|
log.error(costhour.toString());
|
|
PreparedStatement preparedStatement = connection.prepareStatement(sql);
|
|
PreparedStatement preparedStatement = connection.prepareStatement(sql);
|
|
preparedStatement.setString(1, costhour.dt);
|
|
preparedStatement.setString(1, costhour.dt);
|
|
@@ -220,12 +219,13 @@ public class BatchSinkHour extends RichSinkFunction<CostHourDM> {
|
|
preparedStatement.setDouble(85, costhour.webRegisterCostTotal);
|
|
preparedStatement.setDouble(85, costhour.webRegisterCostTotal);
|
|
preparedStatement.setDouble(86, costhour.webRegisterCostDay);
|
|
preparedStatement.setDouble(86, costhour.webRegisterCostDay);
|
|
preparedStatement.setDouble(87, costhour.webRegisterCostHour);
|
|
preparedStatement.setDouble(87, costhour.webRegisterCostHour);
|
|
|
|
+ preparedStatement.setString(88, costhour.agencyAccountId);
|
|
preparedStatement.addBatch();
|
|
preparedStatement.addBatch();
|
|
long startTime = System.currentTimeMillis();
|
|
long startTime = System.currentTimeMillis();
|
|
int ints[] = preparedStatement.executeBatch();
|
|
int ints[] = preparedStatement.executeBatch();
|
|
connection.commit();
|
|
connection.commit();
|
|
long endTime = System.currentTimeMillis();
|
|
long endTime = System.currentTimeMillis();
|
|
- log.error("批量插入耗时: " + (endTime - startTime) + "插入数据数量=" + ints.length);
|
|
|
|
|
|
+ log.info("批量插入耗时: " + (endTime - startTime) + "插入数据数量=" + ints.length);
|
|
//clickhouse 处理重复数据
|
|
//clickhouse 处理重复数据
|
|
//TODO:数据去重有问题,去除掉非最新的数据
|
|
//TODO:数据去重有问题,去除掉非最新的数据
|
|
// Statement statement_duplicate = connection.createStatement();
|
|
// Statement statement_duplicate = connection.createStatement();
|
|
@@ -233,7 +233,7 @@ public class BatchSinkHour extends RichSinkFunction<CostHourDM> {
|
|
// statement_duplicate.executeQuery(sql_duplicate);
|
|
// statement_duplicate.executeQuery(sql_duplicate);
|
|
// connection.commit();
|
|
// connection.commit();
|
|
long endTime_dp = System.currentTimeMillis();
|
|
long endTime_dp = System.currentTimeMillis();
|
|
- log.error("数据清理耗时: " + (endTime_dp - endTime));
|
|
|
|
|
|
+ log.info("数据清理耗时: " + (endTime_dp - endTime));
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|