I'v used the following to get a CQL connection
com.datastax.driver.core.Cluster cluster = InitialContext.doLookup("
CassandraRepo");
And added the following entry to master-datasources.xml
<datasource>
<name>WSO2_CASSANDRA_DB</name>
<description>The datasource used for cassandra</description>
<jndiConfig>
<name>CassandraRepo</name>
</jndiConfig>
<definition type="CASSANDRA">
<configuration>
<async>false</async>
<clusterName>TestCluster</clusterName>
<compression>SNAPPY</compression>
<concurrency>100</concurrency>
<username>admin</username>
<password encrypted="true">admin</password>
<port>9042</port>
<maxConnections>100</maxConnections>
<hosts>
<host>127.0.0.1</host>
</hosts>
<loadBalancePolicy>
<exclusionThreshold>2.5</exclusionThreshold>
<latencyAware>true</latencyAware>
<minMeasure>100</minMeasure>
<policyName>RoundRobinPolicy</policyName>
<retryPeriod>10</retryPeriod>
<scale>2</scale>
</loadBalancePolicy>
<poolOptions>
<coreConnectionsForLocal>10</coreConnectionsForLocal>
<coreConnectionsForRemote>10</coreConnectionsForRemote>
<maxConnectionsForLocal>10</maxConnectionsForLocal>
<maxConnectionsForRemote>10</maxConnectionsForRemote>
<maxSimultaneousRequestsForLocal>10</maxSimultaneousRequestsForLocal>
<maxSimultaneousRequestsForRemote>10</maxSimultaneousRequestsForRemote>
<minSimultaneousRequestsForLocal>10</minSimultaneousRequestsForLocal>
<minSimultaneousRequestsForRemote>10</minSimultaneousRequestsForRemote>
</poolOptions>
<reconnectPolicy>
<baseDelayMs>100</baseDelayMs>
<policyName>ConstantReconnectionPolicy</policyName>
</reconnectPolicy>
<socketOptions>
<connectTimeoutMillis>200</connectTimeoutMillis>
<keepAlive>true</keepAlive>
<readTimeoutMillis>200</readTimeoutMillis>
<tcpNoDelay>true</tcpNoDelay>
</socketOptions>
</configuration>
</definition>
</datasource>
On Wed, Jul 30, 2014 at 7:48 AM, Dhanuka Ranasinghe <[email protected]>
wrote:
> Can you please let me know the exact steps followed?
> On 29 Jul 2014 17:47, "Udara Rathnayake" <[email protected]> wrote:
>
>> Hi Asitha,
>>
>> Not sure whether you can use this approach or not, previously in ES
>> product we had following Cassandra data-source[1] definition and able to
>> create connection using following, But we have used cassandra.cql.jdbc
>> driver here.
>>
>> CarbonDataSource carbonDataSource =
>> DataSourceManager.getInstance().getDataSourceRepository().getDataSource("SOCIAL_CASSANDRA_DB");
>> DataSource dataSource = (DataSource) carbonDataSource.getDSObject();
>> conn = dataSource.getConnection();
>>
>> [1]
>>
>> <datasource>
>> <name>SOCIAL_CASSANDRA_DB</name>
>> <description>The cassandra datasource used for storing social
>> activities</description>
>> <definition type="RDBMS">
>> <configuration>
>> <url>jdbc:cassandra://localhost:9160/EVENT_KS</url>
>> <username>admin</username>
>> <password>admin</password>
>>
>> <driverClassName>org.apache.cassandra.cql.jdbc.CassandraDriver</driverClassName>
>> </configuration>
>> </definition>
>> </datasource>
>>
>> Regards,
>> UdaraR
>>
>>
>> On Tue, Jul 29, 2014 at 2:25 PM, Asitha Nanayakkara <[email protected]>
>> wrote:
>>
>>> Hi,
>>>
>>> While trying to integrate CQL data source feature of
>>> master-datasources.xml to MB I get an error at run time.
>>>
>>> I've used the following method to get the connection
>>>
>>>> com.datastax.driver.core.Cluster cluster
>>>> = InitialContext.doLookup("CassandraRepo");
>>>
>>>
>>> Following is the error I get.
>>>
>>> [2014-07-29 14:08:57,035] ERROR
>>> {org.wso2.carbon.ndatasource.core.DataSourceRepository} - A data source
>>> reader cannot be found for the type 'CASSANDRA'
>>> org.wso2.carbon.ndatasource.common.DataSourceException: A data source
>>> reader cannot be found for the type 'CASSANDRA'
>>> at
>>> org.wso2.carbon.ndatasource.core.DataSourceRepository.createDataSourceObject(DataSourceRepository.java:196)
>>> at
>>> org.wso2.carbon.ndatasource.core.DataSourceRepository.registerDataSource(DataSourceRepository.java:359)
>>> at
>>> org.wso2.carbon.ndatasource.core.DataSourceRepository.addDataSource(DataSourceRepository.java:473)
>>> at
>>> org.wso2.carbon.ndatasource.core.DataSourceManager.initSystemDataSource(DataSourceManager.java:185)
>>> at
>>> org.wso2.carbon.ndatasource.core.DataSourceManager.initSystemDataSources(DataSourceManager.java:157)
>>> at
>>> org.wso2.carbon.ndatasource.core.internal.DataSourceServiceComponent.initSystemDataSources(DataSourceServiceComponent.java:191)
>>> at
>>> org.wso2.carbon.ndatasource.core.internal.DataSourceServiceComponent.setSecretCallbackHandlerService(DataSourceServiceComponent.java:177)
>>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>> at
>>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>>> at
>>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>>> at java.lang.reflect.Method.invoke(Method.java:606)
>>> at
>>> org.eclipse.equinox.internal.ds.model.ComponentReference.bind(ComponentReference.java:376)
>>> at
>>> org.eclipse.equinox.internal.ds.model.ServiceComponentProp.bindReference(ServiceComponentProp.java:432)
>>> at
>>> org.eclipse.equinox.internal.ds.model.ServiceComponentProp.bind(ServiceComponentProp.java:218)
>>> at
>>> org.eclipse.equinox.internal.ds.model.ServiceComponentProp.build(ServiceComponentProp.java:345)
>>> at
>>> org.eclipse.equinox.internal.ds.InstanceProcess.buildComponent(InstanceProcess.java:620)
>>> at
>>> org.eclipse.equinox.internal.ds.InstanceProcess.buildComponents(InstanceProcess.java:197)
>>> at
>>> org.eclipse.equinox.internal.ds.Resolver.getEligible(Resolver.java:343)
>>> at
>>> org.eclipse.equinox.internal.ds.SCRManager.serviceChanged(SCRManager.java:222)
>>> at
>>> org.eclipse.osgi.internal.serviceregistry.FilteredServiceListener.serviceChanged(FilteredServiceListener.java:107)
>>> at
>>> org.eclipse.osgi.framework.internal.core.BundleContextImpl.dispatchEvent(BundleContextImpl.java:861)
>>> at
>>> org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
>>> at
>>> org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)
>>> at
>>> org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEventPrivileged(ServiceRegistry.java:819)
>>> at
>>> org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEvent(ServiceRegistry.java:771)
>>> at
>>> org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.register(ServiceRegistrationImpl.java:130)
>>> at
>>> org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.registerService(ServiceRegistry.java:214)
>>> at
>>> org.eclipse.osgi.framework.internal.core.BundleContextImpl.registerService(BundleContextImpl.java:433)
>>> at
>>> org.eclipse.osgi.framework.internal.core.BundleContextImpl.registerService(BundleContextImpl.java:451)
>>> at
>>> org.wso2.carbon.securevault.internal.SecretManagerInitializerComponent.activate(SecretManagerInitializerComponent.java:48)
>>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>> at
>>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>>> at
>>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>>> at java.lang.reflect.Method.invoke(Method.java:606)
>>> at
>>> org.eclipse.equinox.internal.ds.model.ServiceComponent.activate(ServiceComponent.java:260)
>>> at
>>> org.eclipse.equinox.internal.ds.model.ServiceComponentProp.activate(ServiceComponentProp.java:146)
>>> at
>>> org.eclipse.equinox.internal.ds.model.ServiceComponentProp.build(ServiceComponentProp.java:347)
>>> at
>>> org.eclipse.equinox.internal.ds.InstanceProcess.buildComponent(InstanceProcess.java:620)
>>> at
>>> org.eclipse.equinox.internal.ds.InstanceProcess.buildComponents(InstanceProcess.java:197)
>>> at
>>> org.eclipse.equinox.internal.ds.Resolver.buildNewlySatisfied(Resolver.java:473)
>>> at
>>> org.eclipse.equinox.internal.ds.Resolver.enableComponents(Resolver.java:217)
>>> at
>>> org.eclipse.equinox.internal.ds.SCRManager.performWork(SCRManager.java:816)
>>> at
>>> org.eclipse.equinox.internal.ds.SCRManager$QueuedJob.dispatch(SCRManager.java:783)
>>> at org.eclipse.equinox.internal.ds.WorkThread.run(WorkThread.java:89)
>>> at java.lang.Thread.run(Thread.java:745)
>>>
>>> --
>>> *Asitha Nanayakkara*
>>> Software Engineer
>>> WSO2, Inc. http://wso2.com/
>>> Mob: + 94 77 85 30 682
>>>
>>>
>>> _______________________________________________
>>> Dev mailing list
>>> [email protected]
>>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>>
>>>
>>
>>
>> --
>> *Udara Rathnayake*
>> Software Engineer
>> WSO2 Inc. : http://wso2.com
>>
>> Mobile : +94 772207239
>> Twitter : http://twitter.com/udarakr
>> Blog : http://udarakr.blogspot.com
>>
>>
--
*Asitha Nanayakkara*
Software Engineer
WSO2, Inc. http://wso2.com/
Mob: + 94 77 85 30 682
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev