Commit | Line | Data |
---|---|---|
6e512b93 ASL |
1 | /******************************************************************************* |
2 | * Copyright (c) 2009 Ericsson | |
3 | * | |
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 | |
8 | * | |
9 | * Contributors: | |
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; | |
14 | ||
15 | import java.util.HashMap; | |
16 | import java.util.Map; | |
17 | ||
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; | |
21 | ||
22 | /** | |
23 | * Provide the handlers that will count the CPU Time, Cumulative CPU Time and | |
24 | * Elapsed Time and update the appropriate tree. | |
25 | * | |
26 | * Builds a Map from string event name to a processing handler object, the | |
27 | * processors implement the same interface to facilitate transparent methods | |
28 | * call, | |
29 | * | |
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 | |
32 | * | |
33 | * @author alvaro | |
34 | * | |
35 | */ | |
36 | public class StatsTimeCountHandlerFactory extends AbsEventToHandlerResolver { | |
37 | // ======================================================================== | |
38 | // Data | |
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(); | |
44 | ||
45 | // ======================================================================== | |
46 | // Constructors | |
47 | // ======================================================================= | |
48 | private StatsTimeCountHandlerFactory() { | |
49 | super(); | |
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()); | |
53 | ||
54 | eventNametoBeforeProcessor.put(StateStrings.Events.LTT_EVENT_SYSCALL_EXIT | |
55 | .getInName(), instantiateHandler.getsySyscallExitBeforeHandler()); | |
56 | ||
57 | eventNametoBeforeProcessor.put(StateStrings.Events.LTT_EVENT_TRAP_ENTRY | |
58 | .getInName(), instantiateHandler.getTrapEntryBeforeHandler()); | |
59 | ||
60 | eventNametoBeforeProcessor.put(StateStrings.Events.LTT_EVENT_TRAP_EXIT | |
61 | .getInName(), instantiateHandler.getTrapExitBeforeHandler()); | |
62 | ||
63 | eventNametoBeforeProcessor.put(StateStrings.Events.LTT_EVENT_PAGE_FAULT_ENTRY | |
64 | .getInName(), instantiateHandler.getTrapEntryBeforeHandler()); | |
65 | ||
66 | eventNametoBeforeProcessor.put(StateStrings.Events.LTT_EVENT_PAGE_FAULT_EXIT | |
67 | .getInName(), instantiateHandler.getTrapExitBeforeHandler()); | |
68 | ||
69 | eventNametoBeforeProcessor.put(StateStrings.Events.LTT_EVENT_PAGE_FAULT_NOSEM_ENTRY | |
70 | .getInName(), instantiateHandler.getTrapEntryBeforeHandler()); | |
71 | ||
72 | eventNametoBeforeProcessor.put(StateStrings.Events.LTT_EVENT_PAGE_FAULT_NOSEM_EXIT | |
73 | .getInName(), instantiateHandler.getTrapExitBeforeHandler()); | |
74 | ||
75 | eventNametoBeforeProcessor.put(StateStrings.Events.LTT_EVENT_IRQ_ENTRY | |
76 | .getInName(), instantiateHandler.getIrqEntryBeforeHandler()); | |
77 | ||
78 | eventNametoBeforeProcessor.put(StateStrings.Events.LTT_EVENT_IRQ_EXIT | |
79 | .getInName(), instantiateHandler.getIrqExitBeforeHandler()); | |
80 | ||
81 | eventNametoBeforeProcessor.put(StateStrings.Events.LTT_EVENT_SOFT_IRQ_ENTRY | |
82 | .getInName(), instantiateHandler.getSoftIrqEntryBeforeHandler()); | |
83 | ||
84 | eventNametoBeforeProcessor.put(StateStrings.Events.LTT_EVENT_SOFT_IRQ_EXIT | |
85 | .getInName(), instantiateHandler.getSoftIrqExitBeforeHandler()); | |
86 | ||
87 | eventNametoBeforeProcessor.put(StateStrings.Events.LTT_EVENT_FUNCTION_ENTRY | |
88 | .getInName(), instantiateHandler.getFunctionEntryBeforeHandler()); | |
89 | ||
90 | eventNametoBeforeProcessor.put(StateStrings.Events.LTT_EVENT_FUNCTION_EXIT | |
91 | .getInName(), instantiateHandler.getFunctionExitBeforeHandler()); | |
92 | ||
93 | eventNametoBeforeProcessor.put(StateStrings.Events.LTT_EVENT_SCHED_SCHEDULE | |
94 | .getInName(), instantiateHandler.getSchedChangeBeforeHandler()); | |
95 | ||
96 | afterhandler = instantiateHandler.getAfterHandler(); | |
97 | ||
98 | } | |
99 | ||
100 | // ======================================================================== | |
101 | // Public methods | |
102 | // ======================================================================= | |
103 | /** | |
104 | * The event processors are common to all traces an multiple instances will | |
105 | * use more memory unnecessarily | |
106 | * | |
107 | * @return | |
108 | */ | |
109 | public static AbsEventToHandlerResolver getInstance() { | |
110 | if (instance == null) { | |
111 | instance = new StatsTimeCountHandlerFactory(); | |
112 | } | |
113 | return instance; | |
114 | } | |
115 | ||
116 | ||
117 | @Override | |
118 | public ILttngEventProcessor getAfterProcessor(String eventType) { | |
119 | return afterhandler; | |
120 | } | |
121 | ||
122 | @Override | |
123 | public ILttngEventProcessor getBeforeProcessor(String eventType) { | |
124 | return eventNametoBeforeProcessor.get(eventType); | |
125 | } | |
126 | ||
127 | @Override | |
128 | public ILttngEventProcessor getfinishProcessor() { | |
129 | // No finishing processor used | |
130 | return null; | |
131 | } | |
132 | ||
133 | @Override | |
134 | public ILttngEventProcessor getStateUpdaterProcessor(String eventType) { | |
135 | return null; | |
136 | } | |
137 | } |