在ignite中加入2缓存时找不到数据库
我正致力于利用多个ignite缓存之间的分布式连接。我在两个缓存中都加载了所需的数据,在执行连接时,它在解析SQL时失败,提示“未找到数据库”(请查看堆栈跟踪) 下面是我的ignite配置文件:在ignite中加入2缓存时找不到数据库,ignite,Ignite,我正致力于利用多个ignite缓存之间的分布式连接。我在两个缓存中都加载了所需的数据,在执行连接时,它在解析SQL时失败,提示“未找到数据库”(请查看堆栈跟踪) 下面是我的ignite配置文件: <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="offerCacheStoreFactory" class="javax.cache.configuration.FactoryBuilder" factory-method="factoryOf">
<constructor-arg><value>com.xyz.exploreignite.cache.CustomOfferCacheStore</value></constructor-arg>
</bean>
<bean id="organizationCacheStoreFactory" class="javax.cache.configuration.FactoryBuilder" factory-method="factoryOf">
<constructor-arg><value>com.xyz.exploreignite.cache.CustomOrganizationCacheStore</value></constructor-arg>
</bean>
<bean id="ignite.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
<property name="peerClassLoadingEnabled" value="false"/>
<property name="clientMode" value="false"/>
<property name="gridName" value="clusterGrid"/>
<property name="cacheConfiguration">
<list>
<bean class="org.apache.ignite.configuration.CacheConfiguration">
<property name="atomicityMode" value="ATOMIC"/>
<property name="backups" value="1"/>
<property name="name" value="customOrganizationCache"/>
<property name="readThrough" value="true"/>
<property name="writeThrough" value="true"/>
<property name="cacheMode" value="PARTITIONED"/>
<property name="writeBehindEnabled" value="true"/>
<property name="copyOnRead" value="false"/>
<property name="memoryMode" value="OFFHEAP_TIERED"/>
<property name="atomicWriteOrderMode" value="PRIMARY"/>
<property name="indexedTypes" >
<list>
<value>java.lang.String</value>
<value>com.xyz.exploreignite.pojo.Organization</value>
</list>
</property>
<!-- Cache store. -->
<property name="cacheStoreFactory" ref="organizationCacheStoreFactory"/>
<property name="swapEnabled" value="false"/>
<property name="offHeapMaxMemory" value="0"/>
<property name="evictionPolicy">
<!-- LRU eviction policy. -->
<bean class="org.apache.ignite.cache.eviction.lru.LruEvictionPolicy">
<!-- Set the maximum cache size to 1 million (default is 100,000). -->
<property name="maxSize" value="1000000"/>
</bean>
</property>
</bean>
<bean class="org.apache.ignite.configuration.CacheConfiguration">
<property name="atomicityMode" value="ATOMIC"/>
<property name="backups" value="1"/>
<property name="name" value="customOfferCache"/>
<property name="readThrough" value="true"/>
<property name="writeThrough" value="true"/>
<property name="cacheMode" value="PARTITIONED"/>
<property name="writeBehindEnabled" value="true"/>
<property name="copyOnRead" value="false"/>
<property name="memoryMode" value="OFFHEAP_TIERED"/>
<property name="atomicWriteOrderMode" value="PRIMARY"/>
<property name="indexedTypes" >
<list>
<value>java.lang.String</value>
<value>com.xyz.exploreignite.pojo.Offer</value>
</list>
</property>
<!-- Cache store. -->
<property name="cacheStoreFactory" ref="offerCacheStoreFactory"/>
<property name="swapEnabled" value="false"/>
<property name="offHeapMaxMemory" value="0"/>
<property name="evictionPolicy">
<!-- LRU eviction policy. -->
<bean class="org.apache.ignite.cache.eviction.lru.LruEvictionPolicy">
<!-- Set the maximum cache size to 1 million (default is 100,000). -->
<property name="maxSize" value="1000000"/>
</bean>
</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. For information on all options refer
to our documentation: http://apacheignite.readme.io/docs/cluster-config
-->
<!-- 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>
<value>127.0.0.1:47500..47509</value>
</list>
</property>
</bean>
</property>
</bean>
</property>
</bean>
com.xyz.exploreignite.cache.CustomOfferCacheStore
com.xyz.exploreignite.cache.CustomOrganizationCacheStore
java.lang.String
com.xyz.exploreignite.pojo.Organization
java.lang.String
com.xyz.exploreignite.pojo.Offer
127.0.0.1:47500..47509
下面是我在执行联接时使用的代码:
try (Ignite ignite = Ignition.start(
// "/home/impadmin/ignite/apache-ignite-fabric-1.7.0-bin/examples/config/example-cache-ss-cluster.xml"))
// {
"/home/xyz/msheth/install/apache-ignite-fabric-1.7.0-bin/examples/config/example-cache-ss-cluster.xml")) {
try (IgniteCache<String, Offer> customOfferCache = ignite.getOrCreateCache("customOfferCache");
IgniteCache<String, Organization> customOrganizationCache = ignite
.getOrCreateCache("customOrganizationCache")) {
SqlFieldsQuery joinQuery = new SqlFieldsQuery("select organization.displayName "
+ "from Organization as organization, \"customOfferCache\".Offer as offer"
+ " where organization._id = offer.relationships.customer.targets.key "
+ "and organization._id = ?");
joinQuery.setDistributedJoins(true);
long startTime = System.currentTimeMillis();
try (QueryCursor<List<?>> joinCursor = customOrganizationCache
.query(joinQuery.setArgs("542de0b83b2d445f0a0e0f53"))) {
for (List<?> organizationEntry : joinCursor)
System.out.println("Organizations display name: " + organizationEntry);
}
System.out.println("Time to fetch join based record:" + (System.currentTimeMillis() - startTime));
}
}
try(点火=点火启动(
//“/home/impadmin/ignite/apache-ignite-fabric-1.7.0-bin/examples/config/example cache ss cluster.xml”))
// {
“/home/xyz/msheth/install/apache-ignite-fabric-1.7.0-bin/examples/config/example cache ss cluster.xml”)){
try(IgniteCache customOfferCache=ignite.getOrCreateCache(“customOfferCache”);
IgniteCache customOrganizationCache=ignite
.getOrCreateCache(“customOrganizationCache”)){
SqlFieldsQuery joinQuery=新建SqlFieldsQuery(“选择organization.displayName”
+“来自作为组织的组织,\“customOfferCache\”。作为要约提供”
+“其中组织._id=offer.relationships.customer.targets.key”
+“和组织._id=?”;
setDistributedJoins(true);
long startTime=System.currentTimeMillis();
try(QueryCursor organizationEntry:joinCursor)
System.out.println(“组织显示名称:“+organizationEntry”);
}
System.out.println(“获取基于联接的记录的时间:”+(System.currentTimeMillis()-startTime));
}
}
请帮助我找到根本原因。问题出现在以下表达式中:
offer.relationships.customer.targets.key
围绕这一点的几点考虑:
- 允许嵌套对象,但Ignite将创建平面模式。例如,
字段可以作为customer
表的成员访问,您不应该为此提供完整路径。通常,在使用SQL时应该尽量避免嵌套对象,而是创建简单的POJO类Offer
- 但是,不允许在集合内查询。在您的情况下,
保存为单个对象,您不能根据其内容进行选择。您应该为目标的整个集合
对象提供单独的缓存,并将其与其他表连接起来Target
offer.relationships.customer.targets.key
围绕这一点的几点考虑:
- 允许嵌套对象,但Ignite将创建平面模式。例如,
字段可以作为customer
表的成员访问,您不应该为此提供完整路径。通常,在使用SQL时应该尽量避免嵌套对象,而是创建简单的POJO类Offer
- 但是,不允许在集合内查询。在您的情况下,
保存为单个对象,您不能根据其内容进行选择。您应该为目标的整个集合
对象提供单独的缓存,并将其与其他表连接起来Target
@QuerySqlField
注释具有o