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
.tests
.state
.handlers
.before
;
14 import java
.util
.HashMap
;
17 import org
.eclipse
.linuxtools
.lttng
.state
.StateStrings
;
18 import org
.eclipse
.linuxtools
.lttng
.state
.evProcessor
.IEventProcessing
;
21 * Builds a Map from string event name to a processing handler object, the
22 * processors implement the same interface to facilitate transparent methods
25 * The map key STring is the entry point of the raw events, using a hash speeds
26 * up the resolution of the appropriate processor
31 public class StateBeforeUpdateFactory
{
32 // ========================================================================
34 // =======================================================================
35 private final Map
<String
, IEventProcessing
> eventNametoProcessor
= new HashMap
<String
, IEventProcessing
>();
36 private static StateBeforeUpdateFactory instance
= null;
37 private StateBeforeUpdateHandlers instantiateHandler
= new StateBeforeUpdateHandlers();
39 // ========================================================================
41 // =======================================================================
42 private StateBeforeUpdateFactory() {
43 //create one instance of each individual event handler and add the instance to the map
44 eventNametoProcessor
.put(StateStrings
.Events
.LTT_EVENT_SYSCALL_ENTRY
45 .getInName(), instantiateHandler
.getSyscallEntryHandler());
47 eventNametoProcessor
.put(StateStrings
.Events
.LTT_EVENT_SYSCALL_EXIT
48 .getInName(), instantiateHandler
.getsySyscallExitHandler());
50 // eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_TRAP_ENTRY
51 // .getInName(), instantiateHandler.getTrapEntryHandler());
53 // eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_TRAP_EXIT
54 // .getInName(), instantiateHandler.getTrapExitHandler());
56 // eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_PAGE_FAULT_ENTRY
57 // .getInName(), instantiateHandler.getTrapEntryHandler());
59 // eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_PAGE_FAULT_EXIT
60 // .getInName(), instantiateHandler.getTrapExitHandler());
62 // eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_PAGE_FAULT_NOSEM_ENTRY
63 // .getInName(), instantiateHandler.getTrapEntryHandler());
65 // eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_PAGE_FAULT_NOSEM_EXIT
66 // .getInName(), instantiateHandler.getTrapExitHandler());
68 // eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_IRQ_ENTRY
69 // .getInName(), instantiateHandler.getIrqEntryHandler());
71 // eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_IRQ_EXIT
72 // .getInName(), instantiateHandler.getIrqExitHandler());
74 // eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_SOFT_IRQ_RAISE
75 // .getInName(), instantiateHandler.getSoftIrqRaiseHandler());
77 // eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_SOFT_IRQ_ENTRY
78 // .getInName(), instantiateHandler.getSoftIrqEntryHandler());
80 // eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_SOFT_IRQ_EXIT
81 // .getInName(), instantiateHandler.getSoftIrqExitHandler());
83 // eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_LIST_INTERRUPT
84 // .getInName(), instantiateHandler.getEnumInterruptHandler());
86 // eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_REQUEST_ISSUE
87 // .getInName(), instantiateHandler.getBdevRequestIssueHandler());
89 // eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_REQUEST_COMPLETE
90 // .getInName(), instantiateHandler.getBdevRequestCompleteHandler());
92 // eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_FUNCTION_ENTRY
93 // .getInName(), instantiateHandler.getFunctionEntryHandler());
95 // eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_FUNCTION_EXIT
96 // .getInName(), instantiateHandler.getFunctionExitHandler());
98 // eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_SYS_CALL_TABLE
99 // .getInName(), instantiateHandler.getDumpSyscallHandler());
101 // eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_KPROBE_TABLE
102 // .getInName(), instantiateHandler.getDumpKprobeHandler());
104 // eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_SOFTIRQ_VEC
105 // .getInName(), instantiateHandler.getDumpSoftIrqHandler());
107 // eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_SCHED_SCHEDULE
108 // .getInName(), instantiateHandler.getSchedChangeHandler());
110 // eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_PROCESS_FORK
111 // .getInName(), instantiateHandler.getProcessForkHandler());
113 // eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_KTHREAD_CREATE
114 // .getInName(), instantiateHandler.getProcessKernelThreadHandler());
116 // eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_PROCESS_EXIT
117 // .getInName(), instantiateHandler.getProcessExitHandler());
119 // eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_PROCESS_FREE
120 // .getInName(), instantiateHandler.getProcessFreeHandler());
122 // eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_EXEC
123 // .getInName(), instantiateHandler.getProcessExecHandler());
125 // eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_THREAD_BRAND
126 // .getInName(), instantiateHandler.GetThreadBrandHandler());
128 // eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_STATEDUMP_END
129 // .getInName(), instantiateHandler.getStateDumpEndHandler());
131 // eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_PROCESS_STATE
132 // .getInName(), instantiateHandler.getEnumProcessStateHandler());
137 // ========================================================================
139 // =======================================================================
141 * The event processors are common to all traces an multiple instances will
142 * use more memory unnecessarily
146 public static StateBeforeUpdateFactory
getInstance() {
147 if (instance
== null) {
148 instance
= new StateBeforeUpdateFactory();
155 * @return The Event Handler corresponding to the type of event
157 public IEventProcessing
getEventNametoProcessor(String eventType
) {
158 return eventNametoProcessor
.get(eventType
);