1 /*******************************************************************************
2 * Copyright (c) 2009 Ericsson
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * Yann N. Dauphin (dhaemon@gmail.com) - Implementation for stats
11 * Alvaro Sanchez-Leon (alvsan09@gmail.com) - Initial API and implementation
12 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.lttng
.ui
.views
.statistics
.evProcessor
;
15 import java
.util
.HashMap
;
18 import org
.eclipse
.linuxtools
.lttng
.state
.StateStrings
;
19 import org
.eclipse
.linuxtools
.lttng
.state
.evProcessor
.AbsEventToHandlerResolver
;
20 import org
.eclipse
.linuxtools
.lttng
.state
.evProcessor
.ILttngEventProcessor
;
23 * Provide the handlers that will count the CPU Time, Cumulative CPU Time and
24 * Elapsed Time and update the appropriate tree.
26 * Builds a Map from string event name to a processing handler object, the
27 * processors implement the same interface to facilitate transparent methods
30 * The map key STring is the entry point of the raw events, using a hash speeds
31 * up the resolution of the appropriate processor
36 public class StatsTimeCountHandlerFactory
extends AbsEventToHandlerResolver
{
37 // ========================================================================
39 // =======================================================================
40 private final Map
<String
, ILttngEventProcessor
> eventNametoBeforeProcessor
= new HashMap
<String
, ILttngEventProcessor
>();
41 ILttngEventProcessor afterhandler
;
42 private static StatsTimeCountHandlerFactory instance
= null;
43 private StatsTimeCountHandlers instantiateHandler
= new StatsTimeCountHandlers();
45 // ========================================================================
47 // =======================================================================
48 private StatsTimeCountHandlerFactory() {
50 //create one instance of each individual event handler and add the instance to the map
51 eventNametoBeforeProcessor
.put(StateStrings
.Events
.LTT_EVENT_SYSCALL_ENTRY
52 .getInName(), instantiateHandler
.getSyscallEntryBeforeHandler());
54 eventNametoBeforeProcessor
.put(StateStrings
.Events
.LTT_EVENT_SYSCALL_EXIT
55 .getInName(), instantiateHandler
.getsySyscallExitBeforeHandler());
57 eventNametoBeforeProcessor
.put(StateStrings
.Events
.LTT_EVENT_TRAP_ENTRY
58 .getInName(), instantiateHandler
.getTrapEntryBeforeHandler());
60 eventNametoBeforeProcessor
.put(StateStrings
.Events
.LTT_EVENT_TRAP_EXIT
61 .getInName(), instantiateHandler
.getTrapExitBeforeHandler());
63 eventNametoBeforeProcessor
.put(StateStrings
.Events
.LTT_EVENT_PAGE_FAULT_ENTRY
64 .getInName(), instantiateHandler
.getTrapEntryBeforeHandler());
66 eventNametoBeforeProcessor
.put(StateStrings
.Events
.LTT_EVENT_PAGE_FAULT_EXIT
67 .getInName(), instantiateHandler
.getTrapExitBeforeHandler());
69 eventNametoBeforeProcessor
.put(StateStrings
.Events
.LTT_EVENT_PAGE_FAULT_NOSEM_ENTRY
70 .getInName(), instantiateHandler
.getTrapEntryBeforeHandler());
72 eventNametoBeforeProcessor
.put(StateStrings
.Events
.LTT_EVENT_PAGE_FAULT_NOSEM_EXIT
73 .getInName(), instantiateHandler
.getTrapExitBeforeHandler());
75 eventNametoBeforeProcessor
.put(StateStrings
.Events
.LTT_EVENT_IRQ_ENTRY
76 .getInName(), instantiateHandler
.getIrqEntryBeforeHandler());
78 eventNametoBeforeProcessor
.put(StateStrings
.Events
.LTT_EVENT_IRQ_EXIT
79 .getInName(), instantiateHandler
.getIrqExitBeforeHandler());
81 eventNametoBeforeProcessor
.put(StateStrings
.Events
.LTT_EVENT_SOFT_IRQ_ENTRY
82 .getInName(), instantiateHandler
.getSoftIrqEntryBeforeHandler());
84 eventNametoBeforeProcessor
.put(StateStrings
.Events
.LTT_EVENT_SOFT_IRQ_EXIT
85 .getInName(), instantiateHandler
.getSoftIrqExitBeforeHandler());
87 eventNametoBeforeProcessor
.put(StateStrings
.Events
.LTT_EVENT_FUNCTION_ENTRY
88 .getInName(), instantiateHandler
.getFunctionEntryBeforeHandler());
90 eventNametoBeforeProcessor
.put(StateStrings
.Events
.LTT_EVENT_FUNCTION_EXIT
91 .getInName(), instantiateHandler
.getFunctionExitBeforeHandler());
93 eventNametoBeforeProcessor
.put(StateStrings
.Events
.LTT_EVENT_SCHED_SCHEDULE
94 .getInName(), instantiateHandler
.getSchedChangeBeforeHandler());
96 afterhandler
= instantiateHandler
.getAfterHandler();
100 // ========================================================================
102 // =======================================================================
104 * The event processors are common to all traces an multiple instances will
105 * use more memory unnecessarily
109 public static AbsEventToHandlerResolver
getInstance() {
110 if (instance
== null) {
111 instance
= new StatsTimeCountHandlerFactory();
118 public ILttngEventProcessor
getAfterProcessor(String eventType
) {
123 public ILttngEventProcessor
getBeforeProcessor(String eventType
) {
124 return eventNametoBeforeProcessor
.get(eventType
);
128 public ILttngEventProcessor
getfinishProcessor() {
129 // No finishing processor used
134 public ILttngEventProcessor
getStateUpdaterProcessor(String eventType
) {