norikra 0.1.7-java → 1.0.0-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (97) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +17 -0
  3. data/esper/changelog.txt +103 -0
  4. data/esper/{esper-4.9.0.jar → esper-5.0.0.jar} +0 -0
  5. data/esper/esper/lib/antlr-runtime-4.1.jar +0 -0
  6. data/esper/esper/lib/cglib-nodep-3.1.jar +0 -0
  7. data/esper/esper/lib/commons-logging-1.1.3.jar +0 -0
  8. data/esper/esper/lib/esper_3rdparties.license +7 -13
  9. data/esper/esper/lib/log4j-1.2.17.jar +0 -0
  10. data/esper/esper/lib/readme.txt +7 -7
  11. data/lib/norikra/cli.rb +8 -2
  12. data/lib/norikra/engine.rb +55 -6
  13. data/lib/norikra/field.rb +14 -1
  14. data/lib/norikra/logger.rb +37 -11
  15. data/lib/norikra/logger_mizuno_patch.rb +1 -1
  16. data/lib/norikra/query.rb +56 -19
  17. data/lib/norikra/query/ast.rb +1129 -246
  18. data/lib/norikra/rpc/handler.rb +8 -0
  19. data/lib/norikra/server.rb +5 -4
  20. data/lib/norikra/stats.rb +7 -1
  21. data/lib/norikra/udf.rb +11 -2
  22. data/lib/norikra/udf_spec_helper.rb +3 -1
  23. data/lib/norikra/version.rb +1 -1
  24. data/lib/norikra/webui.rb +1 -0
  25. data/lib/norikra/webui/api.rb +168 -0
  26. data/lib/norikra/webui/handler.rb +6 -1
  27. data/lib/norikra/webui/http.rb +5 -0
  28. data/norikra.gemspec +1 -1
  29. data/public/css/norikra.css +20 -0
  30. data/public/js/jquery.min.js +6 -0
  31. data/public/js/norikra.webui.js +12 -1
  32. data/script/spec_server_pry +27 -13
  33. data/spec/field_spec.rb +20 -8
  34. data/spec/fieldset_spec.rb +11 -0
  35. data/spec/query_spec.rb +161 -52
  36. data/spec/stats_spec.rb +6 -1
  37. data/views/base.erb +2 -1
  38. data/views/index.erb +12 -0
  39. metadata +10 -62
  40. data/esper/esper/lib/antlr-runtime-3.2.jar +0 -0
  41. data/esper/esper/lib/cglib-nodep-2.2.jar +0 -0
  42. data/esper/esper/lib/commons-logging-1.1.1.jar +0 -0
  43. data/esper/esper/lib/log4j-1.2.16.jar +0 -0
  44. data/esper/esperio-amqp-4.9.0.jar +0 -0
  45. data/esper/esperio-amqp/lib/commons-cli-1.1.jar +0 -0
  46. data/esper/esperio-amqp/lib/commons-io-1.2.jar +0 -0
  47. data/esper/esperio-amqp/lib/esperio_3rdparties.license +0 -1328
  48. data/esper/esperio-amqp/lib/esperio_amqp_jars.txt +0 -2
  49. data/esper/esperio-amqp/lib/rabbitmq-client.jar +0 -0
  50. data/esper/esperio-csv-4.9.0.jar +0 -0
  51. data/esper/esperio-csv/lib/esperio_3rdparties.license +0 -1328
  52. data/esper/esperio-db-4.9.0.jar +0 -0
  53. data/esper/esperio-db/lib/esperio_3rdparties.license +0 -1328
  54. data/esper/esperio-http-4.9.0.jar +0 -0
  55. data/esper/esperio-http/lib/esperio_3rdparties.license +0 -1328
  56. data/esper/esperio-http/lib/httpclient-4.0.1.jar +0 -0
  57. data/esper/esperio-http/lib/httpcore-4.0.1.jar +0 -0
  58. data/esper/esperio-http/lib/httpcore-nio-4.0.1.jar +0 -0
  59. data/esper/esperio-license.txt +0 -95
  60. data/esper/esperio-socket-4.9.0.jar +0 -0
  61. data/esper/esperio-socket/lib/esperio_3rdparties.license +0 -1328
  62. data/esper/esperio-springjms-4.9.0.jar +0 -0
  63. data/esper/esperio-springjms/lib/activation-1.1.jar +0 -0
  64. data/esper/esperio-springjms/lib/activemq-core-5.7.0.jar +0 -0
  65. data/esper/esperio-springjms/lib/activemq-pool-5.7.0.jar +0 -0
  66. data/esper/esperio-springjms/lib/commons-pool-1.6.jar +0 -0
  67. data/esper/esperio-springjms/lib/esperio_3rdparties.license +0 -1328
  68. data/esper/esperio-springjms/lib/geronimo-j2ee-management_1.1_spec-1.0.1.jar +0 -0
  69. data/esper/esperio-springjms/lib/geronimo-jms_1.1_spec-1.1.1.jar +0 -0
  70. data/esper/esperio-springjms/lib/junit-4.8.2.jar +0 -0
  71. data/esper/esperio-springjms/lib/org.springframework.asm-3.1.1.RELEASE.jar +0 -0
  72. data/esper/esperio-springjms/lib/org.springframework.beans-3.1.1.RELEASE.jar +0 -0
  73. data/esper/esperio-springjms/lib/org.springframework.context-3.1.1.RELEASE.jar +0 -0
  74. data/esper/esperio-springjms/lib/org.springframework.core-3.1.1.RELEASE.jar +0 -0
  75. data/esper/esperio-springjms/lib/org.springframework.expression-3.1.1.RELEASE.jar +0 -0
  76. data/esper/esperio-springjms/lib/org.springframework.jms-3.1.1.RELEASE.jar +0 -0
  77. data/esper/esperio-springjms/lib/org.springframework.transaction-3.1.1.RELEASE.jar +0 -0
  78. data/esper/esperio-springjms/lib/slf4j-api-1.7.2.jar +0 -0
  79. data/esper/esperio-springjms/lib/slf4j-log4j12-1.7.2.jar +0 -0
  80. data/esper/esperio-stax-4.9.0.jar +0 -0
  81. data/esper/esperio-stax/lib/axiom-api-1.2.9.jar +0 -0
  82. data/esper/esperio-stax/lib/axiom-c14n-1.2.9.jar +0 -0
  83. data/esper/esperio-stax/lib/axiom-dom-1.2.9.jar +0 -0
  84. data/esper/esperio-stax/lib/axiom-impl-1.2.9.jar +0 -0
  85. data/esper/esperio-stax/lib/commons-logging-1.1.1.jar +0 -0
  86. data/esper/esperio-stax/lib/commons-logging-LICENSE.txt +0 -203
  87. data/esper/esperio-stax/lib/esperio_3rdparties.license +0 -1328
  88. data/esper/esperio-stax/lib/geronimo-activation-LICENSE.txt +0 -203
  89. data/esper/esperio-stax/lib/geronimo-activation_1.1_spec-1.0.2.jar +0 -0
  90. data/esper/esperio-stax/lib/geronimo-javamail-LICENSE.txt +0 -203
  91. data/esper/esperio-stax/lib/geronimo-javamail_1.4_spec-1.6.jar +0 -0
  92. data/esper/esperio-stax/lib/geronimo-stax-api-LICENSE.txt +0 -203
  93. data/esper/esperio-stax/lib/geronimo-stax-api_1.0_spec-1.0.1.jar +0 -0
  94. data/esper/esperio-stax/lib/jaxen-1.1.1.jar +0 -0
  95. data/esper/esperio-stax/lib/jaxen-LICENSE.txt +0 -33
  96. data/esper/esperio-stax/lib/wstx-LICENSE.txt +0 -203
  97. data/esper/esperio-stax/lib/wstx-asl-3.2.9.jar +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c60623a71ba50774fd30d435b33ddd5abddb5a32
