use of com.actiontech.dble.backend.mysql.xa.CoordinatorLogEntry in project dble by actiontech.
the class KVStoreRepository method getAllCoordinatorLogEntries.
@Override
public Collection<CoordinatorLogEntry> getAllCoordinatorLogEntries() {
String data = null;
try {
if (zkConn.checkExists().forPath(logPath) != null) {
try {
byte[] raw = zkConn.getData().forPath(logPath);
if (raw != null) {
data = new String(raw, StandardCharsets.UTF_8);
}
} catch (Exception e) {
LOGGER.warn(AlarmCode.CORE_ZK_WARN + "KVStoreRepository.getAllCoordinatorLogEntries error", e);
}
}
} catch (Exception e2) {
LOGGER.warn(AlarmCode.CORE_ZK_WARN + "KVStoreRepository error", e2);
}
if (data == null) {
return Collections.emptyList();
}
Map<String, CoordinatorLogEntry> coordinatorLogEntries = new HashMap<>();
String[] logs = data.split(Serializer.LINE_SEPARATOR);
for (String log : logs) {
try {
CoordinatorLogEntry coordinatorLogEntry = Deserializer.fromJson(log);
coordinatorLogEntries.put(coordinatorLogEntry.getId(), coordinatorLogEntry);
} catch (DeserializationException e) {
LOGGER.warn(AlarmCode.CORE_ZK_WARN + "Unexpected EOF - logfile not closed properly last time? ", e);
}
}
return coordinatorLogEntries.values();
}
Aggregations