/** * @param ctx invocation context * @param fqn fqn to test * @return true if the node does not exist; false otherwise. */ protected boolean nodeDoesNotExist(InvocationContext ctx, Fqn fqn) { return !dataContainer.exists(fqn); }
public Set<Fqn> getInternalFqns() { return dataContainer.getInternalFqns(); }
private List<Fqn> getNodeList(Fqn startingPoint) { return dataContainer.getNodesForEviction(startingPoint, true); } }
private void evictNode(Fqn fqn) throws Throwable { if (dataContainer.exists(fqn)) { List<Fqn> toEvict = dataContainer.getNodesForEviction(fqn, true); for (Fqn aFqn : toEvict) { EvictCommand evictFqnCommand = commandsFactory.buildEvictFqnCommand(aFqn); invoker.invoke(evictFqnCommand); } } else { if (trace) log.trace("Not evicting " + fqn + " as it doesn't exist"); } }
@ManagedOperation public Map<String, Object> dumpStatistics() { Map<String, Object> retval = new HashMap<String, Object>(); retval.put("Hits", hits); retval.put("Misses", misses); retval.put("Stores", stores); retval.put("Evictions", evictions); retval.put("NumberOfAttributes", dataContainer.getNumberOfAttributes()); retval.put("NumberOfNodes", dataContainer.getNumberOfNodes()); retval.put("ElapsedTime", getElapsedTime()); retval.put("TimeSinceReset", getTimeSinceReset()); retval.put("AverageReadTime", getAverageReadTime()); retval.put("AverageWriteTime", getAverageWriteTime()); retval.put("HitMissRatio", getHitMissRatio()); retval.put("ReadWriteRatio", getReadWriteRatio()); return retval; }
boolean evictNode(Fqn fqn, InvocationContext ctx) { notifier.notifyNodeInvalidated(fqn, true, ctx); try { return dataContainer.evict(fqn); } finally { notifier.notifyNodeInvalidated(fqn, false, ctx); } }
@Start public void setRootNode() { rootNode = dataContainer.getRoot(); }
public int getNumberOfAttributes() { return dataContainer.getNumberOfAttributes(); }
public int getNumberOfNodes() { return dataContainer.getNumberOfNodes(); }
/** * Creates a node in the cache, specified by the given Fqn. */ public Object perform(InvocationContext ctx) { Object[] results = dataContainer.createNodes(fqn); List<NodeSPI> created = (List<NodeSPI>) results[0]; boolean foundFqn = false; if (!created.isEmpty()) { for (NodeSPI n : created) { if (fqn.equals(n.getFqn())) foundFqn = true; newlyCreated.add(n.getFqn()); } } if (newlyCreated != null && !foundFqn) newlyCreated.remove(fqn); return results[1]; }
public int getNumberOfLocksHeld() { return dataContainer.getNumberOfLocksHeld(); }
List<NodeData> list = dataContainer.buildNodeData(new LinkedList<NodeData>(), (NodeSPI) actualNode, false);
@Override public Object visitRollbackCommand(InvocationContext ctx, RollbackCommand command) throws Throwable { // clean up nodesCreated map if (trace) log.trace("Removing temporarily created nodes"); // this needs to be done in reverse order. List list = ctx.getTransactionContext().getDummyNodesCreatedByCacheLoader(); if (list != null && list.size() > 0) { ListIterator i = list.listIterator(list.size()); while (i.hasPrevious()) { Fqn fqn = (Fqn) i.previous(); try { dataContainer.evict(fqn, false); } catch (CacheException e) { if (trace) log.trace("Unable to evict node " + fqn, e); } } } return invokeNextInterceptor(ctx, command); }
public String printLockInfo() { return printLockInfo(dataContainer.getRoot()); } }
@ManagedAttribute(description = "number of cache attributes") public int getNumberOfAttributes() { return dataContainer.getNumberOfAttributes(); }
@ManagedAttribute(description = "number of nodes in the cache") public int getNumberOfNodes() { return dataContainer.getNumberOfNodes(); }
@SuppressWarnings("unchecked") private NodeSPI<?, ?> createNodes(Fqn fqn, TransactionContext transactionContext) throws Exception { Object[] results = dataContainer.createNodes(fqn); List<NodeSPI<?, ?>> createdNodes = (List<NodeSPI<?, ?>>) results[0]; NodeSPI lastCreated = null; for (NodeSPI node : createdNodes) { node.setDataLoaded(false); if (transactionContext != null) { transactionContext.addDummyNodeCreatedByCacheLoader(node.getFqn()); } lastCreated = node; } // mark the leaf node as data loaded since that is what we are doing in this interceptor. if (lastCreated != null) lastCreated.setDataLoaded(true); // regardless of whether the last node was created, return it. return (NodeSPI) results[1]; }
@Override public Object visitRollbackCommand(InvocationContext ctx, RollbackCommand command) throws Throwable { // clean up nodesCreated map if (trace) log.trace("Removing temporarily created nodes from treecache"); // this needs to be done in reverse order. List list = ctx.getTransactionContext().getDummyNodesCreatedByCacheLoader(); if (list != null && list.size() > 0) { ListIterator i = list.listIterator(list.size()); while (i.hasPrevious()) { Fqn fqn = (Fqn) i.previous(); try { dataContainer.evict(fqn, false); } catch (CacheException e) { if (trace) log.trace("Unable to evict node " + fqn, e); } } } return invokeNextInterceptor(ctx, command); }