4
- data.tar.gz: 4540758d58b47d144feaa504087a393a7853d380
3
+ metadata.gz: 538c722175146fe4406fa69a0d9c98a2d8c560e3
4
+ data.tar.gz: 3ac5dc22cd77d7b6faa7f1e5f9e025834a57dfe7
5
5
  SHA512:
6
- metadata.gz: fba4984d9d6c96573f169d5d7fe1f62e6bf711666c0546886d11fce7723beaaf64dce7a30d884b1c05870c7edce49603345e18d660c6d67824d408e22ef768ba
7
- data.tar.gz: 3359da4c4bd851e4f2191ab859b902843619d17124da18b5fe6ab7f3c9fe1d07afed9d12b0e4579fc5b81c40ebba7db0a8035fe1e831dd0dea3ec7367c7d820f
6
+ metadata.gz: b6c74589514fc80a08f122e3422acc5c4ca6a00077111d98cefc44e75c0e190d9cf3600d7e7135864b2b2045547cd801952522396f8a581756295475108ac5c4
7
+ data.tar.gz: 610063d16fb5f1ca4c88dfeb61b6119985952c391fa4698a3d2957e5207453e61a796e0e3cfae6d8180656d06c61496867e740a319ca13159446a56f96422740
data/README.md CHANGED
@@ -62,6 +62,7 @@ https://github.com/norikra/norikra-client-ruby
62
62
 
