gpt4 book ai didi

java - Siddhi 如何使用统计数据

转载 作者:行者123 更新时间:2023-11-30 06:13:06 28 4
gpt4 key购买 nike

最近我想让我的 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}]

只有一个仪表,没有显示任何内容。我是否错过了任何扩展包?或者我是否以错误的方式使用统计命令?谢谢您的提问!

最佳答案

我只是想结束这个问题,因为我自己弄清楚了。当我使用 Java 10 作为 JDK 时,出现了这个问题。解决办法是使用java 1.8

关于java - Siddhi 如何使用统计数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49815025/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com