Changeset 300


Ignore:
Timestamp:
12/13/11 13:39:32 (12 years ago)
Author:
sherbold
Message:
  • added command parseJFC for parsing log files created with the JFCMonitor
  • added de.ugoe.cs.eventbench.jfc.JFCLogParser for parsing of log files created with the JFCMonitor
  • added de.ugoe.cs.eventbench.jfc.data.JFCEvent for working with JFC events
Location:
trunk/EventBenchConsole/src/de/ugoe/cs
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/web/data/WebEvent.java

    r298 r300  
    1919 
    2020        /** 
     21         * <p> 
    2122         * Timestamp of the event. 
     23         * </p> 
    2224         */ 
    2325        private final long timestamp; 
  • trunk/EventBenchConsole/src/de/ugoe/cs/eventbensch/jfc/JFCLogParser.java

    r299 r300  
    99import java.security.InvalidParameterException; 
    1010import java.util.Collection; 
     11import java.util.LinkedList; 
    1112import java.util.List; 
    1213 
     
    4243         * </p> 
    4344         */ 
    44         Collection<List<JFCEvent>> sequences; 
     45        private Collection<List<JFCEvent>> sequences; 
     46 
     47        /** 
     48         * <p> 
     49         * Internal handle to the event that is currently being parsed. 
     50         * </p> 
     51         */ 
     52        private JFCEvent currentEvent; 
     53 
     54        /** 
     55         * <p> 
     56         * Internal handle to the event sequence that is currently being parsed. 
     57         * </p> 
     58         */ 
     59        private List<JFCEvent> currentSequence = null; 
     60 
     61        /** 
     62         * <p> 
     63         * Enumeration to differentiate if a parameter belongs to an event, a source 
     64         * or the parent of a source. 
     65         * </p> 
     66         *  
     67         * @author Steffen Herbold 
     68         * @version 1.0 
     69         */ 
     70        private enum ParamSource { 
     71                EVENT, SOURCE, PARENT 
     72        }; 
     73 
     74        /** 
     75         * <p> 
     76         * Specifies whether the parameters that are currently being read belong the 
     77         * the event, the source or the parent. 
     78         * </p> 
     79         */ 
     80        ParamSource paramSource = null; 
    4581 
    4682        /** 
     
    66102                if (qName.equals("newsession")) { 
    67103                        Console.traceln("start of session"); 
    68                         // TODO implement handling: newsession node 
     104                        if (currentSequence != null && currentSequence.size() != 0) { 
     105                                sequences.add(currentSequence); 
     106                                currentSequence = new LinkedList<JFCEvent>(); 
     107                        } 
    69108                } else if (qName.equals("event")) { 
    70                         // TODO implement handling: start of event node 
     109                        currentEvent = new JFCEvent(atts.getValue("id")); 
     110                        paramSource = ParamSource.EVENT; 
    71111                } else if (qName.equals("param")) { 
    72                         // TODO implement handling: param node 
     112                        if (paramSource == ParamSource.EVENT) { 
     113                                currentEvent.addParameter(atts.getValue("name"), 
     114                                                atts.getValue("value")); 
     115                        } else if (paramSource == ParamSource.SOURCE) { 
     116                                currentEvent.addSourceInformation(atts.getValue("name"), 
     117                                                atts.getValue("value")); 
     118                        } else if (paramSource == ParamSource.PARENT) { 
     119                                currentEvent.addParentInformation(atts.getValue("name"), 
     120                                                atts.getValue("value")); 
     121                        } 
     122                } else if (qName.equals("source")) { 
     123                        paramSource = ParamSource.SOURCE; 
     124                } else if (qName.equals("parent")) { 
     125                        paramSource = ParamSource.PARENT; 
    73126                } 
    74127        } 
     
    84137                        throws SAXException { 
    85138                if (qName.equals("event")) { 
    86                         // TODO implement handling: end of event node 
     139                        currentSequence.add(currentEvent); 
    87140                } else if (qName.equals("source")) { 
    88                         // TODO implement handling: end of source node 
     141                        paramSource = ParamSource.EVENT; 
    89142                } else if (qName.equals("parent")) { 
    90                         // TODO implement handling: end of parent node 
     143                        paramSource = ParamSource.SOURCE; 
    91144                } 
    92145        } 
  • trunk/EventBenchConsole/src/de/ugoe/cs/eventbensch/jfc/data/JFCEvent.java

    r299 r300  
    11package de.ugoe.cs.eventbensch.jfc.data; 
     2 
     3import java.util.HashMap; 
     4import java.util.Map; 
    25 
    36import de.ugoe.cs.eventbench.data.IReplayable; 
     
    2326        /** 
    2427         * <p> 
     28         * Internal map of parameters associated with the event. 
     29         * </p> 
     30         */ 
     31        private Map<String, String> parameters; 
     32 
     33        /** 
     34         * <p> 
     35         * Information about the event source. 
     36         * </p> 
     37         */ 
     38        private Map<String, String> sourceParameters; 
     39 
     40        /** 
     41         * <p> 
     42         * Information about the parent of the event source. 
     43         * </p> 
     44         */ 
     45        private Map<String, String> parentParameters; 
     46 
     47        /** 
     48         * <p> 
    2549         * Constructor. Creates a new JFCEvent. 
    2650         * </p> 
     
    3155        public JFCEvent(String type) { 
    3256                super(type); 
     57                parameters = new HashMap<String, String>(); 
     58        } 
     59 
     60        /** 
     61         * <p> 
     62         * Adds a new parameter to the event. 
     63         * </p> 
     64         *  
     65         * @param name 
     66         *            name of the parameter 
     67         * @param value 
     68         *            value of the parameter 
     69         */ 
     70        public void addParameter(String name, String value) { 
     71                parameters.put(name, value); 
     72        } 
     73 
     74        /** 
     75         * <p> 
     76         * Retrieves the value of a parameter. 
     77         * </p> 
     78         *  
     79         * @param name 
     80         *            name of the parameter 
     81         * @return value of the parameter 
     82         */ 
     83        public String getParameter(String name) { 
     84                return parameters.get(name); 
     85        } 
     86 
     87        /** 
     88         * <p> 
     89         * Adds new information about the source of the event. 
     90         * </p> 
     91         *  
     92         * @param name 
     93         *            name of the information 
     94         * @param value 
     95         *            value of the information 
     96         */ 
     97        public void addSourceInformation(String name, String value) { 
     98                sourceParameters.put(name, value); 
     99        } 
     100 
     101        /** 
     102         * <p> 
     103         * Retrieves information about the source of the event. 
     104         * </p> 
     105         *  
     106         * @param name 
     107         *            name of the information 
     108         * @return value of the information 
     109         */ 
     110        public String getSourceInformation(String name) { 
     111                return sourceParameters.get(name); 
     112        } 
     113 
     114        /** 
     115         * <p> 
     116         * Adds new information about the parent of the source of the event. 
     117         * </p> 
     118         *  
     119         * @param name 
     120         *            name of the information 
     121         * @param value 
     122         *            value of the information 
     123         */ 
     124        public void addParentInformation(String name, String value) { 
     125                parentParameters.put(name, value); 
     126        } 
     127 
     128        /** 
     129         * <p> 
     130         * Retrieves information about the parent of the source of the event. 
     131         * </p> 
     132         *  
     133         * @param name 
     134         *            name of the information 
     135         * @return value of the information 
     136         */ 
     137        public String getParentInformation(String name) { 
     138                return parentParameters.get(name); 
     139        } 
     140 
     141        /* 
     142         * (non-Javadoc) 
     143         *  
     144         * @see de.ugoe.cs.eventbench.data.ReplayableEvent#equals(java.lang.Object) 
     145         */ 
     146        @Override 
     147        public boolean equals(Object other) { 
     148                if (other == this) { 
     149                        return true; 
     150                } 
     151                if (other instanceof JFCEvent) { 
     152                        return super.equals(other) 
     153                                        && parameters.equals(((JFCEvent) other).parameters); 
     154                } 
     155                return false; 
     156        } 
     157 
     158        /* 
     159         * (non-Javadoc) 
     160         *  
     161         * @see de.ugoe.cs.eventbench.data.ReplayableEvent#hashCode() 
     162         */ 
     163        @Override 
     164        public int hashCode() { 
     165                int hashCode = super.hashCode(); 
     166                hashCode *= parameters.hashCode(); 
     167                return hashCode; 
    33168        } 
    34169 
Note: See TracChangeset for help on using the changeset viewer.