63
63
  For other languages:
64
64
  * Perl: https://github.com/norikra/norikra-client-perl
65
+ * Python: https://github.com/norikra/norikra-client-python
65
66
 
66
67
  ## Events and Queries
67
68
 
@@ -69,6 +70,22 @@ See: http://norikra.github.io/
69
70
 
70
71
  ## Changes
71
72
 
73
+ * v1.0.0:
74
+ * Update esper version (4.9.0 -> 5.0.0)
75
+ * Support Group By ROLLUP, Grouping Sets and CUBE
76
+ * Support Group By clause in subqueries
77
+ * Support subqueries that select multiple columns to provide input to enumeration methods
78
+ * Support Having clause to have subquery
79
+ * Add loopback query group to connect query output into targets directly
80
+ * RPC:
81
+ * Add JSON RPC API (/api on port 26578)
82
+ * Add API to fetch norikra server logs
83
+ * Add `--stats-secondary` option to store versioned stats files
84
+ * Fix bug:
85
+ * to return `[]` for NULL query output (fixed to `nil`)
86
+ * to handle container value for simple value field (exception -> NULL)
87
+ * v0.1.7:
88
+ * Fix `Pattern` support bug
72
89
  * v0.1.6:
73
90
  * Fix bug: Wrong escape for java instance method calls
74
91
  * v0.1.5:
@@ -1,6 +1,109 @@
1
1
  Esper Changelog
2
2
  ===================
3
3
 
