【发布时间】:2018-12-25 04:10:52
【问题描述】:
我有 2 个集群,集群 1 有一个名为“cache1”的缓存,它有一些数据
我想要什么,当客户端连接集群 2 时,当它说 igniteCache.getOrCreateCache("cache1") 时,它应该返回我在集群 1 中创建的缓存,并且客户端应该能够在集群 2 中进行 CRUD 操作这将更新集群 1 和集群 2 中的缓存。
(根据我的研究,我可以使用 Apache Ignite Native Persistence 这里是链接http://frommyworkshop.blogspot.com/2017/09/the-apache-ignite-native-persistence.html)
我可以将 Postgresql 与 Ignite Persistence 一起使用吗?或者我应该找到另一个解决方案。 (特别是我正在寻找有关 ignite 功能的答案)
两个 xml 文件中都没有缓存配置,但假设它会是
这是我的集群 1 配置
<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="ignite.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
<!--set the cluster name-->
<property name="igniteInstanceName" value="FirstCluster"/>
<property name="discoverySpi">
<bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
<!--Initial local port to listen-->
<property name="localPort" value="48500"/>
<!--determine local port range-->
<property name="localPortRange" value="20"/>
<!--Set the ip finder-->
<property name="ipFinder">
<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
<property name="addresses">
<list>
<value>127.0.0.1:48500..48520</value>
</list>
</property>
</bean>
</property>
</bean>
</property>
<property name="communicationSpi">
<bean class="org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi">
<property name="localPort" value="48100"/>
</bean>
</property>
</bean>
这是我的集群 2 配置
<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="ignite.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
<!--set the cluster name-->
<property name="igniteInstanceName" value="SecondCluster"/>
<!-- Enabling Apache Ignite Persistent Store. -->
<!--<property name="dataStorageConfiguration">-->
<!--<bean class="org.apache.ignite.configuration.DataStorageConfiguration">-->
<!--<property name="defaultDataRegionConfiguration">-->
<!--<bean class="org.apache.ignite.configuration.DataRegionConfiguration">-->
<!--<property name="persistenceEnabled" value="true"/>-->
<!--</bean>-->
<!--</property>-->
<!--</bean>-->
<!--</property>-->
<property name="discoverySpi">
<bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
<!-- Initial local port to listen to. -->
<property name="localPort" value="49500"/>
<!-- Changing local port range. This is an optional action. -->
<property name="localPortRange" value="20"/>
<!-- Setting up IP finder for this cluster -->
<property name="ipFinder">
<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
<property name="addresses">
<list>
<!--
Addresses and port range of the nodes from the second
cluster.
127.0.0.1 can be replaced with actual IP addresses or
host names. Port range is optional.
-->
<value>127.0.0.1:49500..49520</value>
</list>
</property>
</bean>
</property>
</bean>
</property>
<property name="communicationSpi">
<bean class="org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi">
<property name="localPort" value="49100"/>
</bean>
</property>
</bean>
【问题讨论】: