X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=source%2Fmir%2Fstorage%2Fstore%2FStoreContainer.java;h=e5c79c51a7c4fc04d9dd43b9131d261a87e0e369;hb=aa6c03501a1cca8714ce094d566769540045c1ab;hp=53256d7c4a0f406d72e786ce98573b8ead1bc373;hpb=c6a2204d8d75293256fd17c07e54971d7672359a;p=mir.git
diff --git a/source/mir/storage/store/StoreContainer.java b/source/mir/storage/store/StoreContainer.java
index 53256d7c..e5c79c51 100755
--- a/source/mir/storage/store/StoreContainer.java
+++ b/source/mir/storage/store/StoreContainer.java
@@ -16,7 +16,8 @@ package mir.storage.store;
*/
import java.util.*;
-import mir.misc.Logfile;
+import javax.servlet.http.*;
+import mir.misc.*;
public class StoreContainer {
@@ -26,17 +27,24 @@ public class StoreContainer {
private LinkedList container;
private StoreContainerType stocType;
- private int maxSize=DEFAULT_SIZE;
- private int uniqueId;
+ private int maxSize=DEFAULT_SIZE, uniqueId;
private int addCount=0,removeCount=0,storeOutCount;
private int hitCount=0,missCount=0;
+ private static ObjectStore o_store = ObjectStore.getInstance();
- private StoreContainer() {};
+ // avoid construction without parameters
+ private StoreContainer() {};
public StoreContainer(StoreContainerType stoc_type) {
this.uniqueId=++uniqueCounter;
this.stocType=stoc_type;
this.container=new LinkedList();
+ int defaultSize = stoc_type.getDefaultSize();
+ String confProperty = stoc_type.getConfPrefix()+".DefaultSize";
+ String confedSize = o_store.getConfProperty(confProperty);
+ if ( confedSize!=null ) {
+ this.maxSize = StringUtil.parseInt (confedSize, defaultSize);
+ }
}
public StoreContainer(StoreContainerType stoc_type, int maxSize) {
@@ -44,9 +52,11 @@ public class StoreContainer {
this.maxSize=maxSize;
}
+
+
public synchronized StorableObject use(StoreIdentifier sid) {
int hit = container.indexOf(sid);
- if (hit>0) {
+ if (hit>=0) {
StoreIdentifier hitSid = (StoreIdentifier)container.get(hit);
if ( hitSid!=null ) {
hitCount++;
@@ -143,6 +153,11 @@ public class StoreContainer {
* @return String
*/
public String toString() {
+ return toHtml(null);
+ }
+
+ public String toHtml(HttpServletRequest req) {
+ boolean showingContent=false;
float hitRatio=0;
long divisor=hitCount+missCount;
if (divisor>0) hitRatio=(float)hitCount/(float)divisor;
@@ -150,14 +165,35 @@ public class StoreContainer {
StringBuffer sb = new StringBuffer("StoreContainer id: ");
sb.append(uniqueId).append(" for ");
- sb.append(stocType.toString()).append("\n [current/maximum size: ");
+ sb.append(stocType.toString());
+ if ( req!=null ) {
+ String show = req.getParameter("stoc_show");
+ if ( show!=null && show.equals(""+uniqueId) ) {
+ // show all entries in container
+ sb.append(" [showing]");
+ showingContent=true;
+ }
+ else
+ sb.append(" [show]");
+ }
+ sb.append("\n [current/maximum size: ");
sb.append(container.size()).append("/").append(maxSize);
sb.append("]\n [added/stored out/removed: ").append(addCount).append("/");
sb.append(storeOutCount).append("/").append(removeCount).append("]\n [hit/miss/ratio: ");
sb.append(hitCount).append("/").append(missCount).append("/");
sb.append(hitRatio).append("%]\n");
- /** @todo list members ? */
+ if (showingContent) {
+ sb.append(" Container contains following references:\n ");
+ ListIterator it = container.listIterator();
+ while ( it.hasNext() ) {
+ StoreIdentifier sid = (StoreIdentifier)it.next();
+ sb.append(sid.toString()).append("\n ");
+ }
+ sb.append("End of List\n\n");
+
+ }
+
return sb.toString();
}