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);
}
Aggregations