private RecoveryInformation TryOpenRecoveryInfoFile() { RecoveryInformation result = null; Tracer.Debug("Checking for Recoverable Transactions filename: " + Filename); lock (syncRoot) { try { if (!File.Exists(Filename)) { return(null); } using (FileStream recoveryLog = new FileStream(Filename, FileMode.Open, FileAccess.Read)) { Tracer.Debug("Found Recovery Log File: " + Filename); IFormatter formatter = new BinaryFormatter(); result = formatter.Deserialize(recoveryLog) as RecoveryInformation; } } catch (Exception ex) { Tracer.ErrorFormat("Error while opening Recovery file {0} error message: {1}", Filename, ex.Message); // Nothing to restore. return(null); } } return(result); }
public void LogRecoveryInfo(XATransactionId xid, byte[] recoveryInformation) { if (recoveryInformation == null || recoveryInformation.Length == 0) { return; } try { lock (syncRoot) { RecoveryInformation info = new RecoveryInformation(xid, recoveryInformation); Tracer.Debug("Serializing Recovery Info to file: " + Filename); IFormatter formatter = new BinaryFormatter(); using (FileStream recoveryLog = new FileStream(Filename, FileMode.OpenOrCreate, FileAccess.Write)) { formatter.Serialize(recoveryLog, info); } } } catch (Exception ex) { Tracer.Error("Error while storing TX Recovery Info, message: " + ex.Message); throw; } }
public KeyValuePair <XATransactionId, byte[]>[] GetRecoverables() { KeyValuePair <XATransactionId, byte[]>[] result = new KeyValuePair <XATransactionId, byte[]> [0]; RecoveryInformation info = TryOpenRecoveryInfoFile(); if (info != null) { result = new KeyValuePair <XATransactionId, byte[]> [1]; result[0] = new KeyValuePair <XATransactionId, byte[]>(info.Xid, info.TxRecoveryInfo); } return(result); }