Infinispan 7.1 Cassandra cache-store - cassandra

I have a very simple cache of type String, Long in Infinispan. I would like to persist this cache to cassandra.
I have installed Infinispan 7.1 Server and I have a cassandra instance running.
I've looked at http://infinispan.org/docs/cachestores/cassandra/ which lists two xml excerpts. Since I am completely new to Infinispan, I have no idea where to add the listed xml.
Is there an example Infinispan 7.1 server installation somewhere where this is setup and working?
EDIT 1:
I am able to use file based persistence by defining myCache as follows:
<subsystem xmlns="urn:infinispan:server:core:7.1" default-cache-container="clustered">
<cache-container name="clustered" default-cache="default" statistics="true">
<transport executor="infinispan-transport" lock-timeout="60000"/>
<distributed-cache name="myCache" mode="SYNC" start="EAGER">
<file-store
shared="false" preload="true"
fetch-state="true"
read-only="false"
purge="false"
path="${java.io.tmpdir}">
<write-behind flush-lock-timeout="15000" thread-pool-size="5" />
</file-store>
</distributed-cache>
</cache-container>
</subsystem>
The schema for the xml defines a "store" element that extends "custom-store".
<xs:element name="store" type="tns:custom-store">
Sooo... I guess I need to study its schema to see how I can create a Cassandra store.
I have a constant feeling I'm doing something wrong because I can find no examples of anyone using this xml...
EDIT 2
Replaced file-store with the following:
<store
name="cassandraStore"
class="org.infinispan.loaders.cassandra.CassandraCacheStore"
shared="true" preload="false" passivation="false"
fetch-state="true">
<property name="host">localhost</property>
<property name="keySpace">mykeyspace</property>
<property name="entryColumnFamily">mytable</property>
<property name="expirationColumnFamily">mytableExpiration</property>
<property name="sharedKeyspace">false</property>
<property name="readConsistencyLevel">ONE</property>
<property name="writeConsistencyLevel">ONE</property>
<property name="configurationPropertiesFile">cassandrapool.properties</property>
<property name="keyMapper">org.infinispan.loaders.keymappers.DefaultTwoWayKey2StringMapper</property>
</store>
When I start infinispan server I get
"JBAS010292: org.infinispan.loaders.cassandra.CassandraCacheStore is not a valid cache store"
Looking at http://mvnrepository.com/artifact/org.infinispan/infinispan-cachestore-cassandra I see the latest version is 6.0.0.Alpha1 from July of 2013
I think the conclusion here is: Cassandra is not supported by Infinispan.

Related

Spring Integration with RedisLockRegistry example

We are implementing a flow where a <int-sftp:inbound-streaming-channel-adapter/> polls a directory for a file and when found it passes the stream to a service activator.
The issue is we will have multiple instances of the app running and we would like to lock the process so that only one instance can pick up the file.
Looking at the documentation, Redis Lock Registry looks to be the solution, is there an example of this being used in xml?
All I can find is a few references to it and the source code for it.
http://docs.spring.io/spring-integration/reference/html/redis.html point 24.1
Added info:
Ive added the RedisMetaDataStore and SftpSimplePatternFileListFilter. It does work but it does have one oddity, when sftpInboundAdapter is activated by the poller it adds an entry for each file in the metadatastore. Say there are 10 files, there would be 10 entries in the datastore, but it does not process all 10 files in "1 go", only 1 file is processed per poll from the adapter, which would be fine, but in a multi instance environment if the server which picked up the files went down after processing 5 files, another server doesn't seem to pick up the remaining 5 files unless the files are "touched".
Is the behaviour of picking up 1 file per poll correct or should it process all valid files during one poll.
Below is my XML
<int:channel id="sftpInbound"/> <!-- To Java -->
<int:channel id="sftpOutbound"/>
<int:channel id="sftpStreamTransformer"/>
<int-sftp:inbound-streaming-channel-adapter id="sftpInboundAdapter"
channel="sftpInbound"
session-factory="sftpSessionFactory"
filter="compositeFilter"
remote-file-separator="/"
remote-directory="${sftp.directory}">
<int:poller cron="${sftp.cron}"/>
</int-sftp:inbound-streaming-channel-adapter>
<int:stream-transformer input-channel="sftpStreamTransformer" output-channel="sftpOutbound"/>
<bean id="compositeFilter"
class="org.springframework.integration.file.filters.CompositeFileListFilter">
<constructor-arg>
<list>
<bean
class="org.springframework.integration.sftp.filters.SftpSimplePatternFileListFilter">
<constructor-arg value="Receipt*.txt" />
</bean>
<bean id="SftpPersistentAcceptOnceFileListFilter" class="org.springframework.integration.sftp.filters.SftpPersistentAcceptOnceFileListFilter">
<constructor-arg ref="metadataStore" />
<constructor-arg value="ReceiptLock_" />
</bean>
</list>
</constructor-arg>
</bean>
<bean id="redisConnectionFactory"
class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory">
<property name="port" value="${redis.port}" />
<property name="password" value="${redis.password}" />
<property name="hostName" value="${redis.host}" />
</bean>
No; you need to use a SftpPersistentAcceptOnceFileListFilter (docs here) with a Redis (or some other) metadata store, not a lock registry.
EDIT
Regarding your comment below.
Yes, it's a known issue; in the next release we've added a max-fetch-size for exactly this reason - so the instances can each retrieve some of the files rather than the first instance grabbing them all.
(The inbound adapter works by first copying files found, that are not already in the store, to the local disk, and then emits them one at a time).
5.0 only available as a milestone right now M2 at the time of writing, but the current version and milestone repo can be found here; it won't be released for a few more months.
Another alternative would be to use outbound gateways - one to LS the files and one to GET individual files; your app would have to use the metadata store itself, though, to determine which file(s) can be fetched.

