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 * Alvaro Sanchez-Leon (alvsan09@gmail.com) - Initial API and implementation
11 *******************************************************************************/
12 package org
.eclipse
.linuxtools
.lttng
.ui
.views
.controlflow
.evProcessor
;
14 import java
.util
.HashMap
;
17 import org
.eclipse
.linuxtools
.lttng
.state
.StateStrings
;
18 import org
.eclipse
.linuxtools
.lttng
.state
.evProcessor
.AbsEventToHandlerResolver
;
19 import org
.eclipse
.linuxtools
.lttng
.state
.evProcessor
.ILttngEventProcessor
;
22 * Builds a Map from string event name to a processing handler object, the
23 * processors implement the same interface to facilitate transparent methods
26 * The map key STring is the entry point of the raw events, using a hash speeds
27 * up the resolution of the appropriate processor
32 public class FlowEventToHandlerFactory
extends AbsEventToHandlerResolver
{
33 // ========================================================================
35 // =======================================================================
36 private final Map
<String
, ILttngEventProcessor
> eventNametoBeforeProcessor
= new HashMap
<String
, ILttngEventProcessor
>();
37 private final Map
<String
, ILttngEventProcessor
> eventNametoAfterProcessor
= new HashMap
<String
, ILttngEventProcessor
>();
38 private ILttngEventProcessor finishProcesor
= null;
39 private static FlowEventToHandlerFactory instance
= null;
40 private FlowBeforeUpdateHandlers instantiateBeforeHandler
= new FlowBeforeUpdateHandlers();
41 private FlowAfterUpdateHandlers instantiateAfterHandler
= new FlowAfterUpdateHandlers();
43 // ========================================================================
45 // =======================================================================
46 private FlowEventToHandlerFactory() {
48 // Create one instance of each individual event handler and add the
49 // instance to the map
52 eventNametoBeforeProcessor
.put(
53 StateStrings
.Events
.LTT_EVENT_SYSCALL_ENTRY
.getInName(),
54 instantiateBeforeHandler
.getStateModesHandler());
56 eventNametoBeforeProcessor
.put(
57 StateStrings
.Events
.LTT_EVENT_SYSCALL_EXIT
.getInName(),
58 instantiateBeforeHandler
.getStateModesHandler());
60 eventNametoBeforeProcessor
.put(StateStrings
.Events
.LTT_EVENT_TRAP_ENTRY
61 .getInName(), instantiateBeforeHandler
.getStateModesHandler());
63 eventNametoBeforeProcessor
.put(StateStrings
.Events
.LTT_EVENT_TRAP_EXIT
64 .getInName(), instantiateBeforeHandler
.getStateModesHandler());
66 eventNametoBeforeProcessor
.put(
67 StateStrings
.Events
.LTT_EVENT_PAGE_FAULT_ENTRY
.getInName(),
68 instantiateBeforeHandler
.getStateModesHandler());
70 eventNametoBeforeProcessor
.put(
71 StateStrings
.Events
.LTT_EVENT_PAGE_FAULT_EXIT
.getInName(),
72 instantiateBeforeHandler
.getStateModesHandler());
74 eventNametoBeforeProcessor
.put(
75 StateStrings
.Events
.LTT_EVENT_PAGE_FAULT_NOSEM_ENTRY
76 .getInName(), instantiateBeforeHandler
77 .getStateModesHandler());
79 eventNametoBeforeProcessor
80 .put(StateStrings
.Events
.LTT_EVENT_PAGE_FAULT_NOSEM_EXIT
81 .getInName(), instantiateBeforeHandler
82 .getStateModesHandler());
84 eventNametoBeforeProcessor
.put(StateStrings
.Events
.LTT_EVENT_IRQ_ENTRY
85 .getInName(), instantiateBeforeHandler
.getStateModesHandler());
87 eventNametoBeforeProcessor
.put(StateStrings
.Events
.LTT_EVENT_IRQ_EXIT
88 .getInName(), instantiateBeforeHandler
.getStateModesHandler());
90 eventNametoBeforeProcessor
.put(
91 StateStrings
.Events
.LTT_EVENT_SOFT_IRQ_ENTRY
.getInName(),
92 instantiateBeforeHandler
.getStateModesHandler());
94 eventNametoBeforeProcessor
.put(
95 StateStrings
.Events
.LTT_EVENT_SOFT_IRQ_EXIT
.getInName(),
96 instantiateBeforeHandler
.getStateModesHandler());
98 eventNametoBeforeProcessor
.put(
99 StateStrings
.Events
.LTT_EVENT_SCHED_SCHEDULE
.getInName(),
100 instantiateBeforeHandler
.getBeforeSchedChangeHandler());
102 eventNametoBeforeProcessor
.put(
103 StateStrings
.Events
.LTT_EVENT_PROCESS_EXIT
.getInName(),
104 instantiateBeforeHandler
.getProcessExitHandler());
106 eventNametoBeforeProcessor
.put(
107 StateStrings
.Events
.LTT_EVENT_PROCESS_FREE
.getInName(),
108 instantiateBeforeHandler
.getProcessFreeHandler());
110 eventNametoBeforeProcessor
.put(
111 StateStrings
.Events
.LTT_EVENT_STATEDUMP_END
.getInName(),
112 instantiateBeforeHandler
.getStateDumpEndHandler());
116 eventNametoAfterProcessor
.put(
117 StateStrings
.Events
.LTT_EVENT_SCHED_SCHEDULE
.getInName(),
118 instantiateAfterHandler
.getSchedChangeHandler());
120 eventNametoAfterProcessor
.put(
121 StateStrings
.Events
.LTT_EVENT_PROCESS_FORK
.getInName(),
122 instantiateAfterHandler
.getProcessForkHandler());
124 eventNametoAfterProcessor
.put(
125 StateStrings
.Events
.LTT_EVENT_PROCESS_EXIT
.getInName(),
126 instantiateAfterHandler
.getProcessExitHandler());
128 eventNametoAfterProcessor
.put(StateStrings
.Events
.LTT_EVENT_EXEC
129 .getInName(), instantiateAfterHandler
.getProcessExecHandler());
131 eventNametoAfterProcessor
.put(
132 StateStrings
.Events
.LTT_EVENT_THREAD_BRAND
.getInName(),
133 instantiateAfterHandler
.GetThreadBrandHandler());
135 eventNametoAfterProcessor
.put(
136 StateStrings
.Events
.LTT_EVENT_PROCESS_STATE
.getInName(),
137 instantiateAfterHandler
.getEnumProcessStateHandler());
139 finishProcesor
= new FlowFinishUpdateHandler();
142 // ========================================================================
144 // =======================================================================
146 * The event processors are common to all traces an multiple instances will
147 * use more memory unnecessarily
151 public static AbsEventToHandlerResolver
getInstance() {
152 if (instance
== null) {
153 instance
= new FlowEventToHandlerFactory();
159 public ILttngEventProcessor
getAfterProcessor(String eventType
) {
160 return eventNametoAfterProcessor
.get(eventType
);
164 public ILttngEventProcessor
getBeforeProcessor(String eventType
) {
165 return eventNametoBeforeProcessor
.get(eventType
);
169 public ILttngEventProcessor
getfinishProcessor() {
170 return finishProcesor
;
174 public ILttngEventProcessor
getStateUpdaterProcessor(String eventType
) {