Attached. thanks.
On Mon, Mar 16, 2020 at 8:28 PM Evgenii Zhuravlev <[email protected]>
wrote:
> Hi, please share the whole config file
>
> пн, 16 мар. 2020 г. в 15:38, narges saleh <[email protected]>:
>
>> Thanks Evgenii for the reply.
>> How do I do that in XML configuration file if my query entities are
>> defined solely in the xml file? What does ClassNameOfKey and
>> fieldNameinThatClass represent? I assume I will have one bean for each
>> cache.
>> <bean class="...CacheConfiguration">
>> <property name="keyConfiguration">
>> <list>
>> <bean class="org.apache.ignite.cache.CacheKeyConfiguration">
>> <property name="typeName" value="ClassNameOfKey"/>
>> <property name="affinityKeyFieldName"
>>
>> value="fieldNameInThatClass"/>
>> </bean>
>> </list>
>> </property>
>> </bean>
>> And the bean for the query entity is:have
>> <bean class="org.apache.ignite.cache.QueryEntity">
>> <property name="keyType"
>> value="java.lang.Integer"/>
>> <property name="valueType"
>> value="PERSON"/>
>> <property name="tableName"
>> value="PERSON"/>
>> <!-- Set fields for value object. -->
>> <property name="fields">
>> <map>
>> <entry key="CompanyId"
>> value="java.lang.Integer"/>
>> <entry key="EmployeeId"
>> value="java.lang.Integer"/>
>> <entry key="firstName"
>> value="java.lang.String"/>
>> <entry key="lastName"
>> value="java.lang.String"/>
>> </map>
>> </property>
>> <property name="keyFields">
>> <set>
>> <!-- These are fields stored in
>> the key. -->
>> <value>CompanyId</value>
>> <value>EmployeeId</value>
>> </set>
>> </property>
>> </bean>
>>
>>
>> On Mon, Mar 16, 2020 at 3:22 PM Evgenii Zhuravlev <
>> [email protected]> wrote:
>>
>>> Hi,
>>>
>>> You should have one cache per table(query entity) and configure separate
>>> CacheKeyConfigurations for each of the caches.
>>>
>>> Evgenii
>>>
>>> пн, 16 мар. 2020 г. в 11:42, narges saleh <[email protected]>:
>>>
>>>> Hi All,
>>>>
>>>> I have a question that might be trivial.
>>>> If I define my query entity for each in the XML configuration file and
>>>> define the affinity key via CacheKeyConfiguration (again in the xml file),
>>>> considering that here affinity key is defined at IgniteConfiguration level,
>>>> how do I specify which cache keys (i.e., query entity key fields) will use
>>>> the affinity key and which ones don't?
>>>>
>>>> Say I have these 4 tables
>>>> Employee(company-id, employee-id)
>>>> Contractor(company-id, contractor-id)
>>>> Customer(company-id, customer-id)
>>>> Company(company-id, address)
>>>>
>>>> How do I collocate employee, and contractors with companies but not the
>>>> customers and companies? Can you provide the CacheKeyConfiguration and
>>>> keyfields for each query entity?
>>>>
>>>> thanks.
>>>>
>>>
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<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">
<bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
<!-- Set to true to enable distributed class loading for examples, default is false. -->
<property name="peerClassLoadingEnabled" value="true"/>
<property name="cacheConfiguration">
<list>
<bean class="org.apache.ignite.configuration.CacheConfiguration">
<property name="name" value="EMPLOYEE"/>
<property name="cacheMode" value="PARTITIONED"/>
<property name="atomicityMode" value="ATOMIC"/>
<property name="writeSynchronizationMode" value="FULL_SYNC"/>
<!-- Configure type metadata to enable queries. -->
<property name="queryEntities">
<list>
<bean class="org.apache.ignite.cache.QueryEntity">
<property name="keyType" value="java.lang.Integer"/>
<property name="valueType" value="EMPLOYEE"/>
<property name="tableName" value="EMPLOYEE"/>
<!-- Set fields for value object. -->
<property name="fields">
<map>
<entry key="employeeId" value="java.lang.Integer"/>
<entry key="companyId" value="java.lang.Integer"/>
<entry key="firstName" value="java.lang.String"/>
<entry key="lastName" value="java.lang.String"/>
</map>
</property>
<property name="keyFields">
<set>
<!-- These are fields stored in the key. -->
<value>employeeId</value>
<value>companyId</value>
</set>
</property>
</bean>
</list>
</property>
</bean>
<bean class="org.apache.ignite.configuration.CacheConfiguration">
<property name="name" value="CONTRACTOR"/>
<property name="cacheMode" value="PARTITIONED"/>
<property name="atomicityMode" value="ATOMIC"/>
<property name="writeSynchronizationMode" value="FULL_SYNC"/>
<!-- Configure type metadata to enable queries. -->
<property name="queryEntities">
<list>
<bean class="org.apache.ignite.cache.QueryEntity">
<property name="keyType" value="java.lang.Integer"/>
<property name="valueType" value="CONTRACTOR"/>
<property name="tableName" value="CONTRACTOR"/>
<!-- Set fields for value object. -->
<property name="fields">
<map>
<entry key="contractorId" value="java.lang.Integer"/>
<entry key="companyId" value="java.lang.Integer"/>
<entry key="firstName" value="java.lang.String"/>
<entry key="lastName" value="java.lang.String"/>
</map>
</property>
<property name="keyFields">
<set>
<!-- These are fields stored in the key. -->
<value>contractorId</value>
<value>companyId</value>
</set>
</property>
</bean>
</list>
</property>
</bean>
<bean class="org.apache.ignite.configuration.CacheConfiguration">
<property name="name" value="CUSTOMER"/>
<property name="cacheMode" value="PARTITIONED"/>
<property name="atomicityMode" value="ATOMIC"/>
<property name="writeSynchronizationMode" value="FULL_SYNC"/>
<!-- Configure type metadata to enable queries. -->
<property name="queryEntities">
<list>
<bean class="org.apache.ignite.cache.QueryEntity">
<property name="keyType" value="java.lang.Integer"/>
<property name="valueType" value="CUSTOMER"/>
<property name="tableName" value="CUSTOMER"/>
<!-- Set fields for value object. -->
<property name="fields">
<map>
<entry key="customerId" value="java.lang.Integer"/>
<entry key="companyId" value="java.lang.Integer"/>
<entry key="firstName" value="java.lang.String"/>
<entry key="lastName" value="java.lang.String"/>
</map>
</property>
<property name="keyFields">
<set>
<!-- These are fields stored in the key. -->
<value>customerId</value>
</set>
</property>
</bean>
</list>
</property>
</bean>
<bean class="org.apache.ignite.configuration.CacheConfiguration">
<property name="name" value="COMPANY"/>
<property name="cacheMode" value="PARTITIONED"/>
<property name="atomicityMode" value="ATOMIC"/>
<property name="writeSynchronizationMode" value="FULL_SYNC"/>
<!-- Configure type metadata to enable queries. -->
<property name="queryEntities">
<list>
<bean class="org.apache.ignite.cache.QueryEntity">
<property name="keyType" value="java.lang.Integer"/>
<property name="valueType" value="COMPANY"/>
<property name="tableName" value="COMPANY"/>
<!-- Set fields for value object. -->
<property name="fields">
<map>
<entry key="companyId" value="java.lang.Integer"/>
<entry key="companyName" value="java.lang.String"/>
</map>
</property>
<property name="keyFields">
<set>
<!-- These are fields stored in the key. -->
<value>companyId</value>
</set>
</property>
</bean>
</list>
</property>
</bean>
</list>
</property>
<!-- Explicitly configure TCP discovery SPI to provide list of initial nodes. -->
<property name="discoverySpi">
<bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
<property name="ipFinder">
<!--
Ignite provides several options for automatic discovery that can be used
instead os static IP based discovery.
-->
<!-- Uncomment static IP finder to enable static-based discovery of initial nodes. -->
<!--<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">-->
<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder">
<property name="addresses">
<list>
<!-- In distributed environment, replace with actual host IP address. -->
<value>127.0.0.1:47550..47551</value>
</list>
</property>
</bean>
</property>
</bean>
</property>
</bean>
</beans>