4
+ Changes in version 5.0.0
5
+ ------------------------
6
+ - The following dependent jar files are upgraded:
7
+ - ANTLR runtime library version is now 4.1 (antlr-runtime-4.1.jar) (previously antlr-runtime-3.2.jar)
8
+ - CGLIB version is now 3.1 (cglib-nodep-3.1.jar) (previously cglib-nodep-2.2.jar)
9
+ - Commons-logging version is now 1.1.3 (commons-logging-1.1.3.jar) (previously commons-logging-1.1.1.jar)
10
+ - (optionally) Log4j version is now 1.2.17 (log4j-1.2.17.jar) (previously log4j-1.2.16.jar)
11
+ - Support for rollup and cube aggregation output. Support for SQL standard output and SQL keywords namely "rollup", "cube", "grouping sets", "grouping", "grouping_id".
12
+ - Support for fire-and-forget insert-into queries using the "values" keyword i.e. "insert into ... values (...)"
13
+ - Support for Java 8-style lambda syntax using the "->" operator the same way as "=>" as equivalent syntax
14
+ - Support for context partitioned variables. Use "context ... create variable ..." to create a contex partitioned variable.
15
+ - Support for method invocation joins to receive object-array events from application code
16
+ - Support for query planner expression analysis hints that provide additional control over query planning
17
+ - Support for the query planner for joins, subqueries, fire-and-forget and on-action queries to consider in-keyword expressions and "or"
18
+ - Support for filter execution planning to consider "or"
19
+ - Statements on unbound streams by default no longer retain the last event for use with the iterator API, and instead an application can specify @IterableUnbound or provide an engine configuration to have statements retain the last event
20
+ - Statement names are now always trimmed
21
+ - Applications that use isolated service providers must now set an engine-wide configuration flag to enable this feature
22
+ - The "as" keyword in the select-clause is now optional
23
+ - Improved rendering of expressions by rendering parenthesis according to precedence and by removing white space in expressions.
24
+ This may affect statements where the select-clause does not name columns using "as" since they may receive a different column name compared to version 4.
25
+ - We have changed time period expression month and year interval computation to become relative to the current time. This change disallows float-type values for year and month in a time interval.
26
+ - Improved formatting and content of validation messages
27
+ - Many performance related enhancements
28
+ - Removed version 4 deprecated APIs
29
+
30
+
31
+ Changes in version 4.11.0
32
+ ------------------------
33
+ - Support for patterns to suppress and discard overlapping matches
34
+ - Support for match-recognize define-clause and measures-clause to use enumeration methods and array-index access for grouped variables
35
+ - Support for match-recognize matching upon pattern state termination when used with interval
36
+ - Support for overlapping context to specify "distinct"
37
+ - Support for group-by clause in subqueries
38
+ - Support for subqueries that select multiple columns to provide input to enumeration methods
39
+ - Support for built-in annotations to be case-insensitive
40
+
41
+ Minor EPL changes
42
+ - When in a select-clause the "as" column name is surrounded with backticks (e.g. "select name as `somename` ...") the property name of the output event does no longer carry backticks (i.e. is "somename").
43
+
44
+ Minor API changes
45
+ - SODA class PatternMatchUntilExpr now requires to set single-bounds as a separate expression
46
+
47
+ Bug fixes and other improvements
48
+ - Fixed issue XIN-243-46130 Window(*) returning scalars throws NPE when used with null values
49
+ - Fixed issue FOT-686-75760 Context partition using for-clause with keyed-segmented context when for-clause utilizes the same key the for-clause is not grouping
50
+ - Fixed issue NUO-642-65913 When JMS unmarshaller receives an exception log error and continue
51
+ - Fixed issue LTU-232-62589 Map/oa type with nested pojo with generic-typed list not producing type fragments
52
+ - Fixed issue ZXU-154-59144 Context partitioned join against virtual data window throws NPE
53
+ - Fixed issue IOO-666-18256 EPL module with script that has brackets and semicolon throws exception on deployment
54
+ - Fixed issue UHA-316-24638 Fully-aggregated subquery without filter throws NPE; subquery against context-partitioned VDW throws NPE
55
+ - Fixed issue ESPER-754 Class that extends class triggers two events when named window declared for both child and parent class
56
+ - Fixed issue ESPER-756 NPE during destroy() when using inbound thread pool and when not waiting for pool to empty
57
+ - Fixed issue ESPER-757 VDW callback on consuming rstream events
58
+ - Fixed issue ESPER-758 Thread safety issue with contained-event selection
59
+ - Fixed issue ESPER-759 Pattern with not-operator controlled by repeat ([n]) does not turn repeat to false
60
+ - Fixed issue ESPER-761 On-Demand query inserting row into named window that contains an enumeration throws NPE
61
+ - Fixed issue ESPER-762 Keyed segmented context with match recognize and "prev" in define-clause causes first event to not evaluate
62
+ - Fixed issue ESPER-763 Allow on-merge assignment of event-typed property
63
+ - Fixed issue ESPER-765 Context declaration with @Priority causes first event to arrive twice
64
+ - Fixed issue ESPER-766 Allow enumeration method in pattern filter to use pattern tagged events as input
65
+ - Fixed issue ESPER-767 Support for tick-escape in select-clause column name
66
+ - Fixed issue ESPER-768 Improve standard deviation to use Knuth's
67
+ - Fixed issue ESPER-769 Issue evaluating nested enumeration
68
+ - Fixed issue ESPER-770 Improve compatibility checking when named window event gets inserted into stream of same-as type (Map and ObjectArray only)
69
+ - Fixed issue ESPER-771 Allow subqueries that select a single column that it itself an event to provide enumerable events and insert-into compatible prop
70
+ - Fixed issue ESPER-772 ClassCastException for method invocation on a property that is itself an event
71
+
72
+ Changes in version 4.10.0
73
+ ------------------------
74
+ Major API or EPL changes
75
+ - Support for context declarations to perform initiate or start immediately
76
+ - Support for mutation expressions for merge and update
77
+ - Support for parameterized fire-and-forget queries
78
+ - Support for fire-and-forget queries to consider the "in" opertator for index lookup
79
+ - Support for having-clause to have subquery
80
+ - Support for explicitly selecting eventbean instances of expressions (ESPER-732)
81
+ - Support for fire-and-forget queries that insert-into a named window
82
+
83
+ Bug fixes
84
+ - Fixed Issue ESPER-733 Passing aggregate scalars to global script
85
+ - Fixed Issue ESPER-734 Unclear exception for invalid match_recognize
86
+ - Fixed Issue ESPER-735 Esper 4.9.0 OSGi bundle execution environment restricted to J2SE 1.6
87
+ - Fixed Issue ESPER-737 NullPointerException with grouped data window intersecting time window and last/first event
88
+ - Fixed Issue ESPER-738 Performance issue with 8 threads, keyed context partitioned, synchronized listener, event sequence for same partition
89
+ - Fixed Issue ESPER-739 All calls methods named "get" assumed to be Date-Time method
90
+ - Fixed Issue ESPER-740 POJO event populated by selectclause and via POJO constructor and select clause selects same type twice is created using wrong parameters
91
+ - Fixed Issue ESPER-741 Named window on-action with relational operator (<, <=) where-clause incorrect behavior when reversing comparison
92
+ - Fixed Issue ESPER-742 Static method lookup selects incorrect classstatic method lookup
93
+ - Fixed Issue ESPER-743 Join accross ObjectArrayEvent and MapEvent leaks data from MapEvent
94
+ - Fixed Issue ESPER-744 parse error in prepared statement for count(*,filter_expr)
95
+ - Fixed Issue ESPER-746 Self-Join between derived value streams provides incorrect result
96
+ - Fixed Issue ESPER-747 Cron timer is skipping months
97
+ - Fixed Issue ESPER-748 create schema fails with fully qualified property type name
98
+ - Fixed Issue ESPER-749 split stream with "output all" not working with prepared statement
99
+ - Fixed Issue ESPER-750 @audit miscounts pattern instances with "not"
100
+ - Fixed Issue ESPER-751 StackOverflow when routing new event during high volume processing
101
+ - Fixed Issue ESPER-752 @Drop annotation with context: First event not dropped
102
+ - Fixed Issue KPH-656-86796 EPL module with javascript incorrectly parsed
103
+ - Fixed Issue PJM-181-84952 Possible deadlock for patterns that have filters that have subqueries
104
+ - Fixed Issue IGC-717-55951 efficiency of group reclaim with grouped data windows
105
+ - Fixed Issue TBC-634-19891 use thread context class loader for default deserialize
106
+
4
107
  Changes in version 4.9.0
