Skip to content

Commit

Permalink
fix(log-writer): 저장할 로그를 관리하는 Set을 Map으로 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
inferior3x committed Nov 27, 2024
1 parent c4f693e commit 32808d8
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

import com.whoz_in.log_writer.managed.ManagedLog;
import com.whoz_in.log_writer.managed.ManagedLogDAO;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
Expand All @@ -28,23 +30,28 @@ public MdnsLogWriter(ManagedLogDAO managedLogDAO, MdnsLogParser parser, MdnsConf

@Scheduled(fixedRate = 10000)
private void writeLogs() {
Set<ManagedLog> logs = new HashSet<>();
Map<ManagedLog, ManagedLog> logs = new HashMap<>();
this.processes.parallelStream()
.forEach(process-> {
String line;
for(;;) {
try {
line = process.readLine();
if (line == null) return;
parser.parse(line).ifPresent(logs::add);
parser.parse(line).ifPresent(
log -> {
logs.put(log, log);
//TODO: ssid 설정
}
);
} catch (Exception e){
e.printStackTrace();
}
}
});
System.out.println("[managed - mdns] 저장할 로그 개수 : " + logs.size());

managedLogDAO.insertAll(logs);
managedLogDAO.insertAll(logs.values());

logs.clear();
}
Expand Down

0 comments on commit 32808d8

Please sign in to comment.