1 8 9 package com.sleepycat.je.txn; 10 11 import java.nio.ByteBuffer ; 12 import java.sql.Timestamp ; 13 14 import com.sleepycat.je.log.LogEntryType; 15 import com.sleepycat.je.log.LogReadable; 16 import com.sleepycat.je.log.LogUtils; 17 import com.sleepycat.je.log.LoggableObject; 18 import com.sleepycat.je.utilint.DbLsn; 19 20 23 public abstract class TxnEnd 24 implements LoggableObject, LogReadable { 25 26 protected long id; 27 protected Timestamp time; 28 private long lastLsn; 29 30 TxnEnd(long id, long lastLsn) { 31 this.id = id; 32 time = new Timestamp (System.currentTimeMillis()); 33 this.lastLsn = lastLsn; 34 } 35 36 39 public TxnEnd() { 40 lastLsn = DbLsn.NULL_LSN; 41 } 42 43 46 public long getId() { 47 return id; 48 } 49 50 long getLastLsn() { 51 return lastLsn; 52 } 53 54 protected abstract String getTagName(); 55 56 59 60 63 public abstract LogEntryType getLogType(); 64 65 69 public boolean marshallOutsideWriteLatch() { 70 return true; 71 } 72 73 76 public boolean countAsObsoleteWhenLogged() { 77 return false; 78 } 79 80 83 public void postLogWork(long justLoggedLsn) { 84 } 85 86 89 public int getLogSize() { 90 return LogUtils.LONG_BYTES + 91 LogUtils.getTimestampLogSize() + 92 LogUtils.getLongLogSize(); } 94 95 98 public void writeToLog(ByteBuffer logBuffer) { 99 LogUtils.writeLong(logBuffer, id); 100 LogUtils.writeTimestamp(logBuffer, time); 101 LogUtils.writeLong(logBuffer, lastLsn); 102 } 103 104 107 public void readFromLog(ByteBuffer logBuffer, byte entryTypeVersion) { 108 id = LogUtils.readLong(logBuffer); 109 time = LogUtils.readTimestamp(logBuffer); 110 lastLsn = LogUtils.readLong(logBuffer); 111 } 112 113 116 public void dumpLog(StringBuffer sb, boolean verbose) { 117 sb.append("<").append(getTagName()); 118 sb.append(" id=\"").append(id); 119 sb.append("\" time=\"").append(time); 120 sb.append("\">"); 121 sb.append(DbLsn.toString(lastLsn)); 122 sb.append("</").append(getTagName()).append(">"); 123 } 124 125 128 public boolean logEntryIsTransactional() { 129 return true; 130 } 131 132 135 public long getTransactionId() { 136 return id; 137 } 138 } 139 | Popular Tags |