[52] | 1 | package de.ugoe.cs.eventbench.windows.commands;
|
---|
[1] | 2 |
|
---|
| 3 | import java.security.InvalidParameterException;
|
---|
[203] | 4 | import java.util.Collection;
|
---|
[1] | 5 | import java.util.List;
|
---|
[229] | 6 | import java.util.SortedSet;
|
---|
[1] | 7 |
|
---|
[240] | 8 | import de.ugoe.cs.eventbench.CommandHelpers;
|
---|
[1] | 9 | import de.ugoe.cs.eventbench.data.GlobalDataContainer;
|
---|
[297] | 10 | import de.ugoe.cs.eventbench.windows.MFCLogParser;
|
---|
[413] | 11 | import de.ugoe.cs.eventbench.windows.data.MFCTargetComparator;
|
---|
[229] | 12 | import de.ugoe.cs.eventbench.windows.data.WindowTree;
|
---|
[198] | 13 | import de.ugoe.cs.eventbench.windows.data.WindowsEvent;
|
---|
[1] | 14 | import de.ugoe.cs.util.console.Command;
|
---|
| 15 | import de.ugoe.cs.util.console.Console;
|
---|
| 16 |
|
---|
[171] | 17 | /**
|
---|
| 18 | * <p>
|
---|
| 19 | * Command to parse an XML file with sessions monitored by EventBench's
|
---|
| 20 | * MFCUsageMonitor.
|
---|
| 21 | * </p>
|
---|
| 22 | *
|
---|
| 23 | * @author Steffen Herbold
|
---|
| 24 | * @version 1.0
|
---|
| 25 | */
|
---|
[1] | 26 | public class CMDparseXML implements Command {
|
---|
| 27 |
|
---|
[183] | 28 | /*
|
---|
| 29 | * (non-Javadoc)
|
---|
| 30 | *
|
---|
[171] | 31 | * @see de.ugoe.cs.util.console.Command#help()
|
---|
| 32 | */
|
---|
[1] | 33 | @Override
|
---|
| 34 | public void help() {
|
---|
[183] | 35 | Console.println("Usage: parseXML <filename> {<sequencesName>} {<countMessageOccurences>}");
|
---|
[1] | 36 | }
|
---|
| 37 |
|
---|
[183] | 38 | /*
|
---|
| 39 | * (non-Javadoc)
|
---|
| 40 | *
|
---|
[171] | 41 | * @see de.ugoe.cs.util.console.Command#run(java.util.List)
|
---|
| 42 | */
|
---|
[1] | 43 | @Override
|
---|
| 44 | public void run(List<Object> parameters) {
|
---|
| 45 | String filename;
|
---|
[183] | 46 | String sequencesName = "sequences";
|
---|
[1] | 47 | boolean countMessageOccurences = false;
|
---|
[171] | 48 |
|
---|
[1] | 49 | try {
|
---|
| 50 | filename = (String) parameters.get(0);
|
---|
[183] | 51 | if (parameters.size() >= 2) {
|
---|
| 52 | sequencesName = (String) parameters.get(1);
|
---|
| 53 | }
|
---|
| 54 | if (parameters.size() >= 3) {
|
---|
[171] | 55 | countMessageOccurences = Boolean
|
---|
[183] | 56 | .parseBoolean((String) parameters.get(2));
|
---|
[1] | 57 | }
|
---|
| 58 | } catch (Exception e) {
|
---|
| 59 | throw new InvalidParameterException();
|
---|
| 60 | }
|
---|
[171] | 61 |
|
---|
[297] | 62 | MFCLogParser parser = new MFCLogParser(countMessageOccurences);
|
---|
[1] | 63 | parser.parseFile(filename);
|
---|
[171] | 64 |
|
---|
[203] | 65 | Collection<List<WindowsEvent>> sequences = parser.getSequences();
|
---|
[413] | 66 |
|
---|
| 67 | Console.traceln("Pre-computing event target equalities.");
|
---|
| 68 | // compare all Events to a dummy event to make sure they are known by
|
---|
| 69 | // the MFCTargetComparator
|
---|
| 70 | WindowsEvent dummyEvent = new WindowsEvent("dummy");
|
---|
| 71 | for (List<WindowsEvent> sequence : sequences) {
|
---|
| 72 | for (WindowsEvent event : sequence) {
|
---|
| 73 | event.equals(dummyEvent);
|
---|
| 74 | }
|
---|
| 75 | }
|
---|
| 76 | MFCTargetComparator.setMutable(false);
|
---|
| 77 |
|
---|
[229] | 78 | SortedSet<String> targets = WindowTree.getInstance().getTargets();
|
---|
[171] | 79 |
|
---|
[183] | 80 | if (GlobalDataContainer.getInstance().addData(sequencesName, sequences)) {
|
---|
[240] | 81 | CommandHelpers.dataOverwritten(sequencesName);
|
---|
[171] | 82 | }
|
---|
[240] | 83 | if (GlobalDataContainer.getInstance().addData(
|
---|
| 84 | sequencesName + "_targets", targets)) {
|
---|
| 85 | CommandHelpers.dataOverwritten(sequencesName + "_targets");
|
---|
[229] | 86 | }
|
---|
[1] | 87 | }
|
---|
| 88 |
|
---|
| 89 | }
|
---|