1 package com.quadcap.sql; 2 3 40 41 import java.io.Externalizable ; 42 import java.io.File ; 43 import java.io.IOException ; 44 import java.io.ObjectInput ; 45 import java.io.ObjectOutput ; 46 47 import java.util.Properties ; 48 49 import com.quadcap.sql.file.DatafileRoot; 50 51 56 public class DatabaseRoot implements Externalizable , DatafileRoot { 57 int buildNumber = -1; 58 long tableIndexNode = -1; 59 long indexIndexNode = -1; 60 long forwardDepsNode = -1; 61 long reverseDepsNode = -1; 62 long blobRefCountRoot = -1; 63 long nextTransId = 1; 64 String dbFileName = null; 65 String unused1 = null; 66 String unused2 = null; 67 String backupDir = null; 68 69 70 int backupCount = 1; 71 72 73 int backupDays = 0; 74 75 76 int backupTime = 0; 77 78 79 int backupLastDay = -1; 80 81 String backupFormat = "xml.gz"; 82 83 Database db; 84 85 88 public DatabaseRoot() {} 89 90 93 public DatabaseRoot(Database db, String dbFileName, Properties props) 94 throws IOException 95 { 96 this.dbFileName = dbFileName; 97 this.unused2 = ""; 98 this.unused1 = ""; 99 this.buildNumber = Version.buildNumber; 100 tableIndexNode = db.getFile().newPage(); 101 indexIndexNode = db.getFile().newPage(); 102 forwardDepsNode = db.getFile().newPage(); 103 reverseDepsNode = db.getFile().newPage(); 104 blobRefCountRoot = db.getFile().newPage(); 105 backupDir = props.getProperty("backup-directory"); 106 } 107 108 111 public void setDatabase(Database db) { 112 this.db = db; 113 } 114 115 118 public int getBuildNumber() { return buildNumber; } 119 120 123 public long getRelationIndexNode() { return tableIndexNode; } 124 125 128 public long getIndexIndexNode() { return indexIndexNode; } 129 130 133 public long getForwardDepsNode() { return forwardDepsNode; } 134 135 138 public long getReverseDepsNode() { return reverseDepsNode; } 139 140 143 public long getBlobRefCountRoot() { return blobRefCountRoot; } 144 145 148 public long getNextTransId() { return nextTransId++; } 149 150 153 public String getBackupDir() { return backupDir; } 154 155 158 public int getBackupCount() { return backupCount; } 159 160 163 public int getBackupDays() { return backupDays; } 164 165 168 public int getBackupLastDay() { return backupLastDay; } 169 170 173 public int getBackupTime() { return backupTime; } 174 175 178 public String getBackupFormat() { return backupFormat; } 179 180 183 public void setBackupDir(String dir) { backupDir = dir; } 184 185 188 public void setBackupCount(int count) { backupCount = count; } 189 190 193 public void setBackupDays(int days) { backupDays = days; } 194 195 198 public void setBackupLastDay(int day) { backupLastDay = day; } 199 200 203 public void setBackupTime(int time) { backupTime = time; } 204 205 208 public void setBackupFormat(String fmt) { backupFormat = fmt; } 209 210 213 public void setNextTransId(long id) { nextTransId = id; } 214 215 218 public void readExternal(ObjectInput in) 219 throws IOException , ClassNotFoundException 220 { 221 buildNumber = in.readInt(); 222 tableIndexNode = in.readLong(); 223 indexIndexNode = in.readLong(); 224 forwardDepsNode = in.readLong(); 225 reverseDepsNode = in.readLong(); 226 blobRefCountRoot = in.readLong(); 227 nextTransId = in.readLong(); 228 dbFileName = (String )in.readObject(); 229 unused2 = (String )in.readObject(); 230 unused1 = (String )in.readObject(); 231 backupDir = (String )in.readObject(); 232 backupCount = in.readInt(); 233 backupDays = in.readInt(); 234 backupLastDay = in.readInt(); 235 backupTime = in.readInt(); 236 backupFormat = (String )in.readObject(); 237 } 238 239 242 public void writeExternal(ObjectOutput out) throws IOException { 243 out.writeInt(buildNumber); 244 out.writeLong(tableIndexNode); 245 out.writeLong(indexIndexNode); 246 out.writeLong(forwardDepsNode); 247 out.writeLong(reverseDepsNode); 248 out.writeLong(blobRefCountRoot); 249 out.writeLong(nextTransId); 250 out.writeObject(dbFileName); 251 out.writeObject(unused2); 252 out.writeObject(unused1); 253 out.writeObject(backupDir); 254 out.writeInt(backupCount); 255 out.writeInt(backupDays); 256 out.writeInt(backupLastDay); 257 out.writeInt(backupTime); 258 out.writeObject(backupFormat); 259 } 260 } 261 | Popular Tags |