1 21 22 package org.continuent.sequoia.controller.recoverylog.events; 23 24 import java.sql.PreparedStatement ; 25 import java.sql.SQLException ; 26 27 import org.continuent.sequoia.common.i18n.Translate; 28 import org.continuent.sequoia.common.log.Trace; 29 import org.continuent.sequoia.controller.recoverylog.LoggerThread; 30 31 37 public class LogRequestCompletionEvent implements LogEvent 38 { 39 private long logId; 40 private boolean success; 41 private long execTime; 42 private int updateCount; 43 private long completionLogId; 44 45 56 public LogRequestCompletionEvent(long logId, boolean success, 57 int updateCount, long execTime, long completionLogId) 58 { 59 this.logId = logId; 60 this.success = success; 61 this.execTime = execTime; 62 this.updateCount = updateCount; 63 this.completionLogId = completionLogId; 64 } 65 66 69 public boolean belongToTransaction(long tid) 70 { 71 return false; 72 } 73 74 77 public void execute(LoggerThread loggerThread) 78 { 79 Trace logger = loggerThread.getLogger(); 80 try 81 { 82 if (logger.isDebugEnabled()) 83 logger.debug(Translate 84 .get("recovery.jdbc.loggerthread.log.info", logId)); 85 86 PreparedStatement pstmt = loggerThread.getUpdatePreparedStatement(); 87 if (success) 88 pstmt.setString(1, LogEntry.SUCCESS); 89 else 90 pstmt.setString(1, LogEntry.FAILED); 91 pstmt.setInt(2, updateCount); 92 pstmt.setLong(3, execTime); 93 pstmt.setLong(4, completionLogId); 94 pstmt.setLong(5, logId); 95 if (logger.isDebugEnabled()) 96 logger.debug(pstmt.toString()); 97 int updatedRows = pstmt.executeUpdate(); 98 if (updatedRows != 1) 99 logger 100 .error("Recovery log was unable to update request completion status: " 101 + pstmt.toString()); 102 } 103 catch (SQLException e) 104 { 105 loggerThread.invalidateLogStatements(); 106 logger.error(Translate.get( 107 "recovery.jdbc.loggerthread.log.update.failed", new String []{ 108 Long.toString(logId), Boolean.toString(success)}), e); 109 loggerThread.putBackAtHeadOfQueue(this, e); 111 } 112 } 113 114 117 public String toString() 118 { 119 return "LogRequestCompletionEvent id " + logId + ", success=" + success; 120 } 121 122 } 123 | Popular Tags |