How to set Consistency Level in Spring Data Cassandra XML config - cassandra

I am using Spring-Data-Cassandra 1.2.2. I am using XML config as below. I read that the default ConsistencyLevel is ONE, I want to set it to QUORUM. How do I configure it in the XML?
I can upgrade my Spring-Data-Cassandra version if required.
<?xml version='1.0'?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:cassandra="http://www.springframework.org/schema/data/cassandra"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/cql http://www.springframework.org/schema/cql/spring-cql.xsd
http://www.springframework.org/schema/data/cassandra http://www.springframework.org/schema/data/cassandra/spring-cassandra.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<!-- Loads the properties into the Spring Context and uses them to fill in placeholders in the bean definitions -->
<context:property-placeholder location="classpath:resources.properties" />
<!-- REQUIRED: The Cassandra Cluster -->
<cassandra:cluster contact-points="${cassandra.contactpoints}" port="${cassandra.port}" />
<!-- REQUIRED: The Cassandra Session, built from the Cluster, and attaching to a keyspace -->
<cassandra:session keyspace-name="${cassandra.keyspace}" schema-action="CREATE" />
<!-- REQUIRED: The Default Cassandra Mapping Context used by CassandraConverter -->
<cassandra:mapping />
<!-- REQUIRED: The Default Cassandra Converter used by CassandraTemplate -->
<cassandra:converter />
<!-- REQUIRED: The Cassandra Template is the building block of all Spring Data Cassandra -->
<cassandra:template />
<!-- OPTIONAL: If you are using Spring Data Cassandra Repositories, add your base packages to scan here -->
<cassandra:repositories base-package="com.my.package.cassandrarepository" />
</beans>

Seems JavaConfig is the only solution. Upgrading from 1.2.2 to 1.5 was proving to be a bit complicated cos of other spring-data(mongo & JPA) dependencies in my proj. So I used the following config in 1.2.2 version: com.datastax.driver.core.Cluster.builder().withQueryOptions(‌​new QueryOptions().setConsistencyLevel(ConsistencyLevel.QUORUM))

Related

Columns is not generating during code-generation in records

Sample XML file:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<configuration xmlns="http://www.jooq.org/xsd/jooq-codegen-3.17.0.xsd">
<!-- Configure the database connection here -->
<jdbc>
<driver>com.mysql.cj.jdbc.Driver</driver>
<url></url>
<user></user>
<password></password>
</jdbc>
<!-- onError SILENT can be used with MYSQLDatabase for Memsql -->
<!-- <onError>SILENT</onError> -->
<generator>
<generate>
<records>true</records>
<instanceFields>true</instanceFields>
<generatedAnnotation>true</generatedAnnotation>
<generatedAnnotationType>DETECT_FROM_JDK</generatedAnnotationType>
</generate>
Earlier this file generated jOOQ code with records, and had columns. Now code generated but jooq-columns are not present
This looks like a regression in the MemSQLDatabase, probably introduced with jOOQ 3.16's support for computed columns: https://github.com/jOOQ/jOOQ/issues/13854

hazelcast client not getting the full dataset from a cluster

