Search in sources :

Example 6 with CoordinatorLogEntry

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();
}
Also used : HashMap(java.util.HashMap) DeserializationException(com.actiontech.dble.backend.mysql.xa.recovery.DeserializationException) DeserializationException(com.actiontech.dble.backend.mysql.xa.recovery.DeserializationException) CoordinatorLogEntry(com.actiontech.dble.backend.mysql.xa.CoordinatorLogEntry)

Aggregations

CoordinatorLogEntry (com.actiontech.dble.backend.mysql.xa.CoordinatorLogEntry)6 DeserializationException (com.actiontech.dble.backend.mysql.xa.recovery.DeserializationException)4 HashMap (java.util.HashMap)2 TxState (com.actiontech.dble.backend.mysql.xa.TxState)1 ErrorPacket (com.actiontech.dble.net.mysql.ErrorPacket)1