How to open txvpck files? (JBuilder UML diagrams)

I have UML diagrams created long ago with JBuilder, a Java IDE apparently defunct since 2008. I am unable to download previous installers, as the product is not even mentioned anymore on the editor website.
The files are XML-based with the extension txvpck, here's an example of their contents:
<?xml version="1.0" encoding="UTF-8"?>
<nodeSet version="1.0">
<view uin="id5n25le5bftm2ge5bfvjng">
<property name="$metaclass" value="Package Diagram"/>
<property name="#__options" value=""/>
<reference df-class-name="reference" referencedUin="design:view:::idv3x1e5bftm2ge5bfvkxc">
<property name="$shortcutReference" value="true"/>
<property name="#__fqn" value="uml:package:MyProduct:src:com"/>
<property name="bounds" value="10,10,102,184"/>
</reference>
<property name="$defaultDiagram" value=""/>
</view>
</nodeSet>
Is there a way to open these files with another UML tool or library, and convert them to an usable format?
A while ago I also worked with Borland/Embacadero tools,... . Usually it is possible to open the UML files from one of those tools with an other one, and I expect that they still support those legacy files. So youcan open it with any newer version of a Borland/Emba tools that has integrated UML support. Maybe an professional edition, e.g, Delphi, would be sufficient to view your old model.

Gridgain: how to redistribute partitioned-mode cache when one node brought down

I am new to gridgain and we are doing a POC using gridgain. We did some simple examples using partitioned cache, it works well however we found that when we bring a node down, cache from that node was gone. so my questions is: if we keep using patitioned mode, is there any way to re-distributed cache when a node (or several nodes) is undeployed. if not, is there any good way to do it? Thanks!
configuration Code:
<context:component-scan base-package="com.test" />
<bean id="hostGrid" class="org.gridgain.grid.GridSpringBean">
<property name="configuration">
<bean class="org.gridgain.grid.GridConfiguration">
<property name="localHost" value="127.0.0.1"/>
<property name="peerClassLoadingEnabled" value="false"/>
<property name="marshaller">
<bean class="org.gridgain.grid.marshaller.optimized.GridOptimizedMarshaller">
<property name="requireSerializable" value="false"/>
</bean>
</property
<property name="cacheConfiguration">
<list>
<bean class="org.gridgain.grid.cache.GridCacheConfiguration">
<property name="name" value="CACHE"/>
<property name="cacheMode" value="PARTITIONED"/>
<property name="store" >
<bean class="com.test.CacheJdbcPOCStore"></bean>
</property>
</bean>
</list>
</property>
</bean>
</property>
</bean>
We deployed the same war (using above configuration) to 3 tomcat 7 server. we did not specify number of backup so it should be 1 by default.
follow up
I solved this problem by putting backups= 1 in configuration. looks like previously it did not create backup copy. however it should make 1 copy since it is by default. also, when i tried to bring down 2 nodes at one time, i saw part of cache was gone, so I set backups=2 and found no cache loss this time. so it looks like if in a very bad case where all nodes except for the main node crash, we need to have # of nodes -1 backups to prevent data loss. but if I do so then it is just like replicated mode and replicated mode has less restriction on query and transactions. So my question is : if we need to take the advantage of parallel computation and at mean time want to prevent data loss when nodes crash what is the best practice?
Thanks!
Number of backups is 0 by default. The documentation has been fixed.
You are right about REPLICATED mode. If you are worried about any data loss, the REPLICATED mode is the only way to guarantee it. The disadvantage here is that writes will get slower, as all the nodes in the cluster will be updated. The advantage is that the data is available on every node, so you can easily access it from your computations without worrying which node to send them to.

