ignite-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexey Kuznetsov <akuznet...@gridgain.com>
Subject Re: jar file update issue in ignite server side
Date Fri, 22 Apr 2016 03:43:46 GMT
Hi, Kevin!

In case of XML you do not need any custom CacheJdbcPojoStoreExampleFactory.
You should use CacheJdbcPojoStoreFactory and configure Datasource bean in
XML
And set dataSourceBean property.

Take a look on sample bellow:

<?xml version="1.0" encoding="UTF-8"?>

<!-- This configuration was generated by GridGain Web Console (04/22/2016
10:41) -->

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:util="http://www.springframework.org/schema/util"
       xsi:schemaLocation="http://www.springframework.org/schema/beans

http://www.springframework.org/schema/beans/spring-beans.xsd
                           http://www.springframework.org/schema/util

http://www.springframework.org/schema/util/spring-util.xsd">
    <!-- Load external properties file. -->
    <bean id="placeholderConfig"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="location" value="classpath:secret.properties"/>
    </bean>

    <!-- Data source beans will be initialized from external properties
file. -->
    <bean id="ds" class="org.h2.jdbcx.JdbcDataSource">
        <property name="URL" value="${ds.jdbc.url}"/>
        <property name="user" value="${ds.jdbc.username}"/>
        <property name="password" value="${ds.jdbc.password}"/>
    </bean>

    <bean class="org.apache.ignite.configuration.IgniteConfiguration">
        <property name="gridName" value="myCluster"/>
        <property name="discoverySpi">
            <bean
class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
                <property name="ipFinder">
                    <bean
class="org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder">
                        <property name="addresses">
                            <list>
                                <value>127.0.0.1:47500..47510</value>
                            </list>
                        </property>
                    </bean>
                </property>
            </bean>
        </property>

        <property name="cacheConfiguration">
            <list>
                <bean
class="org.apache.ignite.configuration.CacheConfiguration">
                    <property name="name" value="myCache"/>
                    <property name="cacheMode" value="PARTITIONED"/>
                    <property name="atomicityMode" value="ATOMIC"/>
                    <property name="readFromBackup" value="true"/>
                    <property name="copyOnRead" value="true"/>

                    <property name="cacheStoreFactory">
                        <bean
class="org.apache.ignite.cache.store.jdbc.CacheJdbcPojoStoreFactory">
                            <property name="dataSourceBean" value="ds"/>
                            <property name="dialect">
                                <bean
class="org.apache.ignite.cache.store.jdbc.dialect.H2Dialect"/>
                            </property>
                            <property name="types">
                                <list>
                                    <bean
class="org.apache.ignite.cache.store.jdbc.JdbcType">
                                        <property name="cacheName"
value="myCache"/>
                                        <property name="keyType"
value="java.lang.Integer"/>
                                        <property name="valueType"
value="my.org.Person"/>
                                        <property name="databaseSchema"
value="MySchema"/>
                                        <property name="databaseTable"
value="Person"/>

                                        <property name="keyFields">
                                            <list>
                                                <bean
class="org.apache.ignite.cache.store.jdbc.JdbcTypeField">
                                                    <property
name="databaseFieldName" value="id"/>
                                                    <property
name="databaseFieldType">
                                                        <util:constant
static-field="java.sql.Types.INTEGER"/>
                                                    </property>
                                                    <property
name="javaFieldName" value="id"/>
                                                    <property
name="javaFieldType" value="java.lang.Integer"/>
                                                </bean>
                                            </list>
                                        </property>

                                        <property name="valueFields">
                                            <list>
                                                <bean
class="org.apache.ignite.cache.store.jdbc.JdbcTypeField">
                                                    <property
name="databaseFieldName" value="name"/>
                                                    <property
name="databaseFieldType">
                                                        <util:constant
static-field="java.sql.Types.VARCHAR"/>
                                                    </property>
                                                    <property
name="javaFieldName" value="name"/>
                                                    <property
name="javaFieldType" value="java.lang.String"/>
                                                </bean>
                                            </list>
                                        </property>
                                    </bean>
                                </list>
                            </property>
                        </bean>
                    </property>

                    <property name="readThrough" value="true"/>
                    <property name="writeThrough" value="true"/>

                    <property name="queryEntities">
                        <list>
                            <bean
class="org.apache.ignite.cache.QueryEntity">
                                <property name="keyType"
value="java.lang.Integer"/>
                                <property name="valueType"
value="my.org.Person"/>
                                <property name="fields">
                                    <map>
                                        <entry key="id"
value="java.lang.Integer"/>
                                        <entry key="name"
value="java.lang.String"/>
                                    </map>
                                </property>
                            </bean>
                        </list>
                    </property>
                </bean>
            </list>
        </property>
    </bean>
</beans>

-- 
Alexey Kuznetsov
GridGain Systems
www.gridgain.com

Mime
View raw message