public boolean matches(EtmPoint aPoint) { String name = aPoint.getName(); if (validNames.contains(name)) { return true; } for (int i = 0; i < pattern.length; i++) { Matcher matcher = pattern[i].matcher(name); if (matcher.matches()) { synchronized (validNames) { validNames.add(name); } return true; } } return false; } }
public String format(EtmPoint aEtmPoint) { String parentName = aEtmPoint.getParent() == null ? "" : calculateParentHierarchie(aEtmPoint); return new StringBuffer(). append("measurementPoint=<"). append(aEtmPoint.getName()). append(">, parent=<"). append(parentName). append(">, transactionTime=<"). append(numberFormat.format(aEtmPoint.getTransactionTime())). append(">, recordingTime=<"). append(aEtmPoint.getStartTimeMillis()). append(">").toString(); }
protected String calculateParentHierarchie(EtmPoint aEtmPoint) { // todo remove string concat String hierarchie = ""; EtmPoint parent = aEtmPoint.getParent(); while (parent != null) { hierarchie = ";" + parent.getName() + hierarchie; parent = parent.getParent(); } return hierarchie.substring(1); } }
/** * @see #alterNamePostException(EtmPoint, Throwable) */ public void alterNamePostException(EtmPoint aEtmPoint, Throwable t) { aEtmPoint.alterName(aEtmPoint.getName() + " [" + calculateShortName(t.getClass()) + "]"); }
/** * Alter name in case an exception is caught during processing. Altering the * name takes place after executing target method. Ensure that you never cause * an exception within this code. * * @param aEtmPoint The EtmPoint to alter. * @param t The caught throwable t. */ protected void alterNamePostException(EtmPoint aEtmPoint, Throwable t) { aEtmPoint.alterName(aEtmPoint.getName() + " [" + calculateShortName(t.getClass()) + "]"); }
public void add(EtmPoint point) { ExecutionAggregate aggregate = getAggregate(point.getName()); aggregate.addTransaction(point); }
public void add(EtmPoint point) { ExecutionAggregate aggregate = getAggregate(point.getName()); aggregate.addTransaction(point); }
/** * Append a measurement result from the end of a tree. * * @param newTree The tree to the measurement result. */ public void appendPath(LinkedList newTree) { EtmPoint current = (EtmPoint) newTree.removeFirst(); ExecutionAggregate aggregate = getChild(current.getName()); if (newTree.size() == 0) { aggregate.addTransaction(current); } else { aggregate.appendPath(newTree); } }
/** * Append a measurement result from the end of a tree. * * @param newTree The tree to the measurement result. */ public void appendPath(LinkedList newTree) { EtmPoint current = (EtmPoint) newTree.removeFirst(); ExecutionAggregate aggregate = getChild(current.getName()); if (newTree.isEmpty()) { aggregate.addTransaction(current); } else { aggregate.appendPath(newTree); } }
public void add(EtmPoint point) { // shortcut for parent == null; if (point.getParent() == null) { ExecutionAggregate aggregate = getAggregate(point.getName()); aggregate.addTransaction(point); return; } // TODO check alternative strategy to improve performance // find tree root node LinkedList path = new LinkedList(); path.add(point); EtmPoint rootNode = point.getParent(); while (rootNode != null) { path.addFirst(rootNode); rootNode = rootNode.getParent(); } rootNode = (EtmPoint) path.removeFirst(); ExecutionAggregate aggregate = getAggregate(rootNode.getName()); aggregate.appendPath(path); }
public void add(EtmPoint point) { // shortcut for parent == null; if (point.getParent() == null) { ExecutionAggregate aggregate = getAggregate(point.getName()); aggregate.addTransaction(point); return; } // TODO check alternative strategy to improve performance // find tree root node LinkedList path = new LinkedList(); path.add(point); EtmPoint rootNode = point.getParent(); while (rootNode != null) { path.addFirst(rootNode); rootNode = rootNode.getParent(); } rootNode = (EtmPoint) path.removeFirst(); ExecutionAggregate aggregate = getAggregate(rootNode.getName()); aggregate.appendPath(path); }
public void afterPhase(PhaseEvent event) { FacesContext facesContext = event.getFacesContext(); // stop recording current phase time EtmPoint point = (EtmPoint) facesContext.getAttributes().get(CURRENT_PHASE_POINT); if (point != null) { // alter name if we encounter an exception Iterator<ExceptionQueuedEvent> it = facesContext.getExceptionHandler().getUnhandledExceptionQueuedEvents().iterator(); if (it.hasNext()) { ExceptionQueuedEvent exceptionQueuedEvent = it.next(); point.alterName(point.getName() + " [" + exceptionQueuedEvent.getContext().getException().getClass().getSimpleName() + "]"); } point.collect(); facesContext.getAttributes().remove(CURRENT_PHASE_POINT); } }
public void add(EtmPoint point) { // short cut for parent == null; if (point.getParent() == null) { super.add(point); return; } // TODO check alternative strategy to improve performance // find tree root node LinkedList path = new LinkedList(); path.add(point); EtmPoint rootNode = point.getParent(); while (rootNode != null) { path.addFirst(rootNode); rootNode = rootNode.getParent(); } rootNode = (EtmPoint) path.removeFirst(); ExecutionAggregate aggregate = getAggregate(rootNode.getName()); aggregate.appendPath(path); }
public void add(EtmPoint point) { // short cut for parent == null; if (point.getParent() == null) { super.add(point); return; } // TODO check alternative strategy to improve performance // find tree root node LinkedList path = new LinkedList(); path.add(point); EtmPoint rootNode = point.getParent(); while (rootNode != null) { path.addFirst(rootNode); rootNode = rootNode.getParent(); } rootNode = (EtmPoint) path.removeFirst(); ExecutionAggregate aggregate = getAggregate(rootNode.getName()); aggregate.appendPath(path); }
public void add(EtmPoint point) { LinkedList path = new LinkedList(); path.add(point.getName()); EtmPoint parent = point.getParent(); while (parent != null) { path.addFirst(parent.getName()); parent = parent.getParent(); } DefaultMutableTreeNode node = (DefaultMutableTreeNode) getRoot(); while (!path.isEmpty()) { String currentString = (String) path.removeFirst(); Enumeration childs = node.children(); DefaultMutableTreeNode currentChild = null; while (currentChild == null && childs.hasMoreElements()) { DefaultMutableTreeNode measurementNode = (DefaultMutableTreeNode) childs.nextElement(); Aggregate aggregate = (Aggregate) measurementNode.getUserObject(); if (aggregate.getName().equals(currentString)) { currentChild = measurementNode; } } if (currentChild == null) { currentChild = new DefaultMutableTreeNode(new ExecutionAggregate(currentString)); insertNodeInto(currentChild, node, getChildCount(currentChild)); } node = currentChild; } ((ExecutionAggregate) node.getUserObject()).addTransaction(point); nodeChanged(node); delegate.add(point); }
public void beforePhase(PhaseEvent event) { FacesContext facesContext = event.getFacesContext(); EtmPoint oldPoint = (EtmPoint) facesContext.getAttributes().get(CURRENT_PHASE_POINT); if (oldPoint != null) { // do some cleanup, should never happen actually oldPoint.alterName(oldPoint.getName() + " - uncollected"); oldPoint.collect(); } String symbolicName = "JSF Phase " + event.getPhaseId().getOrdinal() + " - " + String.valueOf(event.getPhaseId()); EtmPoint point = EtmManager.getEtmMonitor().createPoint(symbolicName); facesContext.getAttributes().put(CURRENT_PHASE_POINT, point); }
public void testOutput() { EtmPoint etmPoint = new TestPointGenerator().getEtmPoint(); DefaultOutputFormatter formatter = new DefaultOutputFormatter(); // validate MS format NumberFormat numberFormat = NumberFormat.getInstance(Locale.getDefault()); numberFormat.setMinimumFractionDigits(3); numberFormat.setMaximumFractionDigits(3); numberFormat.setGroupingUsed(false); String s = formatter.format(etmPoint); assertTrue(s.indexOf(etmPoint.getName()) > 0); if (etmPoint.getParent() != null) { assertTrue(s.indexOf("parent=<" + etmPoint.getParent().getName() + ">") > 0); } assertTrue(s.indexOf(String.valueOf(etmPoint.getStartTimeMillis())) > 0); assertTrue(s.indexOf(numberFormat.format(etmPoint.getTransactionTime())) > 0); }
private void analyzeNested(Map aggregationPoints, EtmPoint[] aEtmPoints, int i) { EtmPoint current = aEtmPoints[i - 1]; ExecutionAggregate aggregate = (ExecutionAggregate) aggregationPoints.get(current.getName()); assertNotNull(aggregate); assertEquals(current.getName(), aggregate.getName()); assertEquals(1, aggregate.getMeasurements()); assertEquals(current.getTransactionTime(), aggregate.getTotal(), 0.0); assertEquals(current.getTransactionTime(), aggregate.getMin(), 0.0); assertEquals(current.getTransactionTime(), aggregate.getMax(), 0.0); i--; if (i != 0) { assertTrue(aggregate.hasChilds()); analyzeNested(aggregate.getChilds(), aEtmPoints, i); } }