补充忘记写的 tracker/0/0

This commit is contained in:
A.C.Sukazyo Eyre 2021-11-09 18:16:30 +08:00
parent b06f7cb365
commit 14d3f76ac1
Signed by: Eyre_S
GPG Key ID: EFB47D98FE082FAD

View File

@ -30,6 +30,7 @@ public class TrackerDataManager {
long lastWaitTimestamp = System.currentTimeMillis(); long lastWaitTimestamp = System.currentTimeMillis();
boolean postProcess = false; boolean postProcess = false;
do { do {
lastWaitTimestamp += 10 * 60 * 1000;
long sleeping = lastWaitTimestamp - System.currentTimeMillis(); long sleeping = lastWaitTimestamp - System.currentTimeMillis();
if (sleeping > 0) { if (sleeping > 0) {
try { Thread.sleep(sleeping); } catch (InterruptedException e) { interrupt(); } try { Thread.sleep(sleeping); } catch (InterruptedException e) { interrupt(); }
@ -41,7 +42,6 @@ public class TrackerDataManager {
postProcess = true; postProcess = true;
logger.warn("last tracker write in this processor!"); logger.warn("last tracker write in this processor!");
} }
lastWaitTimestamp += 10 * 60 * 1000;
if (record.size() != 0) { if (record.size() != 0) {
logger.info("start writing tracker data."); logger.info("start writing tracker data.");
save(reset()); save(reset());
@ -78,6 +78,14 @@ public class TrackerDataManager {
private static void save (HashMap<Long, HashMap<Long, TreeSet<Long>>> record) { private static void save (HashMap<Long, HashMap<Long, TreeSet<Long>>> record) {
{
if (!record.containsKey(0L)) record.put(0L, new HashMap<>());
HashMap<Long, TreeSet<Long>> chatUsers = record.get(0L);
if (!chatUsers.containsKey(0L)) chatUsers.put(0L, new TreeSet<>());
TreeSet<Long> userRecords = chatUsers.get(0L);
userRecords.add(System.currentTimeMillis());
}
record.forEach((chat, chatUsers) -> chatUsers.forEach((user, userRecords) -> { record.forEach((chat, chatUsers) -> chatUsers.forEach((user, userRecords) -> {
long dayCurrent = -1; long dayCurrent = -1;
@ -103,6 +111,7 @@ public class TrackerDataManager {
e.printStackTrace(System.out); e.printStackTrace(System.out);
} }
} }
})); }));
} }