From b3e66253cde6611d2c7f4e9822f47e8a28a985f5 Mon Sep 17 00:00:00 2001 From: "hupenghui@qniao.cn" <1049970895> Date: Wed, 7 Sep 2022 00:14:03 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 4 ++++ .../iot/device/power/IotDevicePowerOnAndOffDataJob.java | 7 +------ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 8452323..6e816d3 100644 --- a/.gitignore +++ b/.gitignore @@ -37,3 +37,7 @@ buildNumber.properties .mvn/wrapper/maven-wrapper.jar /.idea +/.iml +/iot-device-power-on-and-off-data.iml +/iot-device-power-on-and-off-data-event/iot-device-power-on-and-off-data-event.iml +/iot-device-power-on-and-off-data-job/iot-device-power-on-and-off-data-job.iml diff --git a/iot-device-power-on-and-off-data-job/src/main/java/com/qniao/iot/device/power/IotDevicePowerOnAndOffDataJob.java b/iot-device-power-on-and-off-data-job/src/main/java/com/qniao/iot/device/power/IotDevicePowerOnAndOffDataJob.java index a8a6c00..636d37e 100644 --- a/iot-device-power-on-and-off-data-job/src/main/java/com/qniao/iot/device/power/IotDevicePowerOnAndOffDataJob.java +++ b/iot-device-power-on-and-off-data-job/src/main/java/com/qniao/iot/device/power/IotDevicePowerOnAndOffDataJob.java @@ -83,8 +83,6 @@ public class IotDevicePowerOnAndOffDataJob { return requestConfigBuilder; })); - private static final ReentrantLock lock = new ReentrantLock(true); - /** * 当前索引日期后缀 */ @@ -118,7 +116,7 @@ public class IotDevicePowerOnAndOffDataJob { @Override public void open(Configuration parameters) { - StateTtlConfig ttlConfig = StateTtlConfig.newBuilder(Time.hours(1)) + StateTtlConfig ttlConfig = StateTtlConfig.newBuilder(Time.minutes(10)) .setUpdateType(StateTtlConfig.UpdateType.OnCreateAndWrite) .setStateVisibility(StateTtlConfig.StateVisibility.NeverReturnExpired) .build(); @@ -331,7 +329,6 @@ public class IotDevicePowerOnAndOffDataJob { GetIndexRequest exist = new GetIndexRequest(indicesName); // 先判断客户端是否存在 try { - lock.lock(); boolean exists = restHighLevelClient.indices().exists(exist, RequestOptions.DEFAULT); if (!exists) { // 创建索引 @@ -391,8 +388,6 @@ public class IotDevicePowerOnAndOffDataJob { } } catch (Exception e) { e.printStackTrace(); - }finally { - lock.unlock(); } } }