Changeset 5cffd17c6e77c2634aa900dbfa5a0385fa9cf9e8
- Timestamp:
- 11/11/09 20:37:20
(4 years ago)
- Author:
- Theo Schlossnagle <jesus@omniti.com>
- git-committer:
- Theo Schlossnagle <jesus@omniti.com> 1257971840 +0000
- git-parent:
[8f8ea5729bc7adce9e392ef0eb4ab5c6755f9dcd]
- git-author:
- Theo Schlossnagle <jesus@omniti.com> 1257971840 +0000
- Message:
pretty hefty refactoring using reflection stuff to allow registering StratconMessage? types on-the-fly. Supports batching. All else should function as it did (no API/ABI/payload BC breakages that I'm aware of). refs #217
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| rb4d0df9 |
r5cffd17 |
|
| 31 | 31 | com/omniti/reconnoiter/broker/AMQListener.java \ |
|---|
| 32 | 32 | com/omniti/reconnoiter/broker/BrokerFactory.java \ |
|---|
| | 33 | com/omniti/reconnoiter/event/NoitEvent.java \ |
|---|
| 33 | 34 | com/omniti/reconnoiter/event/NoitCheck.java \ |
|---|
| 34 | 35 | com/omniti/reconnoiter/event/NoitStatus.java \ |
|---|
| | 36 | com/omniti/reconnoiter/event/NoitMetric.java \ |
|---|
| 35 | 37 | com/omniti/reconnoiter/event/NoitMetricText.java \ |
|---|
| 36 | 38 | com/omniti/reconnoiter/event/NoitMetricNumeric.java \ |
|---|
| … | … | |
| 51 | 53 | com/omniti/reconnoiter/IEPEngine.java \ |
|---|
| 52 | 54 | com/omniti/reconnoiter/StratconConfig.java \ |
|---|
| 53 | | com/omniti/reconnoiter/StratconMessage.java |
|---|
| | 55 | com/omniti/reconnoiter/StratconMessage.java \ |
|---|
| | 56 | com/omniti/reconnoiter/StratconMessageFactory.java |
|---|
| 54 | 57 | |
|---|
| 55 | 58 | SUPPORT=lib/activemq-all-5.2.0.jar lib/antlr-runtime-3.1.1.jar lib/esper-3.2.0.jar \ |
|---|
| r7ebe017 |
r5cffd17 |
|
| 21 | 21 | this.broker = broker; |
|---|
| 22 | 22 | } |
|---|
| | 23 | public EPServiceProvider getService() { return epService; } |
|---|
| | 24 | public IMQBroker getBroker() { return broker; } |
|---|
| | 25 | public boolean registerQuery(StratconQueryBase sq) { |
|---|
| | 26 | if(queries.containsKey(sq.getUUID())) return false; |
|---|
| | 27 | queries.put(sq.getUUID(), sq); |
|---|
| | 28 | return true; |
|---|
| | 29 | } |
|---|
| | 30 | public boolean deregisterQuery(UUID id) { |
|---|
| | 31 | StratconQueryBase sq = queries.get(id); |
|---|
| | 32 | if(sq != null) { |
|---|
| | 33 | queries.remove(sq.getUUID()); |
|---|
| | 34 | sq.destroy(); |
|---|
| | 35 | System.err.println("Stopping Query/Statement: " + id); |
|---|
| | 36 | return true; |
|---|
| | 37 | } |
|---|
| | 38 | return false; |
|---|
| | 39 | } |
|---|
| | 40 | public boolean isQueryRegistered(UUID id) { return queries.containsKey(id); } |
|---|
| 23 | 41 | |
|---|
| 24 | | public void processMessage(String xml) throws Exception { |
|---|
| 25 | | StratconMessage m = StratconMessage.makeMessage(xml); |
|---|
| 26 | | if(m == null) { |
|---|
| 27 | | System.err.println("Can't grok:\n" + xml); |
|---|
| | 42 | public void processMessage(String payload) throws Exception { |
|---|
| | 43 | Exception last = null; |
|---|
| | 44 | StratconMessage[] messages = StratconMessage.makeMessages(payload); |
|---|
| | 45 | if(messages == null) { |
|---|
| | 46 | System.err.println("Can't grok:\n" + payload); |
|---|
| 28 | 47 | } |
|---|
| 29 | | if(m instanceof StratconStatement) { |
|---|
| 30 | | StratconStatement sq = (StratconStatement) m; |
|---|
| 31 | | |
|---|
| 32 | | if(queries.containsKey(sq.getUUID())) throw (new Exception("Duplicate Query")); |
|---|
| 33 | | |
|---|
| 34 | | EPStatement statement = epService.getEPAdministrator().createEPL(sq.getExpression()); |
|---|
| 35 | | sq.setStatement(statement); |
|---|
| 36 | | queries.put(sq.getUUID(), sq); |
|---|
| 37 | | System.err.println("Creating Statement: " + sq.getUUID()); |
|---|
| | 48 | for ( StratconMessage m : messages ) { |
|---|
| | 49 | if(m != null) try { m.handle(this); } catch (Exception e) { last = e; } |
|---|
| 38 | 50 | } |
|---|
| 39 | | else if(m instanceof StratconQuery) { |
|---|
| 40 | | StratconQuery sq = (StratconQuery) m; |
|---|
| 41 | | |
|---|
| 42 | | if(queries.containsKey(sq.getUUID())) throw (new Exception("Duplicate Query")); |
|---|
| 43 | | |
|---|
| 44 | | EPStatement statement = epService.getEPAdministrator().createEPL(sq.getExpression()); |
|---|
| 45 | | UpdateListener o = broker.getListener(this.epService, sq); |
|---|
| 46 | | |
|---|
| 47 | | statement.addListener(o); |
|---|
| 48 | | sq.setStatement(statement); |
|---|
| 49 | | sq.setListener(o); |
|---|
| 50 | | queries.put(sq.getUUID(), sq); |
|---|
| 51 | | System.err.println("Creating Query: " + sq.getUUID()); |
|---|
| 52 | | } |
|---|
| 53 | | else if(m instanceof StratconQueryStop) { |
|---|
| 54 | | /* QueryStop stops both queries and statements */ |
|---|
| 55 | | StratconQueryBase sq = queries.get(((StratconQueryStop) m).getUUID()); |
|---|
| 56 | | if(sq != null) { |
|---|
| 57 | | queries.remove(sq.getUUID()); |
|---|
| 58 | | sq.destroy(); |
|---|
| 59 | | } |
|---|
| 60 | | } |
|---|
| 61 | | else if(m instanceof NoitMetricText) { |
|---|
| 62 | | epService.getEPRuntime().sendEvent(m); |
|---|
| 63 | | } |
|---|
| 64 | | else if(m instanceof NoitMetricNumeric) { |
|---|
| 65 | | epService.getEPRuntime().sendEvent(m); |
|---|
| 66 | | } |
|---|
| 67 | | else if(m instanceof NoitCheck) { |
|---|
| 68 | | epService.getEPRuntime().sendEvent(m); |
|---|
| 69 | | } |
|---|
| 70 | | else if(m instanceof NoitStatus) { |
|---|
| 71 | | epService.getEPRuntime().sendEvent(m); |
|---|
| 72 | | } |
|---|
| | 51 | if(last != null) throw(last); |
|---|
| 73 | 52 | } |
|---|
| 74 | 53 | } |
|---|
| r5640498 |
r5cffd17 |
|
| 10 | 10 | |
|---|
| 11 | 11 | import java.io.StringReader; |
|---|
| 12 | | import javax.xml.parsers.DocumentBuilder; |
|---|
| 13 | | import javax.xml.parsers.DocumentBuilderFactory; |
|---|
| 14 | | import org.xml.sax.InputSource; |
|---|
| 15 | | |
|---|
| 16 | | import org.w3c.dom.Document; |
|---|
| 17 | | import org.w3c.dom.Element; |
|---|
| 18 | | |
|---|
| | 12 | import java.util.HashMap; |
|---|
| | 13 | import java.lang.reflect.Constructor; |
|---|
| | 14 | import java.lang.reflect.Method; |
|---|
| | 15 | import java.lang.reflect.InvocationTargetException; |
|---|
| 19 | 16 | import com.omniti.reconnoiter.event.*; |
|---|
| 20 | 17 | |
|---|
| 21 | | public class StratconMessage { |
|---|
| 22 | | |
|---|
| | 18 | public abstract class StratconMessage { |
|---|
| 23 | 19 | // This is the text type in the noit_log.h |
|---|
| 24 | 20 | public final static String METRIC_STRING = "s"; |
|---|
| 25 | | |
|---|
| | 21 | public final static HashMap<String,StratconMessageFactory> quicklookup = new HashMap<String,StratconMessageFactory>(); |
|---|
| | 22 | |
|---|
| | 23 | public static boolean registerType(Class clazz) { |
|---|
| | 24 | boolean success = false; |
|---|
| | 25 | try { |
|---|
| | 26 | Method meth = clazz.getMethod("getPrefix"); |
|---|
| | 27 | String prefix = (String)meth.invoke(clazz.newInstance()); |
|---|
| | 28 | StratconMessageFactory smf = new StratconMessageFactory(clazz); |
|---|
| | 29 | quicklookup.put(prefix, smf); |
|---|
| | 30 | success = true; |
|---|
| | 31 | } catch (NoSuchMethodException e) { |
|---|
| | 32 | e.printStackTrace(); |
|---|
| | 33 | } catch (IllegalAccessException e) { |
|---|
| | 34 | e.printStackTrace(); |
|---|
| | 35 | } catch (InvocationTargetException e) { |
|---|
| | 36 | e.printStackTrace(); |
|---|
| | 37 | } catch (InstantiationException e) { |
|---|
| | 38 | e.printStackTrace(); |
|---|
| | 39 | } |
|---|
| | 40 | return success; |
|---|
| | 41 | } |
|---|
| 26 | 42 | public static String[] parseToArray(String jlog, int num) { |
|---|
| 27 | 43 | // Get rid of the null parameter |
|---|
| 28 | | return jlog.substring(0, jlog.length()-1).split("[\t]", num); |
|---|
| | 44 | String operand = jlog.endsWith("\n") ? jlog.substring(0, jlog.length()-1) |
|---|
| | 45 | : jlog; |
|---|
| | 46 | return operand.split("[\t]", num); |
|---|
| 29 | 47 | } |
|---|
| 30 | 48 | |
|---|
| 31 | | protected String getPrefix() { |
|---|
| 32 | | return null; |
|---|
| 33 | | } |
|---|
| | 49 | public String getPrefix() { return null; } |
|---|
| 34 | 50 | |
|---|
| 35 | 51 | protected long timeToLong(String time) { |
|---|
| … | … | |
| 47 | 63 | } |
|---|
| 48 | 64 | |
|---|
| 49 | | protected int getLength() { |
|---|
| 50 | | return -1; |
|---|
| 51 | | } |
|---|
| | 65 | public int getLength() { return 0; } |
|---|
| 52 | 66 | |
|---|
| | 67 | public abstract void handle(EventHandler eh); |
|---|
| | 68 | |
|---|
| | 69 | public StratconMessage() {} |
|---|
| 53 | 70 | // Check and make sure |
|---|
| 54 | 71 | public StratconMessage(String[] parts) throws Exception { |
|---|
| … | … | |
| 63 | 80 | public static StratconMessage makeMessage(String jlog) { |
|---|
| 64 | 81 | String[] parts; |
|---|
| | 82 | if(jlog == null || jlog.length() == 0) return null; |
|---|
| 65 | 83 | // The numbers of the parse are pulled from stratcon and |
|---|
| 66 | 84 | // +1 for the extra remote |
|---|
| 67 | 85 | try { |
|---|
| 68 | | switch (jlog.charAt(0)) { |
|---|
| 69 | | case 'C': |
|---|
| 70 | | parts = parseToArray(jlog, 7); |
|---|
| 71 | | return new NoitCheck(parts); |
|---|
| 72 | | case 'S': |
|---|
| 73 | | parts = parseToArray(jlog, 8); |
|---|
| 74 | | return new NoitStatus(parts); |
|---|
| 75 | | case 'M': |
|---|
| 76 | | parts = parseToArray(jlog, 7); |
|---|
| 77 | | if (parts[5].equals(METRIC_STRING)) { |
|---|
| 78 | | return new NoitMetricText(parts); |
|---|
| 79 | | } else { |
|---|
| 80 | | return new NoitMetricNumeric(parts); |
|---|
| 81 | | } |
|---|
| 82 | | case 'D': |
|---|
| 83 | | parts = parseToArray(jlog, 4); |
|---|
| 84 | | return new StratconStatement(parts); |
|---|
| 85 | | case 'Q': |
|---|
| 86 | | parts = parseToArray(jlog, 5); |
|---|
| 87 | | return new StratconQuery(parts); |
|---|
| 88 | | case 'q': |
|---|
| 89 | | parts = parseToArray(jlog, 3); |
|---|
| 90 | | return new StratconQueryStop(parts); |
|---|
| | 86 | String prefix = jlog.substring(0, jlog.indexOf('\t')); |
|---|
| | 87 | |
|---|
| | 88 | StratconMessageFactory smf = quicklookup.get(prefix); |
|---|
| | 89 | if(smf == null) { |
|---|
| | 90 | throw new Exception("no handler for " + jlog); |
|---|
| 91 | 91 | } |
|---|
| | 92 | parts = parseToArray(jlog, smf.getLength()); |
|---|
| | 93 | return smf.make(parts); |
|---|
| 92 | 94 | } |
|---|
| 93 | 95 | catch(Exception e) { |
|---|
| … | … | |
| 97 | 99 | return null; |
|---|
| 98 | 100 | } |
|---|
| | 101 | public static StratconMessage[] makeMessages(String big) { |
|---|
| | 102 | String[] lines = big.split("[\n]"); |
|---|
| | 103 | StratconMessage[] messages = new StratconMessage[lines.length]; |
|---|
| | 104 | for (int i = 0; i < messages.length; i++) { |
|---|
| | 105 | messages[i] = makeMessage(lines[i]); |
|---|
| | 106 | } |
|---|
| | 107 | return messages; |
|---|
| | 108 | } |
|---|
| | 109 | static { |
|---|
| | 110 | StratconMessage.registerType(NoitCheck.class); |
|---|
| | 111 | StratconMessage.registerType(NoitStatus.class); |
|---|
| | 112 | StratconMessage.registerType(NoitMetric.class); |
|---|
| | 113 | StratconMessage.registerType(StratconStatement.class); |
|---|
| | 114 | StratconMessage.registerType(StratconQuery.class); |
|---|
| | 115 | StratconMessage.registerType(StratconQueryStop.class); |
|---|
| | 116 | } |
|---|
| 99 | 117 | } |
|---|
| r0335d9d |
r5cffd17 |
|
| 1 | 1 | package com.omniti.reconnoiter.event; |
|---|
| 2 | 2 | |
|---|
| 3 | | import com.omniti.reconnoiter.StratconMessage; |
|---|
| | 3 | import com.omniti.reconnoiter.event.NoitEvent; |
|---|
| 4 | 4 | |
|---|
| 5 | 5 | |
|---|
| 6 | | public class NoitCheck extends StratconMessage { |
|---|
| 7 | | String uuid; |
|---|
| 8 | | String target; |
|---|
| 9 | | String module; |
|---|
| 10 | | String name; |
|---|
| 11 | | String noit; |
|---|
| | 6 | public class NoitCheck extends NoitEvent { |
|---|
| | 7 | String uuid; |
|---|
| | 8 | String target; |
|---|
| | 9 | String module; |
|---|
| | 10 | String name; |
|---|
| | 11 | String noit; |
|---|
| 12 | 12 | |
|---|
| 13 | | protected String getPrefix() { |
|---|
| 14 | | return "C"; |
|---|
| 15 | | } |
|---|
| | 13 | public String getPrefix() { |
|---|
| | 14 | return "C"; |
|---|
| | 15 | } |
|---|
| 16 | 16 | |
|---|
| | 17 | /* |
|---|
| | 18 | 'C' REMOTE TIMESTAMP UUID TARGET MODULE NAME |
|---|
| | 19 | */ |
|---|
| | 20 | public NoitCheck() {} |
|---|
| | 21 | public NoitCheck(String[] parts) throws Exception { |
|---|
| | 22 | super(parts); |
|---|
| | 23 | noit = parts[1]; |
|---|
| | 24 | uuid = parts[3]; |
|---|
| | 25 | target = parts[4]; |
|---|
| | 26 | module = parts[5]; |
|---|
| | 27 | name = parts[6]; |
|---|
| | 28 | } |
|---|
| 17 | 29 | |
|---|
| | 30 | public String getUuid() { return uuid; } |
|---|
| | 31 | public String getName() { return name; } |
|---|
| | 32 | public String getTarget() { return target; } |
|---|
| | 33 | public String getModule() { return module; } |
|---|
| | 34 | public String getNoit() { return noit; } |
|---|
| 18 | 35 | |
|---|
| 19 | | /* |
|---|
| 20 | | 'C' REMOTE TIMESTAMP UUID TARGET MODULE NAME |
|---|
| 21 | | */ |
|---|
| 22 | | public NoitCheck(String[] parts) throws Exception { |
|---|
| 23 | | super(parts); |
|---|
| 24 | | noit = parts[1]; |
|---|
| 25 | | uuid = parts[3]; |
|---|
| 26 | | target = parts[4]; |
|---|
| 27 | | module = parts[5]; |
|---|
| 28 | | name = parts[6]; |
|---|
| 29 | | |
|---|
| 30 | | } |
|---|
| 31 | | |
|---|
| 32 | | public String getUuid() { return uuid; } |
|---|
| 33 | | public String getName() { return name; } |
|---|
| 34 | | public String getTarget() { return target; } |
|---|
| 35 | | public String getModule() { return module; } |
|---|
| 36 | | public String getNoit() { return noit; } |
|---|
| 37 | | |
|---|
| 38 | | protected int getLength() { |
|---|
| 39 | | return 7; |
|---|
| 40 | | } |
|---|
| | 36 | public int getLength() { |
|---|
| | 37 | return 7; |
|---|
| | 38 | } |
|---|
| 41 | 39 | } |
|---|
| rd855ea0 |
r5cffd17 |
|
| 9 | 9 | package com.omniti.reconnoiter.event; |
|---|
| 10 | 10 | |
|---|
| 11 | | import com.omniti.reconnoiter.StratconMessage; |
|---|
| | 11 | import com.omniti.reconnoiter.event.NoitEvent; |
|---|
| 12 | 12 | |
|---|
| 13 | | public class NoitMetricNumeric extends StratconMessage { |
|---|
| | 13 | public class NoitMetricNumeric extends NoitEvent { |
|---|
| 14 | 14 | private String uuid; |
|---|
| 15 | 15 | private String name; |
|---|
| … | … | |
| 18 | 18 | private String noit; |
|---|
| 19 | 19 | |
|---|
| 20 | | protected String getPrefix() { |
|---|
| | 20 | public String getPrefix() { |
|---|
| 21 | 21 | return "M"; |
|---|
| 22 | 22 | } |
|---|
| … | … | |
| 24 | 24 | 'M' REMOTE TIMESTAMP UUID NAME TYPE VALUE |
|---|
| 25 | 25 | */ |
|---|
| | 26 | public NoitMetricNumeric() {} |
|---|
| 26 | 27 | public NoitMetricNumeric(String[] parts) throws Exception { |
|---|
| 27 | 28 | super(parts); |
|---|
| … | … | |
| 46 | 47 | public String getNoit() { return noit; } |
|---|
| 47 | 48 | |
|---|
| 48 | | protected int getLength() { |
|---|
| | 49 | public int getLength() { |
|---|
| 49 | 50 | return 7; |
|---|
| 50 | 51 | } |
|---|
| rd855ea0 |
r5cffd17 |
|
| 1 | 1 | package com.omniti.reconnoiter.event; |
|---|
| 2 | 2 | |
|---|
| 3 | | import com.omniti.reconnoiter.StratconMessage; |
|---|
| | 3 | import com.omniti.reconnoiter.event.NoitEvent; |
|---|
| 4 | 4 | |
|---|
| 5 | | public class NoitMetricText extends StratconMessage { |
|---|
| | 5 | public class NoitMetricText extends NoitEvent { |
|---|
| 6 | 6 | String uuid; |
|---|
| 7 | 7 | Long time; |
|---|
| … | … | |
| 10 | 10 | String noit; |
|---|
| 11 | 11 | |
|---|
| 12 | | protected String getPrefix() { |
|---|
| | 12 | public String getPrefix() { |
|---|
| 13 | 13 | return "M"; |
|---|
| 14 | 14 | } |
|---|
| … | … | |
| 16 | 16 | 'M' REMOTE TIMESTAMP UUID NAME TYPE VALUE |
|---|
| 17 | 17 | */ |
|---|
| | 18 | public NoitMetricText() {} |
|---|
| 18 | 19 | public NoitMetricText(String[] parts) throws Exception { |
|---|
| 19 | 20 | super(parts); |
|---|
| … | … | |
| 31 | 32 | |
|---|
| 32 | 33 | |
|---|
| 33 | | protected int getLength() { |
|---|
| | 34 | public int getLength() { |
|---|
| 34 | 35 | return 7; |
|---|
| 35 | 36 | } |
|---|
| r5640498 |
r5cffd17 |
|
| 1 | 1 | package com.omniti.reconnoiter.event; |
|---|
| 2 | 2 | |
|---|
| 3 | | import com.omniti.reconnoiter.StratconMessage; |
|---|
| | 3 | import com.omniti.reconnoiter.event.NoitEvent; |
|---|
| 4 | 4 | |
|---|
| | 5 | public class NoitStatus extends NoitEvent { |
|---|
| | 6 | String uuid; |
|---|
| | 7 | Long time; |
|---|
| | 8 | String status; |
|---|
| | 9 | String state; |
|---|
| | 10 | String availability; |
|---|
| | 11 | Double duration; |
|---|
| | 12 | String noit; |
|---|
| 5 | 13 | |
|---|
| 6 | | public class NoitStatus extends StratconMessage { |
|---|
| 7 | | String uuid; |
|---|
| 8 | | Long time; |
|---|
| 9 | | String status; |
|---|
| 10 | | String state; |
|---|
| 11 | | String availability; |
|---|
| 12 | | Double duration; |
|---|
| 13 | | String noit; |
|---|
| | 14 | public String getPrefix() { |
|---|
| | 15 | return "S"; |
|---|
| | 16 | } |
|---|
| 14 | 17 | |
|---|
| 15 | | @Override |
|---|
| 16 | | protected String getPrefix() { |
|---|
| 17 | | return "S"; |
|---|
| 18 | | } |
|---|
| | 18 | /* |
|---|
| | 19 | 'S' REMOTE TIMESTAMP UUID STATE AVAILABILITY DURATION STATUS_MESSAGE |
|---|
| | 20 | */ |
|---|
| | 21 | public NoitStatus() {} |
|---|
| | 22 | public NoitStatus(String[] parts) throws Exception { |
|---|
| | 23 | super(parts); |
|---|
| | 24 | noit = parts[1]; |
|---|
| | 25 | uuid = parts[3]; |
|---|
| | 26 | state = parts[4]; |
|---|
| | 27 | availability = parts[5]; |
|---|
| | 28 | duration = Double.parseDouble(parts[6]); |
|---|
| | 29 | status = parts[7]; |
|---|
| | 30 | time = timeToLong(parts[2]); |
|---|
| | 31 | } |
|---|
| 19 | 32 | |
|---|
| 20 | | /* |
|---|
| 21 | | 'S' REMOTE TIMESTAMP UUID STATE AVAILABILITY DURATION STATUS_MESSAGE |
|---|
| 22 | | */ |
|---|
| 23 | | public NoitStatus(String[] parts) throws Exception { |
|---|
| 24 | | super(parts); |
|---|
| 25 | | noit = parts[1]; |
|---|
| 26 | | uuid = parts[3]; |
|---|
| 27 | | state = parts[4]; |
|---|
| 28 | | availability = parts[5]; |
|---|
| 29 | | duration = Double.parseDouble(parts[6]); |
|---|
| 30 | | status = parts[7]; |
|---|
| 31 | | time = timeToLong(parts[2]); |
|---|
| 32 | | } |
|---|
| | 33 | public String getUuid() { return uuid; } |
|---|
| | 34 | public Long getTime() { return time; } |
|---|
| | 35 | public String getStatus() { return status; } |
|---|
| | 36 | public String getState() { return state; } |
|---|
| | 37 | public String getAvailability() { return availability; } |
|---|
| | 38 | public Double getDuration() { return duration; } |
|---|
| | 39 | public String getNoit() { return noit; } |
|---|
| 33 | 40 | |
|---|
| 34 | | public String getUuid() { return uuid; } |
|---|
| 35 | | public Long getTime() { return time; } |
|---|
| 36 | | public String getStatus() { return status; } |
|---|
| 37 | | public String getState() { return state; } |
|---|
| 38 | | public String getAvailability() { return availability; } |
|---|
| 39 | | public Double getDuration() { return duration; } |
|---|
| 40 | | public String getNoit() { return noit; } |
|---|
| 41 | | |
|---|
| 42 | | protected int getLength() { |
|---|
| 43 | | return 8; |
|---|
| 44 | | } |
|---|
| | 41 | public int getLength() { |
|---|
| | 42 | return 8; |
|---|
| | 43 | } |
|---|
| 45 | 44 | } |
|---|
| rb4d0df9 |
r5cffd17 |
|
| 11 | 11 | |
|---|
| 12 | 12 | import com.omniti.reconnoiter.event.StratconQueryBase; |
|---|
| | 13 | import com.omniti.reconnoiter.EventHandler; |
|---|
| | 14 | import com.espertech.esper.client.EPStatement; |
|---|
| 13 | 15 | import com.espertech.esper.client.UpdateListener; |
|---|
| 14 | 16 | import java.util.UUID; |
|---|
| … | … | |
| 20 | 22 | protected Thread thr; |
|---|
| 21 | 23 | |
|---|
| 22 | | protected String getPrefix() { |
|---|
| | 24 | public String getPrefix() { |
|---|
| 23 | 25 | return "Q"; |
|---|
| 24 | 26 | } |
|---|
| 25 | 27 | |
|---|
| 26 | 28 | /* 'Q' REMOTE ID NAME QUERY */ |
|---|
| | 29 | public StratconQuery() {} |
|---|
| 27 | 30 | public StratconQuery(String[] parts) throws Exception { |
|---|
| 28 | 31 | super(parts); |
|---|
| … | … | |
| 58 | 61 | } |
|---|
| 59 | 62 | |
|---|
| 60 | | protected int getLength() { |
|---|
| | 63 | public int getLength() { |
|---|
| 61 | 64 | return 5; |
|---|
| 62 | 65 | } |
|---|
| | 66 | |
|---|
| | 67 | public void handle(EventHandler eh) { |
|---|
| | 68 | eh.deregisterQuery(getUUID()); |
|---|
| | 69 | |
|---|
| | 70 | EPStatement statement = eh.getService().getEPAdministrator().createEPL(getExpression()); |
|---|
| | 71 | UpdateListener o = eh.getBroker().getListener(eh.getService(), this); |
|---|
| | 72 | |
|---|
| | 73 | statement.addListener(o); |
|---|
| | 74 | setStatement(statement); |
|---|
| | 75 | setListener(o); |
|---|
| | 76 | eh.registerQuery(this); |
|---|
| | 77 | System.err.println("Creating Query: " + getUUID()); |
|---|
| | 78 | } |
|---|
| 63 | 79 | } |
|---|
| r0335d9d |
r5cffd17 |
|
| 14 | 14 | import java.util.UUID; |
|---|
| 15 | 15 | |
|---|
| 16 | | public class StratconQueryBase extends StratconMessage { |
|---|
| | 16 | public abstract class StratconQueryBase extends StratconMessage { |
|---|
| 17 | 17 | protected EPStatement statement; |
|---|
| 18 | 18 | protected UUID uuid; |
|---|
| 19 | 19 | protected String expression; |
|---|
| 20 | 20 | |
|---|
| | 21 | public StratconQueryBase() {} |
|---|
| 21 | 22 | public StratconQueryBase(String parts[]) throws Exception { |
|---|
| 22 | 23 | super(parts); |
|---|
| r0335d9d |
r5cffd17 |
|
| 9 | 9 | package com.omniti.reconnoiter.event; |
|---|
| 10 | 10 | |
|---|
| | 11 | import java.util.UUID; |
|---|
| 11 | 12 | import com.omniti.reconnoiter.StratconMessage; |
|---|
| 12 | | import java.util.UUID; |
|---|
| 13 | | import org.w3c.dom.Document; |
|---|
| 14 | | import org.w3c.dom.Element; |
|---|
| | 13 | import com.omniti.reconnoiter.EventHandler; |
|---|
| 15 | 14 | |
|---|
| 16 | 15 | public class StratconQueryStop extends StratconQueryBase { |
|---|
| 17 | 16 | |
|---|
| 18 | | protected String getPrefix() { |
|---|
| 19 | | return "q"; |
|---|
| 20 | | } |
|---|
| | 17 | public String getPrefix() { |
|---|
| | 18 | return "q"; |
|---|
| | 19 | } |
|---|
| 21 | 20 | |
|---|
| 22 | | /* 'q' REMOTE ID */ |
|---|
| | 21 | /* 'q' REMOTE ID */ |
|---|
| | 22 | public StratconQueryStop() {} |
|---|
| 23 | 23 | public StratconQueryStop(String[] parts) throws Exception { |
|---|
| 24 | 24 | super(parts); |
|---|
| … | … | |
| 29 | 29 | } |
|---|
| 30 | 30 | |
|---|
| 31 | | protected int getLength() { |
|---|
| | 31 | public int getLength() { |
|---|
| 32 | 32 | return 3; |
|---|
| 33 | 33 | } |
|---|
| 34 | | |
|---|
| | 34 | |
|---|
| | 35 | public void handle(EventHandler eh) { |
|---|
| | 36 | eh.deregisterQuery(getUUID()); |
|---|
| | 37 | } |
|---|
| 35 | 38 | } |
|---|
| 36 | 39 | |
|---|
| r0335d9d |
r5cffd17 |
|
| 10 | 10 | |
|---|
| 11 | 11 | import com.omniti.reconnoiter.event.StratconQueryBase; |
|---|
| | 12 | import com.omniti.reconnoiter.EventHandler; |
|---|
| | 13 | import com.espertech.esper.client.EPStatement; |
|---|
| 12 | 14 | import com.espertech.esper.client.UpdateListener; |
|---|
| 13 | 15 | |
|---|
| 14 | 16 | import java.util.UUID; |
|---|
| 15 | | import javax.xml.xpath.XPath; |
|---|
| 16 | | import javax.xml.xpath.XPathFactory; |
|---|
| 17 | | import javax.xml.xpath.XPathConstants; |
|---|
| 18 | | import javax.xml.xpath.XPathExpressionException; |
|---|
| 19 | | import org.w3c.dom.Document; |
|---|
| 20 | 17 | |
|---|
| 21 | 18 | public class StratconStatement extends StratconQueryBase { |
|---|
| 22 | 19 | |
|---|
| 23 | | protected String getPrefix() { |
|---|
| 24 | | return "D"; |
|---|
| 25 | | } |
|---|
| | 20 | public String getPrefix() { |
|---|
| | 21 | return "D"; |
|---|
| | 22 | } |
|---|
| 26 | 23 | |
|---|
| 27 | | /* 'D' REMOTE ID QUERY */ |
|---|
| 28 | | public StratconStatement(String[] parts) throws Exception { |
|---|
| 29 | | super(parts); |
|---|
| 30 | | String id = parts[2]; |
|---|
| 31 | | expression = parts[3]; |
|---|
| 32 | | if(id == null) |
|---|
| 33 | | uuid = UUID.randomUUID(); |
|---|
| 34 | | else |
|---|
| 35 | | uuid = UUID.fromString(id); |
|---|
| 36 | | } |
|---|
| | 24 | /* 'D' REMOTE ID QUERY */ |
|---|
| | 25 | public StratconStatement() {} |
|---|
| | 26 | public StratconStatement(String[] parts) throws Exception { |
|---|
| | 27 | super(parts); |
|---|
| | 28 | String id = parts[2]; |
|---|
| | 29 | expression = parts[3]; |
|---|
| | 30 | if(id == null) |
|---|
| | 31 | uuid = UUID.randomUUID(); |
|---|
| | 32 | else |
|---|
| | 33 | uuid = UUID.fromString(id); |
|---|
| | 34 | } |
|---|
| 37 | 35 | |
|---|
| 38 | | protected int getLength() { |
|---|
| | 36 | public int getLength() { |
|---|
| 39 | 37 | return 4; |
|---|
| 40 | 38 | } |
|---|
| | 39 | |
|---|
| | 40 | public void handle(EventHandler eh) { |
|---|
| | 41 | eh.deregisterQuery(getUUID()); |
|---|
| | 42 | EPStatement statement = eh.getService().getEPAdministrator().createEPL(getExpression()); |
|---|
| | 43 | setStatement(statement); |
|---|
| | 44 | if(eh.registerQuery(this)) { |
|---|
| | 45 | System.err.println("Creating Statement: " + getUUID()); |
|---|
| | 46 | } |
|---|
| | 47 | } |
|---|
| 41 | 48 | } |
|---|