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
.AbsEventProcessorFactory
;
20 import org
.eclipse
.linuxtools
.lttng
.state
.evProcessor
.IEventProcessing
;
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 AbsEventProcessorFactory
{
37 // ========================================================================
39 // =======================================================================
40 private final Map
<String
, IEventProcessing
> eventNametoBeforeProcessor
= new HashMap
<String
, IEventProcessing
>();
41 private final Map
<String
, IEventProcessing
> eventNametoAfterProcessor
= new HashMap
<String
, IEventProcessing
>();
42 private static StatsTimeCountHandlerFactory instance
= null;
43 private StatsTimeCountHandlers instantiateHandler
= new StatsTimeCountHandlers();
45 // ========================================================================
47 // =======================================================================
48 private StatsTimeCountHandlerFactory() {
49 //create one instance of each individual event handler and add the instance to the map
50 eventNametoBeforeProcessor
.put(StateStrings
.Events
.LTT_EVENT_SYSCALL_ENTRY
51 .getInName(), instantiateHandler
.getSyscallEntryBeforeHandler());
53 eventNametoBeforeProcessor
.put(StateStrings
.Events
.LTT_EVENT_SYSCALL_EXIT
54 .getInName(), instantiateHandler
.getsySyscallExitBeforeHandler());
56 eventNametoBeforeProcessor
.put(StateStrings
.Events
.LTT_EVENT_TRAP_ENTRY
57 .getInName(), instantiateHandler
.getTrapEntryBeforeHandler());
59 eventNametoBeforeProcessor
.put(StateStrings
.Events
.LTT_EVENT_TRAP_EXIT
60 .getInName(), instantiateHandler
.getTrapExitBeforeHandler());
62 eventNametoBeforeProcessor
.put(StateStrings
.Events
.LTT_EVENT_PAGE_FAULT_ENTRY
63 .getInName(), instantiateHandler
.getTrapEntryBeforeHandler());
65 eventNametoBeforeProcessor
.put(StateStrings
.Events
.LTT_EVENT_PAGE_FAULT_EXIT
66 .getInName(), instantiateHandler
.getTrapExitBeforeHandler());
68 eventNametoBeforeProcessor
.put(StateStrings
.Events
.LTT_EVENT_PAGE_FAULT_NOSEM_ENTRY
69 .getInName(), instantiateHandler
.getTrapEntryBeforeHandler());
71 eventNametoBeforeProcessor
.put(StateStrings
.Events
.LTT_EVENT_PAGE_FAULT_NOSEM_EXIT
72 .getInName(), instantiateHandler
.getTrapExitBeforeHandler());
74 eventNametoBeforeProcessor
.put(StateStrings
.Events
.LTT_EVENT_IRQ_ENTRY
75 .getInName(), instantiateHandler
.getIrqEntryBeforeHandler());
77 eventNametoBeforeProcessor
.put(StateStrings
.Events
.LTT_EVENT_IRQ_EXIT
78 .getInName(), instantiateHandler
.getIrqExitBeforeHandler());
80 eventNametoBeforeProcessor
.put(StateStrings
.Events
.LTT_EVENT_SOFT_IRQ_ENTRY
81 .getInName(), instantiateHandler
.getSoftIrqEntryBeforeHandler());
83 eventNametoBeforeProcessor
.put(StateStrings
.Events
.LTT_EVENT_SOFT_IRQ_EXIT
84 .getInName(), instantiateHandler
.getSoftIrqExitBeforeHandler());
86 eventNametoBeforeProcessor
.put(StateStrings
.Events
.LTT_EVENT_FUNCTION_ENTRY
87 .getInName(), instantiateHandler
.getFunctionEntryBeforeHandler());
89 eventNametoBeforeProcessor
.put(StateStrings
.Events
.LTT_EVENT_FUNCTION_EXIT
90 .getInName(), instantiateHandler
.getFunctionExitBeforeHandler());
92 eventNametoBeforeProcessor
.put(StateStrings
.Events
.LTT_EVENT_SCHED_SCHEDULE
93 .getInName(), instantiateHandler
.getSchedChangeBeforeHandler());
95 eventNametoAfterProcessor
.put(StateStrings
.Events
.LTT_EVENT_SCHED_SCHEDULE
96 .getInName(), instantiateHandler
.getSchedChangeAfterHandler());
100 // ========================================================================
102 // =======================================================================
104 * The event processors are common to all traces an multiple instances will
105 * use more memory unnecessarily
109 public static AbsEventProcessorFactory
getInstance() {
110 if (instance
== null) {
111 instance
= new StatsTimeCountHandlerFactory();
118 public IEventProcessing
getAfterProcessor(String eventType
) {
119 return eventNametoAfterProcessor
.get(eventType
);
123 public IEventProcessing
getBeforeProcessor(String eventType
) {
124 return eventNametoBeforeProcessor
.get(eventType
);
128 public IEventProcessing
getfinishProcessor() {
129 // No finishing processor used