1 24 package org.objectweb.jalisto.se.impl.server.page.info; 25 26 import org.objectweb.jalisto.se.impl.InFileAddress; 27 28 import java.util.ArrayList ; 29 30 public class InMemoryPageInfo { 31 32 protected InMemoryPageInfo(PageInfo pageInfo) { 33 ifa = pageInfo.getPageIfa(); 34 freeSpaceSize = pageInfo.getEmptySpace(); 35 transactionalImage = -1; 36 pid = pageInfo.getPid(); 37 } 38 39 public void getAFreeSpace(Object sessionId) { 40 freeSpaceSize--; 41 } 42 43 public void freeASpace(Object sessionId) { 44 freeSpaceSize++; 45 } 46 47 public int getFreeSpaceSize() { 48 return freeSpaceSize; 49 } 50 51 public InFileAddress getInstancePageIfa() { 52 return ifa; 53 } 54 55 public Object getPid() { 56 return pid; 57 } 58 59 public String toString() { 60 return "IMPO:" + freeSpaceSize + "@" + ifa.getAddress(); 61 } 62 63 public void begin(Object sessionId) { 64 transactionalImage = freeSpaceSize; 65 } 66 67 public boolean rollback(Object sessionId) { 68 if (transactionalImage < 0) { 69 return false; 70 } 71 freeSpaceSize = transactionalImage; 72 return true; 73 } 74 75 private InFileAddress ifa; 76 protected int freeSpaceSize; 77 private int transactionalImage; 78 private Object pid; 79 80 81 public static InMemoryPageInfo createNewInstance(ArrayList sessionIds, boolean isMonoImplementation, 82 PageInfo pageInfo) { 83 if (isMonoImplementation) { 84 return new InMemoryPageInfo(pageInfo); 85 } else { 86 return new InMemoryPageInfoMulti(sessionIds, pageInfo); 87 } 88 } 89 } 90 | Popular Tags |