Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Task/migrate esper 8.4 #176

Merged
merged 33 commits into from
Sep 28, 2021
Merged

Task/migrate esper 8.4 #176

merged 33 commits into from
Sep 28, 2021

Conversation

AlvaroVega
Copy link
Member

@AlvaroVega AlvaroVega commented Sep 10, 2021

issue #136

  • Clean old code
  • Improve logs
  • Add new tests:
    ,"SELECT current_timestamp() as r FROM iotEvent WHERE cast(value?,int) > 10"
    ,"expression twoPI alias for { java.lang.Math.PI * 2 > 5 } SELECT *, twoPI as r FROM iotEvent WHERE twoPI"
    ,"expression E {(v1,v2) => max(v1,v2)} select E(1, 2) from iotEvent"
    ,"expression double js:fib(num) [ fib(num); function fib(n) { if(n <= 1) return n; return fib(n-1) + fib(n-2);}] select fib(5) from iotEvent"
  • Select minor version of esper (> 8.4 com.espertech.esper.compiler.client.EPCompileExceptionItem: Implicit conversion from datatype 'double' to 'Float' for property 'cast(cast(BloodPressure?,String),float)' is not allowed (strict filter type coercion)
  • Propagate error detail to perseo-fe

@AlvaroVega AlvaroVega changed the title - [ ] Task/migrate epl 8 [WIP] Task/migrate esper 8.x Sep 10, 2021
@AlvaroVega
Copy link
Member Author

sudo docker exec iotp-pqa1 bash -c "cd /opt/iotp-pqa && behave ./tests/ --tags=onpremise --tags=-skip --tags=cb2cep"

Failing scenarios:
tests/features/TS03_cbflows/001_cb2cep.feature:91 cb001003 Entity update in CB matches a basic TYPE rule with action EMAIL -- @1.1
tests/features/TS03_cbflows/001_cb2cep.feature:92 cb001003 Entity update in CB matches a basic TYPE rule with action EMAIL -- @1.2
tests/features/TS03_cbflows/001_cb2cep.feature:261 cb001010 Entity update in CB matches a basic TYPE rule with action EMAIL and wildcards -- @1.1
tests/features/TS03_cbflows/001_cb2cep.feature:262 cb001010 Entity update in CB matches a basic TYPE rule with action EMAIL and wildcards -- @1.2
tests/features/TS03_cbflows/006_cb2cep2_conditionbasedonattrmetadata.feature:109 trigger a plain rule with a Email action -- @1.1
tests/features/TS03_cbflows/006_cb2cep2_conditionbasedonattrmetadata.feature:110 trigger a plain rule with a Email action -- @1.2
tests/features/TS03_cbflows/006_cb2cep2_conditionbasedonattrmetadata.feature:144 trigger a plain rule with a Email action and Metadata available -- @1.1
tests/features/TS03_cbflows/006_cb2cep2_conditionbasedonattrmetadata.feature:145 trigger a plain rule with a Email action and Metadata available -- @1.2
tests/features/TS03_cbflows/006_cb2cep2_conditionbasedonattrmetadata.feature:251 trigger a plain rule with a post action -- @1.2
tests/features/TS03_cbflows/008_cb2cep2_conditionbasedonlocation.feature:79 trigger a plain rule based on location using GeoJSON format and Email action
tests/features/TS03_cbflows/009_cb2cep2_conditionbasedontimestamp.feature:72 SC_2 - cb00902 - Trigger a plain rule based on timestamp if it is into the 30 last minutes and Email action

@AlvaroVega
Copy link
Member Author

AlvaroVega commented Sep 14, 2021

with esper 8.5+ EPL like

 "@Audit select *,\"blood_1_action\" as iotcepaction,"
                    + "ev.BloodPressure? as Pression, ev.id? as Meter from pattern "
                    + "[every ev=iotEvent(cast(cast(BloodPressure?,String),float)>1.5"
                    + " and type=\"BloodMeter\")]"

com.espertech.esper.compiler.client.EPCompileExceptionItem: Implicit conversion from datatype 'double' to 'Float' for property 'cast(cast(BloodPressure?,String),float)' is not allowed (strict filter type coercion)

Screenshot from 2021-09-15 13-17-03

@AlvaroVega AlvaroVega changed the title [WIP] Task/migrate esper 8.x [WIP] Task/migrate esper 8.4 Sep 15, 2021
@AlvaroVega AlvaroVega mentioned this pull request Sep 15, 2021
1 task
@AlvaroVega AlvaroVega changed the title [WIP] Task/migrate esper 8.4 [WIP] Task/migrate esper 8.7 Sep 15, 2021
@AlvaroVega
Copy link
Member Author

Enabling query plan:
// Produce query plan output unless logging at debug-level
configuration.getCommon().getLogging().setEnableQueryPlan(true);

and trying with a rule with text:

expression double js:fib(num) [ fib(num); function fib(n) { if(n <= 1) return n; return fib(n-1) + fib(n-2);} ] expression twoPI alias for { java.lang.Math.PI * 2 } SELECT "mirule2" as ruleName, *, 3 as r FROM iotEvent

time=2021-09-16T15:05:51.852Z | lvl=DEBUG | from=::ffff:172.17.0.15 | corr=dabb741a-a074-4fdd-84eb-79f783c0da01; node=k6ah1LRew; perseocep=67 | trans=a3f9e91e-8fff-4419-bed7-806fe534b587 | srv=smartcity | subsrv=/ | op=parse | comp=perseo-core | msg=Error parsing statement [expression double js:fib(num) [ fib(num); function fib(n) { if(n <= 1) return n; return fib(n-1) + fib(n-2);} ] expression twoPI alias for { java.lang.Math.PI * 2 } context ctxt$smartcity$ SELECT "mirule2" as ruleName, *, 3 as r FROM iotEvent]
org.antlr.v4.runtime.misc.ParseCancellationException
at org.antlr.v4.runtime.BailErrorStrategy.recover(BailErrorStrategy.java:51)
at com.espertech.esper.compiler.internal.generated.EsperEPL2GrammarParser.expressionDef(EsperEPL2GrammarParser.java:1054)
at com.espertech.esper.compiler.internal.generated.EsperEPL2GrammarParser.expressionDecl(EsperEPL2GrammarParser.java:925)
at com.espertech.esper.compiler.internal.generated.EsperEPL2GrammarParser.startEPLExpressionRule(EsperEPL2GrammarParser.java:641)
at com.espertech.esper.compiler.internal.util.CompilerHelperSingleEPL$1.invokeParseRule(CompilerHelperSingleEPL.java:49)
at com.espertech.esper.compiler.internal.parse.ParseHelper.parse(ParseHelper.java:94)
at com.espertech.esper.compiler.internal.util.CompilerHelperSingleEPL.parse(CompilerHelperSingleEPL.java:155)
at com.espertech.esper.compiler.internal.util.CompilerHelperSingleEPL.parseCompileInlinedClassesWalk(CompilerHelperSingleEPL.java:62)
at com.espertech.esper.compiler.internal.util.CompilerHelperStatementProvider.compileItem(CompilerHelperStatementProvider.java:92)
at com.espertech.esper.compiler.internal.util.CompilerHelperModuleProvider.compileToBytes(CompilerHelperModuleProvider.java:127)
at com.espertech.esper.compiler.internal.util.CompilerHelperModuleProvider.compile(CompilerHelperModuleProvider.java:89)
at com.espertech.esper.compiler.internal.util.EPCompilerImpl.compile(EPCompilerImpl.java:98)
at com.telefonica.iot.perseo.Utils.compileDeploy(Utils.java:417)
at com.telefonica.iot.perseo.RulesManager.make(RulesManager.java:138)
at com.telefonica.iot.perseo.RulesServlet.doPost(RulesServlet.java:122)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:681)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:764)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:196)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:544)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:698)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:364)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:624)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:831)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1650)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: org.antlr.v4.runtime.NoViableAltException
at com.espertech.esper.compiler.internal.generated.EsperEPL2GrammarParser.stringconstant(EsperEPL2GrammarParser.java:22593)
at com.espertech.esper.compiler.internal.generated.EsperEPL2GrammarParser.expressionDef(EsperEPL2GrammarParser.java:1042)
... 37 more

