From b513223fe175f29a5ec52a1731d16ec6edfeea69 Mon Sep 17 00:00:00 2001 From: Francois Chouinard Date: Tue, 20 Oct 2009 18:11:26 +0000 Subject: [PATCH] [292397] Improve the search of Local UI model Process --- .../ui/model/trange/TimeRangeComposite.java | 2 +- .../model/trange/TimeRangeEventProcess.java | 13 + .../ui/views/controlflow/ControlFlowView.java | 19 +- .../evProcessor/AbsFlowTRangeUpdate.java | 4 +- .../FlowTRangeAfterUpdateHandlers.java | 12 +- .../FlowTRangeBeforeUpdateHandlers.java | 31 +- .../FlowTRangeFinishUpdateHandler.java | 2 +- .../model/FlowProcessContainer.java | 277 ++++++++++++------ .../resources/model/ResourceContainer.java | 98 ++----- 9 files changed, 254 insertions(+), 204 deletions(-) diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/model/trange/TimeRangeComposite.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/model/trange/TimeRangeComposite.java index 9bd391cf7c..b9a728632b 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/model/trange/TimeRangeComposite.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/model/trange/TimeRangeComposite.java @@ -186,7 +186,7 @@ ITmfTimeAnalysisEntry { } /** - * Reset this resource to the construction state except for + * Reset this resource to the construction state */ public void reset() { getChildEventComposites().clear(); diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/model/trange/TimeRangeEventProcess.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/model/trange/TimeRangeEventProcess.java index 66dab7927e..bceef5f6cd 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/model/trange/TimeRangeEventProcess.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/model/trange/TimeRangeEventProcess.java @@ -51,6 +51,19 @@ public class TimeRangeEventProcess extends TimeRangeComposite implements // ======================================================================== // Methods // ======================================================================= + + + /** + * Interface to add children to this process + * + * @param newEvent + */ + public void addChildren(TimeRangeEvent newEvent) { + if ((newEvent != null)) { + this.ChildEventLeafs.add(newEvent); + } + } + /** * @return */ diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/controlflow/ControlFlowView.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/controlflow/ControlFlowView.java index cbf3df9cfa..e3c3fd13d8 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/controlflow/ControlFlowView.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/controlflow/ControlFlowView.java @@ -1146,12 +1146,10 @@ public class ControlFlowView extends AbsTimeUpdateView implements TmfTimeRange trange) { if (clearAllData) { FlowModelFactory.getProcContainer().clearProcesses(); - // Obtain the current process list - Vector processList = FlowModelFactory + // Obtain the current process array + TimeRangeEventProcess[] processArr = FlowModelFactory .getProcContainer().readProcesses(); - // convert it to an Array as expected by the widget - TimeRangeEventProcess[] processArr = processList - .toArray(new TimeRangeEventProcess[processList.size()]); + // initialise to an empty model flowModelUpdates(processArr, -1, -1, false); @@ -1186,12 +1184,9 @@ public class ControlFlowView extends AbsTimeUpdateView implements experimentStartTime = experimentTimeRange.getStartTime().getValue(); experimentEndTime = experimentTimeRange.getEndTime().getValue(); } - // Obtain the current process list - Vector processList = FlowModelFactory + // Obtain the current process array + TimeRangeEventProcess[] processArr = FlowModelFactory .getProcContainer().readProcesses(); - // convert it to an Array as expected by the widget - TimeRangeEventProcess[] processArr = processList - .toArray(new TimeRangeEventProcess[processList.size()]); // Sort the array by pid Arrays.sort(processArr); @@ -1214,8 +1209,8 @@ public class ControlFlowView extends AbsTimeUpdateView implements if (TraceDebug.isDEBUG()) { int eventCount = 0; Long count = smanager.getEventCount(); - for (TimeRangeEventProcess process : processList) { - eventCount += process.getTraceEvents().size(); + for ( int pos = 0; poscpu,&birth,trace_num); - TimeRangeEventProcess localProcess = procContainer.findProcess(process_in.getPid(), process_in.getCreation_time().getValue(), traceSt.getTraceId() ); + TimeRangeEventProcess localProcess = procContainer.findProcess(process_in.getPid(), process_in.getCpu(), traceSt.getTraceId(),process_in.getCreation_time().getValue() ); if ( localProcess == null ) { if ( (pid_in == 0) || (pid_in != process_in.getPpid()) ) { @@ -139,7 +139,7 @@ class FlowTRangeAfterUpdateHandlers { LttngProcessState process_child = lttv_state_find_process(traceSt, trcEvent.getCpuId(), child_pid ); if ( process_child != null ) { - TimeRangeEventProcess localProcess = procContainer.findProcess(process_child.getPid(), process_child.getCreation_time().getValue(), traceSt.getTraceId() ); + TimeRangeEventProcess localProcess = procContainer.findProcess(process_child.getPid(), process_child.getCpu(), traceSt.getTraceId(), process_child.getCreation_time().getValue() ); if ( localProcess == null ) { if ( (child_pid == 0) || (child_pid != process_child.getPpid()) ) { @@ -198,7 +198,7 @@ class FlowTRangeAfterUpdateHandlers { // if(likely(process_list->current_hash_data[trace_num][cpu] != NULL) ){ // hashed_process_data = process_list->current_hash_data[trace_num][cpu]; // } - TimeRangeEventProcess localProcess = procContainer.findProcess(process.getPid(), process.getCreation_time().getValue(), traceSt.getTraceId()); + TimeRangeEventProcess localProcess = procContainer.findProcess(process.getPid(), process.getCpu(), traceSt.getTraceId(), process.getCreation_time().getValue()); if ( localProcess == null ) { if ( (process.getPid() == 0) || (process.getPid() != process.getPpid()) ) { @@ -246,7 +246,7 @@ class FlowTRangeAfterUpdateHandlers { if ( process != null ) { - TimeRangeEventProcess localProcess = procContainer.findProcess(process.getPid(), process.getCreation_time().getValue(), traceSt.getTraceId()); + TimeRangeEventProcess localProcess = procContainer.findProcess(process.getPid(), process.getCpu(), traceSt.getTraceId(), process.getCreation_time().getValue()); if ( localProcess == null ) { if ( (process.getPid() == 0) || (process.getPid() != process.getPpid()) ) { @@ -302,7 +302,7 @@ class FlowTRangeAfterUpdateHandlers { // if(likely(process_list->current_hash_data[trace_num][cpu] != NULL) ){ // hashed_process_data = process_list->current_hash_data[trace_num][cpu]; // } - TimeRangeEventProcess localProcess = procContainer.findProcess(process.getPid(), process.getCreation_time().getValue(), traceSt.getTraceId()); + TimeRangeEventProcess localProcess = procContainer.findProcess(process.getPid(), process.getCpu(), traceSt.getTraceId(), process.getCreation_time().getValue()); if ( localProcess == null ) { if ( (process.getPid() == 0) || (process.getPid() != process.getPpid()) ) { @@ -382,7 +382,7 @@ class FlowTRangeAfterUpdateHandlers { LttngProcessState process_in = lttv_state_find_process(traceSt, trcEvent.getCpuId(), pid_in ); if ( process_in != null ) { - TimeRangeEventProcess localProcess = procContainer.findProcess(process_in.getPid(), process_in.getCreation_time().getValue(), traceSt.getTraceId()); + TimeRangeEventProcess localProcess = procContainer.findProcess(process_in.getPid(), process_in.getCpu(), traceSt.getTraceId(), process_in.getCreation_time().getValue()); if (localProcess == null) { if ( (process_in.getPid() == 0) || (process_in.getPid() != process_in.getPpid()) ) { diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/controlflow/evProcessor/FlowTRangeBeforeUpdateHandlers.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/controlflow/evProcessor/FlowTRangeBeforeUpdateHandlers.java index c381ea6006..cec3cc7ea1 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/controlflow/evProcessor/FlowTRangeBeforeUpdateHandlers.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/controlflow/evProcessor/FlowTRangeBeforeUpdateHandlers.java @@ -64,8 +64,8 @@ class FlowTRangeBeforeUpdateHandlers { // it // may change TimeRangeEventProcess localProcess = procContainer - .findProcess(stateProcess.getPid(), stateProcess - .getCreation_time().getValue(), traceId); + .findProcess(stateProcess.getPid(), stateProcess.getCpu(), traceId, stateProcess + .getCreation_time().getValue()); // Add process to process list if not present if (localProcess == null) { @@ -147,9 +147,8 @@ class FlowTRangeBeforeUpdateHandlers { // hashed_process_data = // processlist_get_process_data(process_list,pid_out,process->cpu,&birth,trace_num); TimeRangeEventProcess localProcess = procContainer - .findProcess(process.getPid(), process - .getCreation_time().getValue(), traceSt - .getTraceId()); + .findProcess(process.getPid(), process.getCpu(), traceSt + .getTraceId(), process.getCreation_time().getValue()); // Add process to process list if not present // Replace C Call : @@ -183,9 +182,8 @@ class FlowTRangeBeforeUpdateHandlers { // processlist_get_process_data(process_list, pid_in, // tfs->cpu, &birth, trace_num); TimeRangeEventProcess localProcess = procContainer - .findProcess(process.getPid(), process - .getCreation_time().getValue(), traceSt - .getTraceId()); + .findProcess(process.getPid(), process.getCpu(), traceSt + .getTraceId(), process.getCreation_time().getValue()); // Add process to process list if not present // Replace C Call : @@ -258,9 +256,8 @@ class FlowTRangeBeforeUpdateHandlers { // processlist_get_process_data(process_list, pid, // process->cpu, &birth,trace_num); TimeRangeEventProcess localProcess = procContainer - .findProcess(process.getPid(), process - .getCreation_time().getValue(), traceSt - .getTraceId()); + .findProcess(process.getPid(), process.getCpu(), traceSt + .getTraceId(), process.getCreation_time().getValue()); // Add process to process list if not present // Replace C Call : @@ -327,9 +324,9 @@ class FlowTRangeBeforeUpdateHandlers { // hashed_process_data = // processlist_get_process_data(process_list,pid,process->cpu,&birth,trace_num); TimeRangeEventProcess localProcess = procContainer - .findProcess(process.getPid(), process - .getCreation_time().getValue(), traceSt - .getTraceId()); + .findProcess(process.getPid(), process.getCpu(), traceSt + .getTraceId(), process + .getCreation_time().getValue()); // This is as it was in the C ... ? if (localProcess == null) { @@ -396,9 +393,9 @@ class FlowTRangeBeforeUpdateHandlers { // hashed_process_data = // processlist_get_process_data(process_list,pid,process->cpu,&birth,trace_num); TimeRangeEventProcess localProcess = procContainer - .findProcess(process.getPid(), process - .getCreation_time().getValue(), traceSt - .getTraceId()); + .findProcess(process.getPid(), process.getCpu(), traceSt + .getTraceId(), process + .getCreation_time().getValue()); // Add process to process list if not present if (localProcess == null) { diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/controlflow/evProcessor/FlowTRangeFinishUpdateHandler.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/controlflow/evProcessor/FlowTRangeFinishUpdateHandler.java index f759c9173a..dbaeb542df 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/controlflow/evProcessor/FlowTRangeFinishUpdateHandler.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/controlflow/evProcessor/FlowTRangeFinishUpdateHandler.java @@ -41,7 +41,7 @@ public class FlowTRangeFinishUpdateHandler extends AbsFlowTRangeUpdate long endReqTime = traceSt.getInputDataRef().getTraceTimeWindow() .getEndTime().getValue(); TraceDebug.debug("Number of localProcesses: " - + procContainer.readProcesses().size()); + + procContainer.readProcesses().length); // to identify the process relevant to the traceState String traceId = traceSt.getTraceId(); int numLocalFound = 0; diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/controlflow/model/FlowProcessContainer.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/controlflow/model/FlowProcessContainer.java index 3b04c8dfa5..535b88958c 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/controlflow/model/FlowProcessContainer.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/controlflow/model/FlowProcessContainer.java @@ -7,16 +7,17 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Alvaro Sanchez-Leon (alvsan09@gmail.com) - Initial API and implementation + * Alvaro Sanchez-Leon - Initial API and implementation *******************************************************************************/ package org.eclipse.linuxtools.lttng.ui.views.controlflow.model; -import java.util.Vector; +import java.util.HashMap; +import java.util.Iterator; import org.eclipse.linuxtools.lttng.ui.model.trange.TimeRangeEventProcess; /** - * Common location to allocate the processes in use by the Control flow view + * Contains the processes in use by the Control flow view * * @author alvaro * @@ -25,9 +26,9 @@ public class FlowProcessContainer { // ======================================================================== // Data // ======================================================================== - private final Vector processes = new Vector(); - private int idgen = 0; - + private final HashMap allProcesses = new HashMap(); + private static Integer uniqueId = 0; + // ======================================================================== // Constructor // ======================================================================== @@ -43,103 +44,197 @@ public class FlowProcessContainer { // Methods // ======================================================================== /** - * Interface to add processes. + * Interface to add a new process.

+ * + * Note : Process with the same key will be overwritten, it's calling function job to make sure the new process is unique. * - * @param process + * @param newProcess The process to add */ - public void addProcesse(TimeRangeEventProcess process) { - if (process != null) { - processes.add(process); + public void addProcess(TimeRangeEventProcess newProcess) { + if (newProcess != null) { + allProcesses.put(new ProcessKey(newProcess), newProcess); } } - + /** - * This method is intended for ready only purposes in order to keep the - * internal data structure in Synch - * - * @return - */ - public Vector readProcesses() { - return processes; + * Request a unique ID + * + * @return Integer + */ + public Integer getUniqueId() { + return uniqueId++; + } + + /** + * This method is intended for read only purposes in order to keep the + * internal data structure in synch + * + * @return TimeRangeEventProcess[] + */ + public TimeRangeEventProcess[] readProcesses() { + // This allow us to return an Array of the correct type of the exact correct dimension, without looping + return allProcesses.values().toArray(new TimeRangeEventProcess[allProcesses.size()]); } - + /** - * Clear the children information for processes related to a specific trace - * e.g. just before refreshing data with a new time range - * - * @param traceId - */ + * Clear the children information for processes related to a specific trace + * e.g. just before refreshing data with a new time range + * + * @param traceId The trace unique id (trace name?) on which we need to eliminate children. + */ public void clearChildren(String traceId) { - String procTraceId; - for (TimeRangeEventProcess process : processes) { - procTraceId = process.getTraceID(); - if (procTraceId.equals(traceId)) { - process.reset(); - } - } + TimeRangeEventProcess process = null; + Iterator iterator = allProcesses.keySet().iterator(); + + while (iterator.hasNext()) { + process = allProcesses.get(iterator.next()); + + if (process.getTraceID().equals(traceId)) { + // Reset clear childEventComposites() and traceEvents() + // Also restore the nextGoodTime to the insertionTime for the drawing + process.reset(); + } + } } - + /** - * Clear all process items - */ - public void clearProcesses() { - processes.clear(); - } - - /** - * remove the processes related to a specific trace e.g. during trace - * removal - * - * @param traceId - */ + * Clear all process items + */ + public void clearProcesses() { + allProcesses.clear(); + } + + /** + * Remove the process related to a specific trace e.g. during trace + * removal + * + * @param traceId The trace unique id (trace name?) on which we want to remove process + */ public void removeProcesses(String traceId) { - String procTraceId; - for (TimeRangeEventProcess process : processes) { - procTraceId = process.getTraceID(); - if (procTraceId.equals(traceId)) { - // Children and traceEvent will get claimed by the garbage collector when process is unreferenced - // Therefore, we don't need to removed them - processes.remove(process); - } - } - } - - /** - * A match is returned if the three arguments received match an entry in the - * Map, otherwise null is returned - * - * @param pid - * @param creationtime - * @param traceID - * @return - */ - public TimeRangeEventProcess findProcess(Long pid, Long creationtime, - String traceID) { - TimeRangeEventProcess rprocess = null; - - // TODO: This needs a more efficient way to find, e.g. use class with - // hash code base on the keys trace, pid and creation time the class - // should also override the equals to valid the search via the hashcode - for (TimeRangeEventProcess process : processes) { - if (process.getPid().equals(pid)) { - if (process.getCreationTime().equals(creationtime)) { - if (process.getTraceID().equals(traceID)) { - return process; - } - } - } - } - - return rprocess; + ProcessKey iterKey = null; + + Iterator iterator = allProcesses.keySet().iterator(); + while (iterator.hasNext()) { + iterKey = iterator.next(); + + if (allProcesses.get(iterKey).getTraceID().equals(traceId)) { + allProcesses.remove(iterKey); + } + } } + + /** + * Search by keys (pid, cpuId, traceId and creationTime)

+ * + * A match is returned if the four arguments received match an entry + * Otherwise null is returned + * + * @param searchedPid The processId (Pid) we are looking for + * @param searchedCpuId The cpu Id we are looking for + * @param searchedTraceID The traceId (trace name?) we are looking for + * @param searchedCreationtime The creation time we are looking for + * + * @return TimeRangeEventProcess + */ + public TimeRangeEventProcess findProcess(Long searchedPid, Long searchedCpuId, String searchedTraceID, Long searchedCreationtime) { + // Get the TimeRangeEventProcess associated to a key we create here + TimeRangeEventProcess foundProcess = allProcesses.get( new ProcessKey(searchedPid, searchedCpuId, searchedTraceID, searchedCreationtime) ); + + return foundProcess; + } +} - /** - * Generate a unique process id while building the process list - * - * @return - */ - public int bookProcId() { - return idgen++; - } +class ProcessKey { + private TimeRangeEventProcess valueRef = null; + + private Long pid = null; + private Long cpuId = null; + private String traceId = null; + private Long creationtime = null; + + @SuppressWarnings("unused") + private ProcessKey() { } + + public ProcessKey(TimeRangeEventProcess newRef) { + valueRef = newRef; + } + + public ProcessKey(Long newPid, Long newCpuId, String newTraceId, Long newCreationTime) { + pid = newPid; + cpuId = newCpuId; + traceId = newTraceId; + creationtime = newCreationTime; + } + + @Override + public boolean equals(Object obj) { + boolean isSame = false; + + if ( obj instanceof ProcessKey ) { + ProcessKey procKey = (ProcessKey) obj; + if ( (procKey.getPid().equals(this.getPid()) ) && + (procKey.getTraceId().equals(this.getTraceId()) ) && + (procKey.getCpuId().equals(this.getCpuId()) ) && + (procKey.getCreationtime().equals(this.getCreationtime()) ) ) + { + isSame = true; + } + } + + return isSame; + } + + // *** WARNING : Everything in there work because the check "valueRef != null" is the same for ALL getter + // Do NOT change this check without checking. + public Long getPid() { + if ( valueRef != null ) { + return valueRef.getPid(); + } + else { + return pid; + } + } + + public Long getCpuId() { + if ( valueRef != null ) { + return valueRef.getCpu(); + } + else { + return cpuId; + } + } + + public String getTraceId() { + if ( valueRef != null ) { + return valueRef.getTraceID(); + } + else { + return traceId; + } + } + + public Long getCreationtime() { + if ( valueRef != null ) { + return valueRef.getCreationTime(); + } + else { + return creationtime; + } + } + + @Override + public int hashCode() { + return this.toString().hashCode(); + } + + + @Override + public String toString() { + if ( valueRef != null ) { + return (valueRef.getPid().toString() + ":" + valueRef.getCpu().toString() + ":" + valueRef.getTraceID().toString() + ":" + valueRef.getCreationTime().toString()); + } + + return (pid + ":" + cpuId + ":" + traceId + ":" + creationtime); + } } diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/resources/model/ResourceContainer.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/resources/model/ResourceContainer.java index ff2e6dcc34..74ba240b41 100644 --- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/resources/model/ResourceContainer.java +++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/resources/model/ResourceContainer.java @@ -7,7 +7,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Alvaro Sanchez-Leon (alvsan09@gmail.com) - Initial API and implementation + * Alvaro Sanchez-Leon - Initial API and implementation *******************************************************************************/ package org.eclipse.linuxtools.lttng.ui.views.resources.model; @@ -25,10 +25,16 @@ import org.eclipse.linuxtools.lttng.ui.model.trange.TimeRangeEventResource.Resou * */ public class ResourceContainer { - + // ======================================================================== + // Data + // ======================================================================== private final HashMap resources = new HashMap(); private static Integer uniqueId = 0; + + // ======================================================================== + // Constructor + // ======================================================================== /** * Package level constructor */ @@ -45,7 +51,9 @@ public class ResourceContainer { } } - + // ======================================================================== + // Methods + // ======================================================================== /** * Request a unique ID * @@ -73,7 +81,6 @@ public class ResourceContainer { * @param traceId */ public void clearChildren(String traceId) { - TimeRangeEventResource newRes = null; Iterator iterator = resources.keySet().iterator(); @@ -94,7 +101,7 @@ public class ResourceContainer { } /** - * remove the resources related to a specific trace e.g. during trace + * Remove the resources related to a specific trace e.g. during trace * removal * * @param traceId @@ -114,82 +121,24 @@ public class ResourceContainer { /** - * Obtain a resource id from resource attributes
- *
- * Note : Slow as hell and defeat the purpose of the map. - * This function probably shouldn't be used, except for testing. - * - */ - public Long findUniqueIdOfresource(Long startTime, Long endTime, String name, String groupName, String className, ResourceTypes type, String traceId) { - - Long foundId = null; - - ResourceKey newKey = null; - TimeRangeEventResource newContent = null; - - Iterator iterator = resources.keySet().iterator(); - while ( (iterator.hasNext()) && (foundId == null) ) { - newKey = iterator.next(); - newContent = resources.get(newKey); - - if ( ( newContent.getStartTime() == startTime ) && ( newContent.getStopTime() == endTime ) && ( newContent.getName() == name ) && - ( newContent.getGroupName() == groupName ) && ( newContent.getClassName() == className ) && ( newContent.getType() == type ) && - ( newContent.getTraceId() == traceId ) ) - { - foundId = newKey.getResourceId(); - } - } - - return foundId; - - } - - /** - * Search by keys (resourceId, traceId and type)
- *
+ * Search by keys (resourceId, traceId and type)

+ * * A match is returned if the three arguments received match an entry * Otherwise null is returned + * + * @param searchedId The ressourceId we are looking for + * @param searchedType The ressourceType we are looking for + * @param searchedTraceId The traceId (trace name?) we are looking for * - * @return + * @return TimeRangeEventResource */ public TimeRangeEventResource findResource(Long searchedId, ResourceTypes searchedType, String searchedTraceId) { - - TimeRangeEventResource foundResource = null; - // Get the EventResource associated to a key we create here - TimeRangeEventResource tmpRes = resources.get( new ResourceKey(searchedId, searchedTraceId, searchedType) ); - - if ( tmpRes != null ) { - foundResource = tmpRes; - } + TimeRangeEventResource foundResource = resources.get( new ResourceKey(searchedId, searchedTraceId, searchedType) ); return foundResource; } - /** - * Search by name
- *
- * A match is returned if the four arguments received match an entry in the - * Otherwise null is returned - * - * @return - */ - public TimeRangeEventResource findResourceFilterByName(Long searchedId, ResourceTypes searchedType, String searchedTraceId, String searchedName) { - - TimeRangeEventResource foundResource = null; - - // Get the EventResource asociated to a key we create here - TimeRangeEventResource tmpRes = resources.get( new ResourceKey(searchedId, searchedTraceId, searchedType) ); - - if ( tmpRes != null ) { - if ( tmpRes.getName().equals(searchedName) ) { - foundResource = tmpRes; - } - } - - return foundResource; - } - /* * MAIN : For testing only! */ @@ -313,8 +262,9 @@ class ResourceKey { @Override public String toString() { - return (getResourceId().toString() + ":" + getTraceId().toString() + ":" + getType().toString()); - + if ( valueRef != null ) { + return (valueRef.getResourceId().toString() + ":" + valueRef.getTraceId().toString() + ":" + valueRef.getType().toString()); + } + return (resourceId + ":" + traceId + ":" + type); } } - -- 2.34.1