[ server ] [ execution ]- optimize proceed and add persistence log
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package io.wdd.common.beans.executor;
|
||||
|
||||
import io.wdd.common.utils.TimeUtils;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
@@ -19,4 +20,9 @@ public class ExecutionMessage {
|
||||
|
||||
private String resultKey;
|
||||
|
||||
public static String GetResultKey(String topicName) {
|
||||
|
||||
return topicName + "Execution:" + TimeUtils.currentTimeStringFullSplit();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -22,18 +22,27 @@ public class TimeUtils {
|
||||
private static final Map<String, Long> times = new LinkedHashMap<>();
|
||||
|
||||
static {
|
||||
times.put("year", TimeUnit.DAYS.toMillis(365));
|
||||
times.put("month", TimeUnit.DAYS.toMillis(30));
|
||||
times.put("week", TimeUnit.DAYS.toMillis(7));
|
||||
times.put("day", TimeUnit.DAYS.toMillis(1));
|
||||
times.put("hour", TimeUnit.HOURS.toMillis(1));
|
||||
times.put("minute", TimeUnit.MINUTES.toMillis(1));
|
||||
times.put("second", TimeUnit.SECONDS.toMillis(1));
|
||||
times.put("year",
|
||||
TimeUnit.DAYS.toMillis(365));
|
||||
times.put("month",
|
||||
TimeUnit.DAYS.toMillis(30));
|
||||
times.put("week",
|
||||
TimeUnit.DAYS.toMillis(7));
|
||||
times.put("day",
|
||||
TimeUnit.DAYS.toMillis(1));
|
||||
times.put("hour",
|
||||
TimeUnit.HOURS.toMillis(1));
|
||||
times.put("minute",
|
||||
TimeUnit.MINUTES.toMillis(1));
|
||||
times.put("second",
|
||||
TimeUnit.SECONDS.toMillis(1));
|
||||
}
|
||||
|
||||
public static ByteBuffer currentTimeByteBuffer() {
|
||||
|
||||
byte[] timeBytes = LocalDateTime.now(ZoneId.of("UTC+8")).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")).getBytes(StandardCharsets.UTF_8);
|
||||
byte[] timeBytes = LocalDateTime.now(ZoneId.of("UTC+8"))
|
||||
.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))
|
||||
.getBytes(StandardCharsets.UTF_8);
|
||||
|
||||
return ByteBuffer.wrap(timeBytes);
|
||||
}
|
||||
@@ -48,9 +57,21 @@ public class TimeUtils {
|
||||
*/
|
||||
public static String currentTimeString() {
|
||||
|
||||
return LocalDateTime.now(ZoneId.of("UTC+8")).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||
return LocalDateTime.now(ZoneId.of("UTC+8"))
|
||||
.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return UTC+8 [ yyyy-MM-dd HH:mm:ss ] Time String
|
||||
*/
|
||||
public static String currentTimeStringFullSplit() {
|
||||
|
||||
return LocalDateTime.now(ZoneId.of("UTC+8"))
|
||||
.format(DateTimeFormatter.ofPattern("yyyy-MM-dd-HH-mm-ss"));
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static String localDateTimeString(LocalDateTime time) {
|
||||
return time.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||
}
|
||||
@@ -62,10 +83,10 @@ public class TimeUtils {
|
||||
long timeDelta = duration / time.getValue();
|
||||
if (timeDelta > 0) {
|
||||
res.append(timeDelta)
|
||||
.append(" ")
|
||||
.append(time.getKey())
|
||||
.append(timeDelta > 1 ? "s" : "")
|
||||
.append(", ");
|
||||
.append(" ")
|
||||
.append(time.getKey())
|
||||
.append(timeDelta > 1 ? "s" : "")
|
||||
.append(", ");
|
||||
duration -= time.getValue() * timeDelta;
|
||||
level++;
|
||||
}
|
||||
@@ -83,7 +104,8 @@ public class TimeUtils {
|
||||
}
|
||||
|
||||
public static String toRelative(long duration) {
|
||||
return toRelative(duration, times.size());
|
||||
return toRelative(duration,
|
||||
times.size());
|
||||
}
|
||||
|
||||
public static String toRelative(Date start, Date end) {
|
||||
@@ -93,6 +115,7 @@ public class TimeUtils {
|
||||
|
||||
public static String toRelative(Date start, Date end, int level) {
|
||||
assert start.after(end);
|
||||
return toRelative(end.getTime() - start.getTime(), level);
|
||||
return toRelative(end.getTime() - start.getTime(),
|
||||
level);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user