1 package org.jboss.cache.eviction; 2 3 import org.jboss.cache.Fqn; 4 5 11 public class NodeEntry 12 { 13 private long modifiedTimeStamp; 14 private long creationTimeStamp; 15 private int numberOfNodeVisits; 16 private int numberOfElements; 17 private Fqn fqn; 18 19 private long inUseTimeoutTimestamp; 20 private boolean currentlyInUse = false; 21 22 EvictionQueue queue; 23 24 27 private NodeEntry() 28 { 29 this.creationTimeStamp = System.currentTimeMillis(); 30 } 31 32 public NodeEntry(Fqn fqn) 33 { 34 this(); 35 setFqn(fqn); 36 } 37 38 public NodeEntry(String fqn) 39 { 40 this(); 41 setFqn(Fqn.fromString(fqn)); 42 } 43 44 49 public boolean isCurrentlyInUse() 50 { 51 return currentlyInUse; 52 } 53 54 public void setCurrentlyInUse(boolean currentlyInUse, long inUseTimeout) 55 { 56 this.currentlyInUse = currentlyInUse; 57 if (inUseTimeout > 0) 58 { 59 this.inUseTimeoutTimestamp = System.currentTimeMillis() + inUseTimeout; 60 } 61 } 62 63 public long getInUseTimeoutTimestamp() 64 { 65 return this.inUseTimeoutTimestamp; 66 } 67 68 74 public long getModifiedTimeStamp() 75 { 76 return modifiedTimeStamp; 77 } 78 79 public void setModifiedTimeStamp(long modifiedTimeStamp) 80 { 81 this.modifiedTimeStamp = modifiedTimeStamp; 82 } 83 84 89 public long getCreationTimeStamp() 90 { 91 return creationTimeStamp; 92 } 93 94 public void setCreationTimeStamp(long creationTimeStamp) 95 { 96 this.creationTimeStamp = creationTimeStamp; 97 } 98 99 public int getNumberOfNodeVisits() 100 { 101 return numberOfNodeVisits; 102 } 103 104 public void setNumberOfNodeVisits(int numberOfNodeVisits) 105 { 106 this.numberOfNodeVisits = numberOfNodeVisits; 107 } 108 109 public int getNumberOfElements() 110 { 111 return numberOfElements; 112 } 113 114 public void setNumberOfElements(int numberOfElements) 115 { 116 if (queue != null) 117 { 118 int difference = numberOfElements - this.numberOfElements; 119 queue.modifyElementCount(difference); 120 } 121 this.numberOfElements = numberOfElements; 122 } 123 124 public Fqn getFqn() 125 { 126 return fqn; 127 } 128 129 void setFqn(Fqn fqn) 130 { 131 this.fqn = fqn; 132 } 133 134 public int hashCode() 135 { 136 return fqn.hashCode(); 137 } 138 139 public boolean equals(Object o) 140 { 141 if (!(o instanceof NodeEntry)) 142 return false; 143 NodeEntry ne = (NodeEntry) o; 144 return fqn.equals(ne.getFqn()); 145 } 146 147 public String toString() 148 { 149 StringBuffer output = new StringBuffer (); 150 output.append("Fqn: "); 151 if (fqn != null) 152 { 153 output.append(fqn); 154 } 155 else 156 { 157 output.append(" null"); 158 } 159 160 output.append(" CreateTime: ").append(this.getCreationTimeStamp()); 161 output.append(" NodeVisits: ").append(this.getNumberOfNodeVisits()); 162 output.append(" ModifiedTime: ").append(this.getModifiedTimeStamp()); 163 output.append(" NumberOfElements: ").append(this.getNumberOfElements()); 164 output.append(" CurrentlyInUse: ").append(this.isCurrentlyInUse()); 165 return output.toString(); 166 } 167 168 } 169 | Popular Tags |