1 | package de.ugoe.cs.eventbench.jfc.commands;
|
---|
2 |
|
---|
3 | import java.security.InvalidParameterException;
|
---|
4 | import java.util.Collection;
|
---|
5 | import java.util.List;
|
---|
6 |
|
---|
7 | import de.ugoe.cs.eventbench.CommandHelpers;
|
---|
8 | import de.ugoe.cs.eventbench.data.GlobalDataContainer;
|
---|
9 | import de.ugoe.cs.eventbench.jfc.JFCLogParser;
|
---|
10 | import de.ugoe.cs.eventbench.jfc.data.JFCEvent;
|
---|
11 | import de.ugoe.cs.eventbench.jfc.data.JFCTargetComparator;
|
---|
12 | import de.ugoe.cs.util.console.Command;
|
---|
13 | import de.ugoe.cs.util.console.Console;
|
---|
14 |
|
---|
15 | /**
|
---|
16 | * <p>
|
---|
17 | * Command to parse an XML file with sessions monitored by EventBench's
|
---|
18 | * JFCMonitor.
|
---|
19 | * </p>
|
---|
20 | *
|
---|
21 | * @author Steffen Herbold
|
---|
22 | * @version 1.0
|
---|
23 | */
|
---|
24 | public class CMDparseJFC implements Command {
|
---|
25 |
|
---|
26 | /*
|
---|
27 | * (non-Javadoc)
|
---|
28 | *
|
---|
29 | * @see de.ugoe.cs.util.console.Command#run(java.util.List)
|
---|
30 | */
|
---|
31 | @Override
|
---|
32 | public void run(List<Object> parameters) {
|
---|
33 | String filename;
|
---|
34 | String sequencesName = "sequences";
|
---|
35 |
|
---|
36 | try {
|
---|
37 | filename = (String) parameters.get(0);
|
---|
38 | if (parameters.size() >= 2) {
|
---|
39 | sequencesName = (String) parameters.get(1);
|
---|
40 | }
|
---|
41 | } catch (Exception e) {
|
---|
42 | throw new InvalidParameterException();
|
---|
43 | }
|
---|
44 | JFCTargetComparator.setMutable(true);
|
---|
45 | JFCLogParser parser = new JFCLogParser();
|
---|
46 |
|
---|
47 | parser.parseFile(filename);
|
---|
48 | Collection<List<JFCEvent>> sequences = parser.getSequences();
|
---|
49 |
|
---|
50 | Console.traceln("Pre-computing event target equalities.");
|
---|
51 | // compare all Events to a dummy event to make sure they are known by
|
---|
52 | // the JFCTargetComparator
|
---|
53 | JFCEvent dummyEvent = new JFCEvent("dummy");
|
---|
54 | for (List<JFCEvent> sequence : sequences) {
|
---|
55 | for (JFCEvent event : sequence) {
|
---|
56 | event.equals(dummyEvent);
|
---|
57 | }
|
---|
58 | }
|
---|
59 | JFCTargetComparator.setMutable(false);
|
---|
60 |
|
---|
61 | if (GlobalDataContainer.getInstance().addData(sequencesName, sequences)) {
|
---|
62 | CommandHelpers.dataOverwritten(sequencesName);
|
---|
63 | }
|
---|
64 | }
|
---|
65 |
|
---|
66 | /*
|
---|
67 | * (non-Javadoc)
|
---|
68 | *
|
---|
69 | * @see de.ugoe.cs.util.console.Command#help()
|
---|
70 | */
|
---|
71 | @Override
|
---|
72 | public void help() {
|
---|
73 | Console.println("Usage: parseJFC <filename> {<sequencesName>}");
|
---|
74 | }
|
---|
75 |
|
---|
76 | }
|
---|