only sencond expression works

@AlvaroVega AlvaroVega changed the title [WIP] Task/migrate esper 8.7 Task/migrate esper 8.4 Sep 20, 2021
Comment on lines 135 to 145
// To be included with using Esper 8.7
// @Override
// public EPTypeClass getUnderlyingEPType() {
// throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
// }

// @Override
// public EPType getPropertyEPType(java.lang.String string) {
// throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
// }
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leftover to be removed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a comment for the future, when we try to update from 8.4 to 8.7, we will need it

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NTC

Comment on lines +58 to +59
//,"inlined_class \"\"\"\n public class MyUtility {\n public static double fib(int n) {\n if (n <= 1) {\n return n;\n }\n return fib(n-1) + fib(n-2);\n }\n }\n\"\"\"\n expression FIBC alias for { MyUtility.fib(5) > 3 } SELECT *, FIBC as r FROM iotEvent WHERE FIBC"
//,"expression double js:fib(num) [\nfib(num);\nfunction fib(n) {\n if(n <= 1)\n return n;\n return fib(n-1) + fib(n-2);\n}\n]\nexpression FIBE alias for { fib(5) > 3 } SELECT *, FIBE as r FROM iotEvent WHERE FIBE"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leftover commented lines?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a comment for the future, we expect that epl text will work with a future version

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NTC

statement.addListener(new GenericListener());
} else {
logger.debug(String.format("found repeated statement: %s", name));
statement = prevStmnt;
}
}
return new Result(HttpServletResponse.SC_OK,
Utils.Statement2JSONObject(statement).toString());
Utils.Statement2JSONObject(statement, epa, statement.getDeploymentId()).toString());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Over indentation here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in 24494fc

Copy link
Member

@fgalan fgalan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@fgalan fgalan merged commit dd1be3f into master Sep 28, 2021
@fgalan fgalan deleted the task/migrate_epl_8 branch September 28, 2021 09:38
@fgalan fgalan mentioned this pull request Sep 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants