最近我想让我的siddhi程序显示一些统计结果。然而,它并没有很好地发挥作用。
基本上我跟着this user guide创建了一个示例应用。然后我转到Siddhi Query Guide页面添加统计部分。主要类看起来像这样:
String siddhiApp =
"@App:name('TestApp') " +
"@App:statistics(interval = '1') " +
"define stream StockEventStream (symbol string, price float, volume long); " +
" " +
"@info(name = 'query1') " +
"from StockEventStream#window.length(5) " +
"select symbol, sum(price) as price, sum(volume) as volume " +
"group by symbol " +
"insert into AggregateStockStream ;";
SiddhiManager siddhiManager = new SiddhiManager();
SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(siddhiApp);
siddhiAppRuntime.addCallback("AggregateStockStream", new StreamCallback() {
@Override
public void receive(Event[] events) {
EventPrinter.print(events);
}
});
InputHandler inputHandler = siddhiAppRuntime.getInputHandler("StockEventStream");
//Start SiddhiApp runtime
siddhiAppRuntime.start();
//Sending events to Siddhi
inputHandler.send(new Object[]{"IBM", 100f, 100L});
Thread.sleep(1000);
inputHandler.send(new Object[]{"IBM", 200f, 300L});
inputHandler.send(new Object[]{"WSO2", 60f, 200L} );
Thread.sleep(1000);
inputHandler.send(new Object[]{"WSO2", 70f, 400L});
inputHandler.send(new Object[]{"GOOG", 50f, 30L});
Thread.sleep(1000);
inputHandler.send(new Object[]{"IBM", 200f, 400L});
Thread.sleep(2000);
inputHandler.send(new Object[]{"WSO2", 70f, 50L});
Thread.sleep(2000);
inputHandler.send(new Object[]{"WSO2", 80f, 400L});
inputHandler.send(new Object[]{"GOOG", 60f, 30L});
//Shutdown SiddhiApp runtime
siddhiAppRuntime.shutdown();
//Shutdown Siddhi
siddhiManager.shutdown();
但是输出没有显示流的计数和流速,而输出只是
[Event{timestamp=1523613242078, data=[IBM, 100.0, 100], isExpired=false}]
[Event{timestamp=1523613243107, data=[IBM, 300.0, 400], isExpired=false}]
[Event{timestamp=1523613243107, data=[WSO2, 60.0, 200], isExpired=false}]
[Event{timestamp=1523613244107, data=[WSO2, 130.0, 600], isExpired=false}]
[Event{timestamp=1523613244107, data=[GOOG, 50.0, 30], isExpired=false}]
2018/4/13 下午5:54:05
============================================================
-- Gauges ----------------------------------------------------------------------
org.wso2.siddhi.SiddhiApps.TestApp.Siddhi.Queries.query1.memory
[Event{timestamp=1523613245120, data=[IBM, 400.0, 700], isExpired=false}]
[Event{timestamp=1523613247136, data=[WSO2, 200.0, 650], isExpired=false}]
[Event{timestamp=1523613249137, data=[WSO2, 220.0, 850], isExpired=false}]
[Event{timestamp=1523613249137, data=[GOOG, 110.0, 60], isExpired=false}]
只有一个Gauge没有显示任何东西。我错过了任何扩展包吗?或者我以错误的方式使用统计命令?谢谢你的询问!
答案 0 :(得分:0)
我只想结束这个问题,因为我自己就知道了。当我将Java 10用作JDK时,发生了此问题。解决方法是使用Java 1.8