|
@@ -32,6 +32,7 @@ import org.springframework.stereotype.Component;
|
|
import org.springframework.util.Assert;
|
|
import org.springframework.util.Assert;
|
|
|
|
|
|
import javax.annotation.PostConstruct;
|
|
import javax.annotation.PostConstruct;
|
|
|
|
+import java.sql.Timestamp;
|
|
import java.time.Instant;
|
|
import java.time.Instant;
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
@@ -178,12 +179,13 @@ public class IncrementPuller extends AbstractPuller implements ScheduledTaskJob
|
|
private static final int FLUSH_DELAYED_SECONDS = 30;
|
|
private static final int FLUSH_DELAYED_SECONDS = 30;
|
|
protected Mapping mapping;
|
|
protected Mapping mapping;
|
|
protected String metaId;
|
|
protected String metaId;
|
|
- private LocalDateTime updateTime = LocalDateTime.now();
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void flushEvent(Map<String, String> snapshot) {
|
|
public void flushEvent(Map<String, String> snapshot) {
|
|
// 30s内更新,执行写入
|
|
// 30s内更新,执行写入
|
|
- if (updateTime.isAfter(LocalDateTime.now().minusSeconds(FLUSH_DELAYED_SECONDS))) {
|
|
|
|
|
|
+ Meta meta = manager.getMeta(metaId);
|
|
|
|
+ LocalDateTime lastSeconds = LocalDateTime.now().minusSeconds(FLUSH_DELAYED_SECONDS);
|
|
|
|
+ if(meta.getUpdateTime() > Timestamp.valueOf(lastSeconds).getTime()){
|
|
if (!CollectionUtils.isEmpty(snapshot)) {
|
|
if (!CollectionUtils.isEmpty(snapshot)) {
|
|
logger.debug("{}", snapshot);
|
|
logger.debug("{}", snapshot);
|
|
}
|
|
}
|
|
@@ -200,11 +202,6 @@ public class IncrementPuller extends AbstractPuller implements ScheduledTaskJob
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
|
- public void refreshFlushEventUpdateTime() {
|
|
|
|
- updateTime = LocalDateTime.now();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
@Override
|
|
@Override
|
|
public void errorEvent(Exception e) {
|
|
public void errorEvent(Exception e) {
|
|
logService.log(LogType.TableGroupLog.INCREMENT_FAILED, e.getMessage());
|
|
logService.log(LogType.TableGroupLog.INCREMENT_FAILED, e.getMessage());
|
|
@@ -253,9 +250,6 @@ public class IncrementPuller extends AbstractPuller implements ScheduledTaskJob
|
|
|
|
|
|
// 处理过程有异常向上抛
|
|
// 处理过程有异常向上抛
|
|
parser.execute(mapping, tableGroup, rowChangedEvent);
|
|
parser.execute(mapping, tableGroup, rowChangedEvent);
|
|
-
|
|
|
|
- // 标记有变更记录
|
|
|
|
- refreshFlushEventUpdateTime();
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -314,8 +308,6 @@ public class IncrementPuller extends AbstractPuller implements ScheduledTaskJob
|
|
parser.execute(mapping, picker.getTableGroup(), rowChangedEvent);
|
|
parser.execute(mapping, picker.getTableGroup(), rowChangedEvent);
|
|
}
|
|
}
|
|
});
|
|
});
|
|
- // 标记有变更记录
|
|
|
|
- refreshFlushEventUpdateTime();
|
|
|
|
eventCounter.set(0);
|
|
eventCounter.set(0);
|
|
return;
|
|
return;
|
|
}
|
|
}
|