1 8 9 package com.sleepycat.je.recovery; 10 11 import java.nio.ByteBuffer ; 12 import java.sql.Timestamp ; 13 import java.util.Calendar ; 14 15 import com.sleepycat.je.log.LogEntryType; 16 import com.sleepycat.je.log.LogException; 17 import com.sleepycat.je.log.LogReadable; 18 import com.sleepycat.je.log.LogUtils; 19 import com.sleepycat.je.log.LoggableObject; 20 21 25 public class CheckpointStart implements LoggableObject, LogReadable { 26 27 private Timestamp startTime; 28 private long id; 29 30 35 private String invoker; 36 37 public CheckpointStart(long id, String invoker) { 38 Calendar cal = Calendar.getInstance(); 39 this.startTime = new Timestamp (cal.getTime().getTime()); 40 this.id = id; 41 if (invoker == null) { 42 this.invoker = ""; 43 } else { 44 this.invoker = invoker; 45 } 46 } 47 48 49 public CheckpointStart() { 50 } 51 52 55 56 59 public LogEntryType getLogType() { 60 return LogEntryType.LOG_CKPT_START; 61 } 62 63 67 public boolean marshallOutsideWriteLatch() { 68 return true; 69 } 70 71 74 public boolean countAsObsoleteWhenLogged() { 75 return false; 76 } 77 78 81 public void postLogWork(long justLoggedLsn) { 82 } 83 84 87 public int getLogSize() { 88 return LogUtils.getTimestampLogSize() + 89 LogUtils.getLongLogSize() + 90 LogUtils.getStringLogSize(invoker); 91 } 92 93 96 public void writeToLog(ByteBuffer logBuffer) { 97 LogUtils.writeTimestamp(logBuffer, startTime); 98 LogUtils.writeLong(logBuffer, id); 99 LogUtils.writeString(logBuffer, invoker); 100 } 101 102 105 public void readFromLog(ByteBuffer logBuffer, byte entryTypeVersion) 106 throws LogException { 107 108 startTime = LogUtils.readTimestamp(logBuffer); 109 id = LogUtils.readLong(logBuffer); 110 invoker = LogUtils.readString(logBuffer); 111 } 112 113 116 public void dumpLog(StringBuffer sb, boolean verbose) { 117 sb.append("<CkptStart invoker=\"").append(invoker); 118 sb.append("\" time=\"").append(startTime); 119 sb.append("\" id=\"").append(id); 120 sb.append("\"/>"); 121 } 122 123 126 public boolean logEntryIsTransactional() { 127 return false; 128 } 129 130 133 public long getTransactionId() { 134 return 0; 135 } 136 } 137 | Popular Tags |