WSO2流处理器连接到Cassandra会出错

问题描述 投票:0回答:1

我正在尝试按照编辑器中给出的示例程序中给出的说明将我的siddhi应用程序连接到cassandra数据存储。我下载了datastax java jar(Osgi)并将其放在WSO2 / lib文件夹中,现在启动了应用程序。现在我收到一个错误

> [2019-03-10_16-41-17_549] ERROR {org.wso2.siddhi.core.table.Table} - Error on 'Store-cassandra'. . Error while connecting to Table 'SweetProductionTable'. (Encoded)
java.lang.NullPointerException
    at org.wso2.extension.siddhi.store.cassandra.CassandraEventTable.connect(CassandraEventTable.java:443)
    at org.wso2.siddhi.core.table.Table.connectWithRetry(Table.java:388)
    at org.wso2.siddhi.core.SiddhiAppRuntime.startWithoutSources(SiddhiAppRuntime.java:401)
    at org.wso2.siddhi.core.SiddhiAppRuntime.start(SiddhiAppRuntime.java:376)
    at org.wso2.carbon.siddhi.editor.core.internal.DebugRuntime.start(DebugRuntime.java:68)
    at org.wso2.carbon.siddhi.editor.core.internal.DebugProcessorService.start(DebugProcessorService.java:37)
    at org.wso2.carbon.siddhi.editor.core.internal.EditorMicroservice.start(EditorMicroservice.java:588)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.wso2.msf4j.internal.router.HttpMethodInfo.invokeResource(HttpMethodInfo.java:187)
    at org.wso2.msf4j.internal.router.HttpMethodInfo.invoke(HttpMethodInfo.java:143)
    at org.wso2.msf4j.internal.MSF4JHttpConnectorListener.dispatchMethod(MSF4JHttpConnectorListener.java:218)
    at org.wso2.msf4j.internal.MSF4JHttpConnectorListener.lambda$onMessage$57(MSF4JHttpConnectorListener.java:129)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)

[2019-03-10_16-41-17_551] ERROR {org.wso2.siddhi.core.SiddhiAppRuntime} - Error starting Siddhi App 'Store-cassandra', triggering shutdown process. null (Encoded)

以下是相应的代码

define stream SweetProductionStream (id int, name string);

@Store(type='cassandra' , cassandra.host='localhost' ,keyspace='production')
@index('uid')
@primaryKey('uid') 
define table SweetProductionTable (uid int, name string);

/* Inserting event into the cassandra keyspace */
@info(name='query1')
from SweetProductionStream
select SweetProductionStream.id as uid, SweetProductionStream.name
insert into SweetProductionTable;

以下是示例中给出的说明

Prerequisites:
    1) Ensure that Cassandra version 3 or above is installed on your machine. 
    2) Add the DataStax Java driver into {WSO2_SP_HOME}/lib as follows:
           a) Download the DataStax Java driver from: http://central.maven.org/maven2/com/datastax/cassandra/cassandra-driver-core/3.3.2/cassandra-driver-core-3.3.2.jar
           b) Use the "jartobundle" tool in {WSO2_SP_Home}/bin to extract and convert the above JARs into OSGi bundles.
            For Windows: <SP_HOME>/bin/jartobundle.bat <PATH_OF_DOWNLOADED_JAR> <PATH_OF_CONVERTED_JAR>
            For Linux: <SP_HOME>/bin/jartobundle.sh <PATH_OF_DOWNLOADED_JAR> <PATH_OF_CONVERTED_JAR>
            Note: The driver given in the above link is a OSGi bundled one. Please skip this step if the jar is already OSGi bunbled.
           c) Copy the converted bundles to the {WSO2_SP_Home}/lib directory.
    3) Create a keyspace named 'production' in Cassanndra store.
    4) In the store configuration of this application, replace 'username' and 'password' values with your Cassandra credentials.
    5) Save this sample.

Executing the Sample:
    1) Start the Siddhi application by clicking on 'Run'.
    2) If the Siddhi application starts successfully, the following message is shown on the console
        * Store-cassandra.siddhi - Started Successfully!

    Note:
    If you want to edit this application while it's running, stop the application, make your edits and save the application, and then start it again. 

Testing the Sample:
    1) Simulate single events:
        a) Click on 'Event Simulator' (double arrows on left tab) and click 'Single Simulation'
        b) Select 'Store-cassandra' as 'Siddhi App Name' and select 'searchSweetProductionStream' as 'Stream Name'.
        c) Provide attribute values, and then click Send.
    2) Send at least one event where the name matches a name value in the data you previously inserted into the SweetProductionTable. This will satisfy the 'on' condition of the join query.
    3) Optionally, send events to the other corresponding streams to add, delete, update, insert, and search events.

    Notes:
    - After a change in the store, you can use the search stream to see whether the operation is successful.
    - The Primary Key constraint in SweetProductionTable is disabled, because the name cannot be used as a PrimaryKey in a ProductionTable.
    - You can use Siddhi functions to create a unique ID for the received events, which can then be used to apply the Primary Key constraint on the data store records. (http://wso2.github.io/siddhi/documentation/siddhi-4.0/#function)

Viewing the Results:
    See the output for raw materials on the console. You can use searchSweetProductionStream to check for inserted, deleted, and updated events.

*/

提前致谢。

cassandra datastax wso2carbon siddhi wso2sp
1个回答
0
投票

请提供您的Cassandra凭证(用户名和密码)。例如:@store(type ='cassandra',cassandra.host ='localhost',username ='cassandra',password ='cassandra',keyspace ='production',column.family ='SweetProductionTable')

请参考此示例。 Siddhi store casssandra

© www.soinside.com 2019 - 2024. All rights reserved.