Browse Source

更新

hph-优化版本
hupenghui@qniao.cn 3 years ago
parent
commit
b3e66253cd
2 changed files with 5 additions and 6 deletions
  1. 4
      .gitignore
  2. 7
      iot-device-power-on-and-off-data-job/src/main/java/com/qniao/iot/device/power/IotDevicePowerOnAndOffDataJob.java

4
.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

7
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();
}
}
}
Loading…
Cancel
Save