I am using hazelcast v3.6 (client-server mode). The relevant parts of the client and server configs are copied below. When I call IMap.size(), I get the count for the full set of data that I have inserted into the test cluster (2 node). However, when I get the keySet or entrySet, I only get the set for half of the keys/objects. I tried running the localKeySet from the client but that throws the following exception:
Exception in thread "main" java.lang.UnsupportedOperationException: Locality is ambiguous for client!!!
at com.hazelcast.client.proxy.ClientMapProxy.localKeySet(ClientMapProxy.java:1172)
I think localKeySet is not available on the client but need to reconfirm that as well.
Client config - relevant parts, not the full config:
<hazelcast-client xsi:schemaLocation="http://www.hazelcast.com/schema/client-config hazelcast-client-config-3.6.xsd"
xmlns="http://www.hazelcast.com/schema/client-config"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<properties>
<property name="hazelcast.client.shuffle.member.list">true</property>
<property name="hazelcast.client.heartbeat.timeout">60000</property>
<property name="hazelcast.client.heartbeat.interval">5000</property>
<property name="hazelcast.client.event.thread.count">5</property>
<property name="hazelcast.client.event.queue.capacity">1000000</property>
<property name="hazelcast.client.invocation.timeout.seconds">120</property>
</properties>
<network>
<cluster-members>
<!-- ip addresses replaced -->
<address>101.102.103.104</address>
<address>101.102.103.105</address>
</cluster-members>
<smart-routing>true</smart-routing>
<redo-operation>true</redo-operation>
<connection-timeout>60000</connection-timeout>
<connection-attempt-period>3000</connection-attempt-period>
<connection-attempt-limit>2</connection-attempt-limit>
<socket-options>
<tcp-no-delay>false</tcp-no-delay>
<keep-alive>true</keep-alive>
<reuse-address>true</reuse-address>
<linger-seconds>3</linger-seconds>
<timeout>-1</timeout>
<buffer-size>32</buffer-size>
</socket-options>
</network>
Server Config - relevant parts
<network>
<port auto-increment="true" port-count="100">5701</port>
<outbound-ports>
<ports>0-5900</ports>
</outbound-ports>
<join>
<multicast enabled="false">
</multicast>
<tcp-ip enabled="true">
<member>101.102.103.104</member>
<member>101.102.103.105</member>
</tcp-ip>
</join>
<interfaces enabled="true">
<interface>101.102.103.104</interface> <!-- this is modified for the second server node -->
</interfaces>
<ssl enabled="false" />
<socket-interceptor enabled="false" />
<symmetric-encryption enabled="false">
<algorithm>PBEWithMD5AndDES</algorithm>
<!-- salt value to use when generating the secret key -->
<salt>test</salt>
<!-- pass phrase to use when generating the secret key -->
<password>testpass</password>
<!-- iteration count to use when generating the secret key -->
<iteration-count>19</iteration-count>
</symmetric-encryption>
</network>
Any thoughts on what might be causing the issue and ways to fix it?
Update:
I have tried replicating the setup on another two node cluster but have not been able to reproduce the same issue. When I call the keySet on the new cluster, I get the full set of keys, not half (unlike the original cluster). I am aware that I can use Predicates instead of getting the whole keySet.
Update
I will try to do that in the near future - I have to dig through the logs. The issue was resolved when I brought down one node and the second node became the primary for all the data (it was a two node test cluster with async replication factor of 1). After that, when I brought up the second node again, the data was distributed again and I did not see any issues with the two node cluster. So it appears that something happened after the cluster was brought up that resulted in the hazelcast client getting the map values from both nodes but any call to the keyset/entry set was just getting keys/values from one node. I tried switching the order in the hazelcast client (xml file) to see if that would change the keyset/entries that the client was receiving but that did not solve the issue.

Spring Integration - Difference from channel and int:channel

I'm studing by few days Spring Integration and in some example i've noticed the use of channel and int:channel.
What is the difference ?
In the same way, there are other keywords: someone start with int: and other (with the same name) are not.
It just depends on how you configure the namespaces at the top of the XML file, and specifically the default xmlns. In the first case, the integration schema is the default, in the second, something else is, usually beans...
<beans:beans xmlns="http://www.springframework.org/schema/integration"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http://www.springframework.org/schema/beans"
...
In this case, integration is the default xmlns and you would use
<channel ...
and
<beans:bean ...
here...
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:int="http://www.springframework.org/schema/integration"
...
beans is the default xmlns and you would use
<int:channel...
and
<bean ....
So, it's simply a matter of personal choice.

Spring 3.2.5 tiles 3 not rendering the view