Jaxb2Marshaller in StaxEventItemReader causing UnmarshalException

So I'm trying to parse an xml and unmarshal it into a program. This is the example xml:
<MaintenanceTransaction:provideCommunicationEvents_BatchRequest
xmlns:MaintenanceTransaction="http://www.pwx.com/Interface/CRS/MaintenanceTransaction_v02"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<MaintenanceTransaction:maintenanceTransaction>
<MaintenanceTransaction:eventInitiatedBy>
<MaintenanceTransaction:identifier>FINACLE</MaintenanceTransaction:identifier>
</MaintenanceTransaction:eventInitiatedBy>
<MaintenanceTransaction:transactionDate>2014-06-21T19:00:32.356+01:00</MaintenanceTransaction:transactionDate>
<MaintenanceTransaction:maintenanceTransactionType>PRE-NOTIFICATION
</MaintenanceTransaction:maintenanceTransactionType>
<MaintenanceTransaction:maintenanceEntries>
<MaintenanceTransaction:hasNewValues xsi:type="MaintenanceTransaction:DepositArrangement">
<MaintenanceTransaction:enterpriseId xsi:type="MaintenanceTransaction:ArrangementIdentifier">
<MaintenanceTransaction:identifier>222000000322</MaintenanceTransaction:identifier>
<MaintenanceTransaction:enterpriseIdType>Term Deposit</MaintenanceTransaction:enterpriseIdType>
</MaintenanceTransaction:enterpriseId>
<MaintenanceTransaction:maturityDate>2014-10-08</MaintenanceTransaction:maturityDate>
</MaintenanceTransaction:hasNewValues>
</MaintenanceTransaction:maintenanceEntries>
</MaintenanceTransaction:maintenanceTransaction>
</MaintenanceTransaction:provideCommunicationEvents_BatchRequest>
The xsd is defined as:
<xsd:schema xmlns:MaintenanceTransaction="http://www.pwx.com/Interface/CRS/MaintenanceTransaction_v02" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.pwx.com/Interface/CRS/MaintenanceTransaction_v02" elementFormDefault="qualified" attributeFormDefault="qualified">
<xsd:include schemaLocation="./commonIFWxsd/IFWXML.xsd" />
<xsd:include schemaLocation="./commonIFWxsd/Event.xsd" />
<xsd:include schemaLocation="./commonIFWxsd/Arrangement.xsd" />
<!-- end of TYPES REQUIRED FOR PARAMETERS -->
<xsd:complexType name="provideCommunicationEvents_BatchRequest">
<xsd:sequence>
<xsd:element name="maintenanceTransaction" type="MaintenanceTransaction:MaintenanceTransaction" maxOccurs="unbounded" />
</xsd:sequence>
</xsd:complexType>
<!-- TYPES REQUIRED FOR PARAMETERS -->
<xsd:element name="provideCommunicationEvents_BatchRequest" type="MaintenanceTransaction:provideCommunicationEvents_BatchRequest" />
</xsd:schema>
With the following setup of my StaxEventItemReader and Jaxb2Marshaller:
<bean id="uploadEventMessageReader" parent="abstractUploadEventMessageReader" scope="step">
<property name="resource" value="file:#{jobExecutionContext['fileToProcess']}"/>
<property name="fragmentRootElementName" value="maintenanceTransaction"/>
<property name="unmarshaller" ref="maintenanceTransactionUnmarshaller"/>
</bean>
<bean id="maintenanceTransactionUnmarshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller" scope="step">
<property name="classesToBeBound">
<list>
<value>com.pwx.crs.informationcollection.ifw.process.model.mt.MaintenanceTransaction</value>
</list>
</property>
</bean>
The problem however is that I get the following exception.
* [javax.xml.bind.UnmarshalException: unexpected element (uri:"http://www.pwx.com/Interface/CRS/MaintenanceTransaction_v02", local:"maintenanceTransaction"). Expected elements are (none)] on step uploadEventMessages, with message: uploadEventMessagesStep.
* --stacktrace:com.pwx.crs.frwk.exp.technical.CRS2UnexpectedBatchException: An unexpected exception occurred in batch job JAXB unmarshalling exception; nested exception is javax.xml.bind.UnmarshalException
Any idea what this is about?
When I slightly change the maintenanceTransaction opening tag of the input xml like this:
<MaintenanceTransaction:maintenanceTransaction xsi:type="MaintenanceTransaction:MaintenanceTransaction">
It does work. But that is not a solution as the clients won't deliver the input xml's like that. So why is the error occuring? There seems to be a problem with determining which class maintenanceTransaction is part of.
Also tried different approaches on the marshaller bean definition:
<bean id="maintenanceTransactionUnmarshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller" scope="step">
<property name="contextPath" value="com.pwx.crs.informationcollection.ifw.process.model.mt"/>
</bean>
and
<bean id="maintenanceTransactionUnmarshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller" scope="step">
<property name="classesToBeBound">
<list>
<value>com.pwx.crs.informationcollection.ifw.process.model.mt.ObjectFactory</value>
</list>
</property>
</bean>
The results for both are the same and similar to the first error
javax.xml.bind.UnmarshalException: unexpected element (uri:"http://www.pwx.com/Interface/CRS/MaintenanceTransaction_v02", local:"maintenanceTransaction"). Expected elements are <{http://www.pwx.com/Interface/CRS/MaintenanceTransaction_v02}AccessTokenLifecycleStatus>
... and here the whole list of classes in the package.
But the xml is perfectly valid against the xsd, as that is done beforehand. Idea's, suggestions, ... that I could try?
Here's my theory.
What mappedClass actually does is switches the unmarshalling method from unmarshaller.unmarshal(source) to unmarshaller.unmarshal(source, this.mappedClass). This is called "partial unmarshalling", i.e. you can unmarshal a known class from some element regardless of the element name.
So, as you say, this works for you. And it does not without mappedClass. This would mean that you are missing an element declaration for your root element. This also alignes well with the error you have reported:
javax.xml.bind.UnmarshalException: unexpected element
(uri:"http://www.pwx.com/Interface/CRS/MaintenanceTransaction_v02",
local:"maintenanceTransaction"). Expected elements are (none)
Which says basically the same thing.
This is also correct. As your schema does not declare a global element for the maintenanceTransaction, only for provideCommunicationEvents_BatchRequest.
So, basically you're unmarshalling the wrong element. And as your schema does not have a declaration for that, this fails. But if you specify exactly which type you want (thus providing the declaration "explicitly"), then it works.
Next, the question is, why do you you unmarshal the wrong element. My guess is that this is because you have
<property name="fragmentRootElementName" value="maintenanceTransaction"/>
This probably points the unmarshaller to use the maintenanceTransaction element as the root element. So the unmarshaller is applied to the wrong element.
Using contextPath, adding more bound classes etc. does not help as none of it adds the element declaration for the maintenanceTransaction.
Now, how to fix this. I see the following options:
Add a global element for maintenanceTransaction to your schema
(OR) Customize your schema to generate an additional #XmlRootElement for MaintenanceTransaction
(OR) Don't use the fragmentRootElementName, unmarshal provideCommunicationEvents_BatchRequest
(OR) Leave it as is with mappedClass
If you handle a specific case here, namely maintenanceTransaction then I'd use the fragmentRootElementName/mappedClass combo. Just as you do now.
So after researching through the code and debugging and much more labour I ended up with something that works. I don't exactly know why, as it was a guess, but it works.
<bean id="maintenanceTransactionUnmarshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
<property name="classesToBeBound">
<list>
<value>com.pwx.crs.informationcollection.ifw.process.model.mt.MaintenanceTransaction</value>
</list>
</property>
<property name="mappedClass" value="com.pwx.crs.informationcollection.ifw.process.model.mt.MaintenanceTransaction"/>
</bean>
As you can see it was not necessary to use the ObjectFactory as classesToBeBound (But it has to be noted that it would have worked as well but in my opinion this is more readable). The thing that really fixes it is adding a mappedClass.
From what I have seen in the code while debugging (I could not check the code f UnmarshallingImpl as this is part of rt.jar and this is not public even though it is part of the jre ...) The classesToBeBound parameter is used to create the jaxbContext for the unmarshaller and the mappedClass is passed to this unmarshaller as expectedType. But when this is not provided and the ObjectFactory is used as parameter the error clearly shows a list of expected classes and the one applicable is present ... Maybe a bug in the unmarshaller, maybe something that I don't understand. But my root problem is solved.
When creating a JAXBContext on a model generated from an XML Schema you should do one of the following to get all the necessary metadata:
Option #1 - Create it on the Generated ObjectFactory Class
<bean id="maintenanceTransactionUnmarshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller" scope="step">
<property name="classesToBeBound">
<list>
<value>com.pwx.crs.informationcollection.ifw.process.model.mt.ObjectFactory</value>
</list>
</property>
</bean>
Option #2 - Create it on the Package Name(s) of the Generated Model
<bean id="maintenanceTransactionUnmarshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller" scope="step">
<property name="contextPath" value="com.pwx.crs.informationcollection.ifw.process.model.mt"/>
</bean>

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.

Resources