From e6e0975de4dfa84dffc4767a237925cf209f7d03 Mon Sep 17 00:00:00 2001 From: Ryan Lee Date: Fri, 14 Oct 2011 18:37:40 -0700 Subject: [PATCH] instrumenting to track lens caching --- .../src/edu/mit/simile/backstage/ScriptableBackstage.java | 1 - .../MOD-INF/src/edu/mit/simile/backstage/model/Context.java | 3 +++ .../src/edu/mit/simile/backstage/model/data/Database.java | 5 ++++- .../edu/mit/simile/backstage/model/ui/views/TileView.java | 5 +++++ 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/modules/backstage/MOD-INF/src/edu/mit/simile/backstage/ScriptableBackstage.java b/modules/backstage/MOD-INF/src/edu/mit/simile/backstage/ScriptableBackstage.java index 61b3350..8a2fb87 100644 --- a/modules/backstage/MOD-INF/src/edu/mit/simile/backstage/ScriptableBackstage.java +++ b/modules/backstage/MOD-INF/src/edu/mit/simile/backstage/ScriptableBackstage.java @@ -17,7 +17,6 @@ public class ScriptableBackstage extends BackstageScriptableObject { private static final long serialVersionUID = -6840851588510351185L; - @SuppressWarnings("unused") protected static Logger _logger = LoggerFactory.getLogger("backstage.scriptable"); public static String getName() { diff --git a/modules/backstage/MOD-INF/src/edu/mit/simile/backstage/model/Context.java b/modules/backstage/MOD-INF/src/edu/mit/simile/backstage/model/Context.java index f2a1b7b..e8a1a6d 100644 --- a/modules/backstage/MOD-INF/src/edu/mit/simile/backstage/model/Context.java +++ b/modules/backstage/MOD-INF/src/edu/mit/simile/backstage/model/Context.java @@ -88,10 +88,13 @@ public void configure(Scriptable config, BackChannel backChannel) { } public Scriptable generateLens(String itemID) { + _logger.debug("> generateLens"); String key = "lens-rendering:" + itemID; + _logger.debug("itemID: " + key); Scriptable result = (Scriptable) getDatabase().cacheAndRun(key, new LensRenderingCacheableQuery(itemID)); + _logger.debug("< generateLens"); return result; } diff --git a/modules/backstage/MOD-INF/src/edu/mit/simile/backstage/model/data/Database.java b/modules/backstage/MOD-INF/src/edu/mit/simile/backstage/model/data/Database.java index 5e19246..ec21183 100644 --- a/modules/backstage/MOD-INF/src/edu/mit/simile/backstage/model/data/Database.java +++ b/modules/backstage/MOD-INF/src/edu/mit/simile/backstage/model/data/Database.java @@ -98,12 +98,15 @@ public void discardCacheableQuery(String key) { } public Object cacheAndRun(String key, CacheableQuery cq) { + _logger.debug("> cacheAndRun"); if (_cacheableQueries.containsKey(key)) { + _logger.debug("cached: " + key); cq = _cacheableQueries.get(key); // use the old one } else { + _logger.debug("not cached"); _cacheableQueries.put(key, cq); } - + _logger.debug("< cacheAndRun"); return cq.run(); } diff --git a/modules/backstage/MOD-INF/src/edu/mit/simile/backstage/model/ui/views/TileView.java b/modules/backstage/MOD-INF/src/edu/mit/simile/backstage/model/ui/views/TileView.java index 0eae1d1..a6ee2cc 100644 --- a/modules/backstage/MOD-INF/src/edu/mit/simile/backstage/model/ui/views/TileView.java +++ b/modules/backstage/MOD-INF/src/edu/mit/simile/backstage/model/ui/views/TileView.java @@ -27,13 +27,16 @@ public TileView(Context context, String id) { @Override public Scriptable getComponentState() { + _logger.debug("> getComponentState"); TupleQueryBuilder builder = new TupleQueryBuilder(); Var itemVar = getCollection().getRestrictedItems(builder, null); String key = "tile-view-rendering:" + builder.getStringSerialization(); + _logger.debug("component: " + key); Scriptable result = (Scriptable) _context.getDatabase().cacheAndRun(key, new ViewRenderingCacheableQuery(builder, itemVar)); + _logger.debug("< getComponentState"); return result; } @@ -48,6 +51,7 @@ protected class ViewRenderingCacheableQuery extends CacheableQuery { @Override protected Object internalRun() { + _logger.debug("> internalRun"); Database database = _context.getDatabase(); DefaultScriptableObject result = new DefaultScriptableObject(); @@ -90,6 +94,7 @@ protected Object internalRun() { result.put("items", result, itemIDs.toArray()); result.put("lenses", result, lenses.toArray()); + _logger.debug("< internalRun"); return result; } }