5
108
  ------------------------
6
109
  Major API or EPL changes
@@ -1,21 +1,15 @@
1
- **** ANTLR 3 License
1
+ **** ANTLR 4 License (see http://www.antlr.org/license.html)
2
2
 
3
3
  [The BSD License]
4
- Copyright (c) 2005, Terence Parr
5
- All rights reserved.
6
- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
7
-
8
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
9
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
10
- Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
4
+ Copyright (c) 2012 Terence Parr and Sam Harwell
5
+ All rights reserved.
6
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
7
+ Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
8
+ Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
9
+ Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
11
10
  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
12
11
 
13
12
 
14
- ANTLR 2 License
15
-
16
- We reserve no legal rights to the ANTLR--it is fully in the public domain. An individual or company may do whatever they wish with source code distributed with ANTLR or the code generated by ANTLR, including the incorporation of ANTLR, or its output, into commerical software.
17
- We encourage users to develop software with ANTLR. However, we do ask that credit is given to us for developing ANTLR. By "credit", we mean that if you use ANTLR or incorporate any source code into one of your programs (commercial product, research project, or otherwise) that you acknowledge this fact somewhere in the documentation, research report, etc... If you like ANTLR and have developed a nice tool with the output, please mention that you developed it using ANTLR. In addition, we ask that the headers remain intact in our source code. As long as these guidelines are kept, we expect to continue enhancing this system and expect to make other tools available as they are completed.
18
-
19
13
  **** Apache Commons Logging, CGLIB bytecode generator, Apache Log4j Library, Apache Commons Collection
20
14
 
21
15
 
@@ -1,15 +1,15 @@
1
1
  Required runtime libraries
2
2
  ==========================
3
3
 
4
- antlr-runtime-3.2
4
+ antlr-runtime-4.1
5
5
  - runtime for ANTLR parser generator
6
6
  - required for runtime
7
7
 
8
- commons-logging-1.1.1.jar
8
+ commons-logging-1.1.3.jar
9
9
  - Apache Commons Logging, for logging
10
10
  - required for runtime
11
11
 
12
- cglib-nodep-2.2.jar
12
+ cglib-nodep-3.1.jar
13
13
  - CGLIB bytecode generator
14
14
  - required for runtime
15
15
 
@@ -17,7 +17,7 @@ cglib-nodep-2.2.jar
17
17
  Optional runtime libraries
18
18
  ==========================
19
19
 
20
- log4j-1.2.16.jar
20
+ log4j-1.2.17.jar
21
21
  - Log4j Library for logging
22
22
  - runtime, optional
23
23
 
@@ -25,14 +25,14 @@ log4j-1.2.16.jar
25
25
  Compile and Build-time libraries - Not part of the binary distribution and not required for runtime
26
26
  ================================
27
27
 
28
- junit-4.8.1.jar
28
+ junit-4.11.jar
29
29
  - JUnit test framework
30
30
  - buildtime, not required for runtime
31
31
 
32
- antlr-3.2.jar
32
+ antlr-4.1-complete.jar
33
33
  - ANTLR parser generator, for compile-time generation of parser and tree walker from grammars
34
34
  - buildtime, not required for runtime
35
35
 
36
- mysql-connector-java-5.1.13-bin.jar
36
+ mysql-connector-java-5.1.28-bin.jar
37
37
  - MySQL JDBC driver, for unit testing of database connectivity
38
38
  - buildtime, not required for runtime
@@ -17,6 +17,8 @@ module Norikra
17
17
 
18
18
  option :stats, :type => :string, :default => nil, :aliases => "-s", \
19
19
  :desc => 'status file path to load/dump targets and queries [none]'
20
+ option :'stats-secondary', :type => :string, :default => nil, \
21
+ :desc => 'status file secondary path, to dump stats with date/time, like "stats.%Y%m%d.json" [none]'
20
22
  option :'suppress-dump-stat', :type => :boolean, :default => false, \
21
23
  :desc => 'specify not to update stat file with updated targets/queries on runtime [false]'
22
24
  option :'dump-stat-interval', :type => :numeric, :default => nil, \
@@ -65,6 +67,7 @@ module Norikra
65
67
  :desc => "directory path of logfiles when daemonized [nil (console for foreground)]"
66
68
  option :'log-filesize', :type => :string, :default => nil, :desc => 'log rotation size [10MB]'
67
69
  option :'log-backups' , :type => :numeric, :default => nil, :desc => 'log rotation backups [10]'
70
+ option :'log-buffer-lines', :type => :numeric, :default => nil, :desc => 'log lines to fetch from API [1000]'
68
71
 
69
72
  ### Loglevel options
70
73
  option :'more-quiet', :type => :boolean, :default => false, :desc => 'set loglevel as ERROR'
@@ -187,7 +190,8 @@ module Norikra
187
190
 
188
191
  ### stat file
189
192
  conf[:stats] = {
190
- path: options[:stats], suppress: options[:'suppress-dump-stat'], interval: options[:'dump-stat-interval'],
193
+ path: options[:stats], secondary_path: options[:'stats-secondary'],
194
+ suppress: options[:'suppress-dump-stat'], interval: options[:'dump-stat-interval'],
191
195
  }
192
196
 
193
197
  ### threads
@@ -218,7 +222,9 @@ module Norikra
218
222
  else nil # for default (assumed as 'INFO')
219
223
  end
220
224
  conf[:log] = {
221
- level: loglevel, dir: options[:logdir], filesize: options[:'log-filesize'], backups: options[:'log-backups'],
225
+ level: loglevel, dir: options[:logdir],
226
+ filesize: options[:'log-filesize'], backups: options[:'log-backups'],
227
+ bufferlines: options[:'log-buffer-lines'],
222
228
  }
223
229
 
224
230
  server_options = {
@@ -6,10 +6,10 @@ require 'norikra/target'
6
6
  require 'norikra/logger'
7
7
  include Norikra::Log
8
8
 
9
- require 'esper-4.9.0.jar'
10
- require 'esper/lib/commons-logging-1.1.1.jar'
11
- require 'esper/lib/antlr-runtime-3.2.jar'
12
- require 'esper/lib/cglib-nodep-2.2.jar'
9
+ require 'esper-5.0.0.jar'
10
+ require 'esper/lib/commons-logging-1.1.3.jar'
11
+ require 'esper/lib/antlr-runtime-4.1.jar'
12
+ require 'esper/lib/cglib-nodep-3.1.jar'
13
13
 
14
14
  require 'norikra/typedef_manager'
15
15
 
@@ -255,7 +255,9 @@ module Norikra
255
255
  event.keys.each do |key|
256
256
  trace "event content key:#{key}, value:#{event[key]}, value class:#{event[key].class}"
257
257
  unescaped_key = Norikra::Field.unescape_name(key)
258
- if event[key].respond_to?(:to_hash)
258
+ if event[key].nil?
259
+ converted[unescaped_key] = nil
260
+ elsif event[key].respond_to?(:to_hash)
259
261
  converted[unescaped_key] = event[key].to_hash
260
262
  elsif event[key].respond_to?(:to_a)
261
263
  converted[unescaped_key] = event[key].to_a
@@ -274,6 +276,30 @@ module Norikra
274
276
  @events_statistics[:output] += events.size
275
277
  end
276
278
  end
279
+
280
+ class LoopbackListener < Listener
281
+ def initialize(engine, query_name, query_group, events_statistics)
282
+ @engine = engine
283
+ @query_name = query_name
284
+ @query_group = query_group
285
+ @events_statistics = events_statistics
286
+ @loopback_target = Norikra::Query.loopback(query_group)
287
+ end
288
+
289
+ def update(new_events, old_events)
290
+ t = Time.now.to_i
291
+ event_list = new_events.map{|e| type_convert(e) }
292
+ trace "loopback event", :query => @query_name, :group => @query_group, :event => event_list
293
+ @events_statistics[:output] += event_list.size
294
+ #
295
+ # We does NOT convert 'container.$0' into container['field'].
296
+ # Use escaped names like 'container__0'. That is NOT so confused.
297
+ #
298
+ #TODO: check performance and consider about loopback event threads
299
+ @engine.send(@loopback_target, event_list)
300
+ end
301
+ end
302
+
277
303
  ##### Unmatched events are simply ignored
278
304
  # class UnmatchedListener
279
305
  # include com.espertech.esper.client.UnmatchedListener
@@ -339,8 +365,22 @@ module Norikra
339
365
  end
340
366
 
341
367
  def register_query(query)
368
+
369
+ if lo_target_name = Norikra::Query.loopback(query.group)
370
+ raise "Invalid loopback target name should be checked before. THIS IS BUG." unless Norikra::Target.valid?(lo_target_name)
371
+
372
+ target = Norikra::Target.new(lo_target_name)
373
+ unless @targets.include?(target)
374
+ info "opening loopback target", :target => lo_target_name
375
+ open_target(target)
376
+ end
377
+ end
378
+
342
379
  @mutex.synchronize do
343
380
  raise Norikra::ClientError, "query '#{query.name}' already exists" unless @queries.select{|q| q.name == query.name }.empty?
381
+ if lo_target_name = Norikra::Query.loopback(query.group)
382
+ raise Norikra::ClientError, "loopback target '#{lo_target_name}'" unless Norikra::Target.valid?(lo_target_name)
383
+ end
344
384
 
345
385
  unless @typedef_manager.ready?(query)
346
386
  @waiting_queries.push(query)
@@ -446,11 +486,20 @@ module Norikra
446
486
  statement_model = administrator.compileEPL(query.expression)
447
487
  Norikra::Query.rewrite_query(statement_model, event_type_name_map)
448
488
 
489
+ listener = if Norikra::Query.loopback(query.group)
490
+ LoopbackListener.new(self, query.name, query.group, @statistics[:events])
491
+ else
492
+ Listener.new(query.name, query.group, @output_pool, @statistics[:events])
493
+ end
494
+
449
495
  epl = administrator.create(statement_model)
450
- epl.java_send :addListener, [com.espertech.esper.client.UpdateListener.java_class], Listener.new(query.name, query.group, @output_pool, @statistics[:events])
496
+ epl.java_send :addListener, [com.espertech.esper.client.UpdateListener.java_class], listener
497
+
451
498
  query.statement_name = epl.getName
499
+
452
500
  # epl is automatically started.
453
501
  # epl.isStarted #=> true
502
+ true
454
503
  end
455
504
 
456
505
  # this method should be protected with @mutex lock
@@ -175,9 +175,22 @@ module Norikra
175
175
  # def value(event) # by define_value_accessor
176
176
 
177
177
  def format(value, element_path=nil) #element_path ex: 'fname.fchild', 'fname.$0', 'f.fchild.$2'
178
+ return nil if value.nil? || value.is_a?(Hash) || value.is_a?(Array)
179
+
178
180
  case @type
179
181
  when 'string' then value.to_s
180
- when 'boolean' then value =~ /^(true|false)$/i ? ($1.downcase == 'true') : (!!value)
182
+ when 'boolean'
183
+ if value.is_a?(TrueClass) || value.is_a?(FalseClass)
184
+ value
185
+ elsif value.is_a?(String)
186
+ if value =~ /^(true|false)$/i
187
+ value.downcase == 'true'
188
+ else
189
+ !!value
190
+ end
191
+ else
192
+ !!value
193
+ end
181
194
  when 'integer' then value.to_i
182
195
  when 'float' then value.to_f
183
196
  when 'hash', 'array'
@@ -1,5 +1,5 @@
1
1
  require 'java'
2
- require 'esper/lib/commons-logging-1.1.1.jar'
2
+ require 'esper/lib/commons-logging-1.1.3.jar'
3
3
 
4
4
  require 'monitor'
5
5
 
@@ -96,7 +96,7 @@ module Norikra
96
96
  p.setProperty('log4j.rootLogger', "#{@@level},default")
97
97
  org.apache.log4j.PropertyConfigurator.configure(p)
98
98
 
99
- @@logger = Logger.new('norikra.log')
99
+ @@logger = Logger.new('norikra.log', opts)
100
100
 
101
101
  else # for test(rspec)
102
102
  p.setProperty('log4j.appender.default', 'org.apache.log4j.varia.NullAppender')
@@ -156,32 +156,59 @@ module Norikra
156
156
  end
157
157
 
158
158
  class Logger
159
- def initialize(name)
159
+ attr_reader :buffer
160
+
161
+ DEFAULT_MEMORY_BUFFER_LINES = 1000
162
+ TIME_FORMAT = '%Y-%m-%d %H:%M:%S %z'
163
+
164
+ def initialize(name, opts={})
165
+ p opts
160
166
  @log4j = org.apache.commons.logging.LogFactory.getLog(name)
167
+ @buffer = Array.new
168
+ @buffer_lines = opts[:bufferlines] || DEFAULT_MEMORY_BUFFER_LINES
169
+ end
170
+
171
+ def push(level, line)
172
+ if @buffer.size == @buffer_lines
173
+ @buffer.shift
174
+ end
175
+ @buffer << [Time.now.strftime(TIME_FORMAT), level, line]
161
176
  end
162
177
 
163
178
  def trace(message, data=nil, from=nil)
164
- @log4j.trace(format(from, message, data))
179
+ line = format(from, message, data)
180
+ push('trace', line)
181
+ @log4j.trace(line)
165
182
  end
166
183
 
167
184
  def debug(message, data=nil, from=nil)
168
- @log4j.debug(format(from, message, data))
185
+ line = format(from, message, data)
186
+ push('debug', line)
187
+ @log4j.debug(line)
169
188
  end
170
189
 
171
190
  def info(message, data=nil, from=nil)
172
- @log4j.info(format(from, message, data))
191
+ line = format(from, message, data)
192
+ push('info', line)
193
+ @log4j.info(line)
173
194
  end
174
195
 
175
196
  def warn(message, data=nil, from=nil)
176
- @log4j.warn(format(from, message, data))
197
+ line = format(from, message, data)
198
+ push('warn', line)
199
+ @log4j.warn(line)
177
200
  end
178
201
 
179
202
  def error(message, data=nil, from=nil)
180
- @log4j.error(format(from, message, data))
203
+ line = format(from, message, data)
204
+ push('error', line)
205
+ @log4j.error(line)
181
206
  end
182
207
 
183
208
  def fatal(message, data=nil, from=nil)
184
- @log4j.fatal(format(from, message, data))
209
+ line = format(from, message, data)
210
+ push('fatal', line)
211
+ @log4j.fatal(line)
185
212
  end
186
213
 
187
214
  def format_location(locations)
@@ -213,7 +240,6 @@ module Norikra
213
240
  # LOG_LOG4J_FORMAT = '%d{yyyy-MM-dd HH:mm:ss Z} [%p] %m%n'
214
241
  # LOG_FORMAT = '%s: %s%s'
215
242
  FORMAT_SIMULATED = "%s [%s] %s\n"
216
- FORMAT_SIMULATED_TIME = '%Y-%m-%d %H:%M:%S %z'
217
243
  attr_accessor :logs, :output
218
244
  def initialize
219
245
  @logs = { :TRACE => [], :DEBUG => [], :INFO => [], :WARN => [], :ERROR => [], :FATAL => [] }
@@ -221,7 +247,7 @@ module Norikra
221
247
  end
222
248
  def log(level, message, data, from)
223
249
  @logs[level].push({:message => message, :data => data, :from => from})
224
- formatted = sprintf(FORMAT_SIMULATED, Time.now.strftime(FORMAT_SIMULATED_TIME), level.to_s, format(from, message, data))
250
+ formatted = sprintf(FORMAT_SIMULATED, Time.now.strftime(TIME_FORMAT), level.to_s, format(from, message, data))
225
251
  @output.push(formatted)
226
252
  end
227
253
  def trace(m,d,f); self.log(:TRACE,m,d,f); end