Search in sources :

Example 6 with CepEventPattern

use of edu.snu.mist.common.cep.CepEventPattern in project mist by snuspl.

the class CepHRMonitoring method submitQuery.

public static APIQueryControlResult submitQuery(final Configuration configuration) throws IOException, InjectionException, URISyntaxException {
    final String sourceSocket = Tang.Factory.getTang().newInjector(configuration).getNamedInstance(NettySourceAddress.class);
    final String[] source = sourceSocket.split(":");
    final String sourceHostname = source[0];
    final int sourcePort = Integer.parseInt(source[1]);
    final CepInput<CepHRClass> input = new CepInput.TextSocketBuilder<CepHRClass>().setSocketAddress(sourceHostname).setSocketPort(sourcePort).setClassGenFunc(new CepHRClassGenFunc()).build();
    final CepSink sink = new CepSink.TextSocketBuilder().setSocketAddress(MISTExampleUtils.SINK_HOSTNAME).setSocketPort(MISTExampleUtils.SINK_PORT).build();
    final MISTPredicate<CepHRClass> conditionD = s -> s.getName().equals("D");
    final MISTPredicate<CepHRClass> conditionP = s -> s.getName().equals("P");
    final CepEventPattern<CepHRClass> eventD = new CepEventPattern.Builder<CepHRClass>().setName("doctor").setCondition(conditionD).setContiguity(CepEventContiguity.NON_DETERMINISTIC_RELAXED).setClass(CepHRClass.class).build();
    final CepEventPattern<CepHRClass> eventP = new CepEventPattern.Builder<CepHRClass>().setName("patient").setCondition(conditionP).setContiguity(CepEventContiguity.NON_DETERMINISTIC_RELAXED).setNOrMore(2).setInnerContiguity(CepEventContiguity.STRICT).setClass(CepHRClass.class).build();
    final MISTCepQuery<CepHRClass> cepQuery = new MISTCepQuery.Builder<CepHRClass>("demo-group", "user1").input(input).setEventPatternSequence(eventD, eventP).setQualifier(new CepHRQualifier()).within(3600000).setAction(new CepAction.Builder().setActionType(CepActionType.TEXT_WRITE).setCepSink(sink).setParams("Alert!").build()).build();
    final MISTQueryBuilder queryBuilder = CepUtils.translate(cepQuery);
    return MISTExampleUtils.submit(queryBuilder, configuration);
}
Also used : Tang(org.apache.reef.tang.Tang) MISTFunction(edu.snu.mist.common.functions.MISTFunction) MISTPredicate(edu.snu.mist.common.functions.MISTPredicate) NettySourceAddress(edu.snu.mist.examples.parameters.NettySourceAddress) edu.snu.mist.client.cep(edu.snu.mist.client.cep) URISyntaxException(java.net.URISyntaxException) IOException(java.io.IOException) CommandLine(org.apache.reef.tang.formats.CommandLine) APIQueryControlResult(edu.snu.mist.client.APIQueryControlResult) CepEventPattern(edu.snu.mist.common.cep.CepEventPattern) CepEventContiguity(edu.snu.mist.common.cep.CepEventContiguity) List(java.util.List) MISTQueryBuilder(edu.snu.mist.client.MISTQueryBuilder) Configuration(org.apache.reef.tang.Configuration) Map(java.util.Map) JavaConfigurationBuilder(org.apache.reef.tang.JavaConfigurationBuilder) InjectionException(org.apache.reef.tang.exceptions.InjectionException) MISTQueryBuilder(edu.snu.mist.client.MISTQueryBuilder) CepEventPattern(edu.snu.mist.common.cep.CepEventPattern) MISTQueryBuilder(edu.snu.mist.client.MISTQueryBuilder) JavaConfigurationBuilder(org.apache.reef.tang.JavaConfigurationBuilder)

Aggregations

CepEventPattern (edu.snu.mist.common.cep.CepEventPattern)6 MistDataEvent (edu.snu.mist.core.MistDataEvent)4 MistEvent (edu.snu.mist.core.MistEvent)4 CepExampleClass (edu.snu.mist.core.utils.CepExampleClass)4 OutputBufferEmitter (edu.snu.mist.core.utils.OutputBufferEmitter)4 ArrayList (java.util.ArrayList)4 LinkedList (java.util.LinkedList)4 Test (org.junit.Test)4 MISTQueryBuilder (edu.snu.mist.client.MISTQueryBuilder)2 Map (java.util.Map)2 APIQueryControlResult (edu.snu.mist.client.APIQueryControlResult)1 edu.snu.mist.client.cep (edu.snu.mist.client.cep)1 CepEventContiguity (edu.snu.mist.common.cep.CepEventContiguity)1 MISTFunction (edu.snu.mist.common.functions.MISTFunction)1 MISTPredicate (edu.snu.mist.common.functions.MISTPredicate)1 NettySourceAddress (edu.snu.mist.examples.parameters.NettySourceAddress)1 IOException (java.io.IOException)1 URISyntaxException (java.net.URISyntaxException)1 List (java.util.List)1 Configuration (org.apache.reef.tang.Configuration)1