I have gone through other post of rendering the view using spring3.2.5 & tiles3
in my context-servlet.xml
<bean id="viewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver">
<property name="viewClass">
<value>
org.springframework.web.servlet.view.tiles3.TilesView
</value>
</property>
In my tiles-servlet.xml
<bean id="tilesConfigurer"
class="org.springframework.web.servlet.view.tiles3.TilesConfigurer">
<property name="definitions">
<list>
<value>/WEB-INF/tiles/common/tiles.xml</value>
<value>/WEB-INF/tiles/common/base_tiles.xml</value>
<value>/WEB-INF/tiles/common/person_tiles.xml</value>
</list>
</property>
</bean>
In person_tiles.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE tiles-definitions PUBLIC
"-//Apache Software Foundation//DTD Tiles Configuration 3.0//EN"
"http://tiles.apache.org/dtds/tiles-config_3_0.dtd">
<tiles-definitions>
<definition name="new_person" extends="base.definition">
<put-attribute name="body" value="/WEB-INF/xx/xxx/web_person.jsp" />
</definition>
</tiles-defnitions>
It throws below error
javax.servlet.ServletException: Could not resolve view with name 'new_person' in servlet with name 'project'
please help me to solve the issue.
Related issue discussing this "behavior" is SPR-11491 and is specific to Tiles v3.
It comes from SpringWildcardServletTilesApplicationContext.getResources(String) -> URLApplicationResource(String, URL) constructor -> super PostfixedApplicationResource(String localePath) constructor. When there is an underscore in definition filenames, the string after the last underscore is identified as the locale.
The Tiles section of Spring 4.0.3 reference documentation has been updated in order to make this behavior more explicit, and there are ongoing discussion with Tiles development team to get this fixed by checking the locale against Locale.getISOLanguageCodes() in order to get a less surprising default behavior.
After lot of digging I found that tiles is not loading the resources properly.
Here i am not sure whether it is a bug (spring 3.2.5 & tiles 3.0.1) or not:
But I solved this issue by following
here in my tiles-servlet.xml
<bean id="tilesConfigurer"
class="org.springframework.web.servlet.view.tiles3.TilesConfigurer">
<property name="definitions">
<list>
<value>/WEB-INF/tiles/common/tiles.xml</value>
<value>/WEB-INF/tiles/common/baseTiles.xml</value><!-- Change the base_tiles to baseTiles.xml or base.xml -->
<value>/WEB-INF/tiles/common/personTiles.xml</value><!-- Change the person_tiles.xml to personTiles.xml or person.xml-->
</list>
</property>
</bean>
Here when we have the definitions value as separated with underscore (ex: person_tiles or base_tiles) it is not loading the resource.However tiles.xml the tiles-definitions are accessible.
But I tried with tiles 2.2 & spring 3.2.5 it works correctly. Even though we give as person_tiles or base_tiles.xml.
In tiles-servlet.xml
Change the base_tiles & person_tiles to baseTiles & personTiles, and changed the file names accordingly.
OR
Change the base_tiles & person_tiles to base & person, and changed the file names accordingly.
I hope somebody can find it as useful.

Is FeatureUpgrading supposed to use the latest Property values?

The 1.0.0.0 version of my Feature's Template.xml file looked like this:
<?xml version="1.0" encoding="utf-8" ?>
<Feature xmlns="http://schemas.microsoft.com/sharepoint/">
<Properties>
<Property Key="AvailableWebTemplates" Value="MPS#0;MPS#1;MPS#2;MPS#3;MPS#4" />
</Properties>
</Feature>
The new version 1.1.0.0 is as follows:
<?xml version="1.0" encoding="utf-8" ?>
<Feature xmlns="http://schemas.microsoft.com/sharepoint/">
<UpgradeActions>
<VersionRange BeginVersion="1.0.0.0" EndVersion="1.1.0.0">
<CustomUpgradeAction Name="UpgradeTo1v1"/>
</VersionRange>
</UpgradeActions>
<Properties>
<Property Key="AvailableWebTemplates" Value="MPS#0;MPS#1;MPS#2;MPS#3;MPS#4;STS#2" />
</Properties>
</Feature>
The value of templates is still MPS#0;MPS#1;MPS#2;MPS#3;MPS#4, when the following code runs in FeatureUpgrading:
SPFeatureProperty property = properties.Feature.Properties["AvailableWebTemplates"];
string templates = property.Value;
Why am I not getting the updated property value? Is this the way it is supposed to be?
This is indeed the way it is supposed to be:
A feature has 1 definition and n instances. The code in FeatureUpgrading is used to upgrade the instances.
The property in your xml updates the feature definition and not the running instances.
properties.Feature.Properties["MyProp"] gets the property value of the running instance properties.Definition.Properties["MyProp"] gets the value of the property in the feature definition.

Resources