在现有Cassandra上点燃缓存

时间:2019-01-08 08:57:14

标签: caching cassandra ignite

我是Ignite的新手,试图将Ignite用作Cassandra缓存。我使用本地计算机进行点火,并希望连接我的远程Cassandra。当我同时为Ignite和Cassandra提供127.0.0.1(连接设置和yaml)时,Cassandra以嵌入式形式开始。但是当我尝试连接到遥控器时。

这是我的连接XML

<bean id="loadBalancingPolicy" class="com.datastax.driver.core.policies.TokenAwarePolicy">
    <constructor-arg
        type="com.datastax.driver.core.policies.LoadBalancingPolicy">
        <bean class="com.datastax.driver.core.policies.RoundRobinPolicy" />
    </constructor-arg>
</bean>

<bean id="cassandraAdminDataSource"
    class="org.apache.ignite.cache.store.cassandra.datasource.DataSource">
    <property name="port" value="9049" />
    <property name="contactPoints" value="x.x.x.x" />
    <property name="readConsistency" value="ONE" />
    <property name="writeConsistency" value="ONE" />
    <property name="loadBalancingPolicy" ref="loadBalancingPolicy" />
</bean>

我的持久连接

<bean id="primitive_csndra_cache" class="org.apache.ignite.cache.store.cassandra.persistence.KeyValuePersistenceSettings">
    <constructor-arg type="java.lang.String">
        <value><![CDATA[
            <persistence keyspace="hello" table="primitive_xyz">
                <keyPersistence class="java.lang.String" strategy="PRIMITIVE" column="key"/>
                <valuePersistence class="java.lang.String" strategy="PRIMITIVE" column="value"/>
            </persistence>]]>
        </value>
    </constructor-arg>
</bean>

<bean id="blob_csndra_cache" class="org.apache.ignite.cache.store.cassandra.persistence.KeyValuePersistenceSettings">
    <constructor-arg type="java.lang.String">
        <value><![CDATA[
            <persistence keyspace="hello" table="blob_persons">
                <keyPersistence class="my.apache.ignite.examples.collocation.PersonKey" strategy="BLOB" column="PersonKey"/>
                <valuePersistence class="my.apache.ignite.examples.collocation.Person" strategy="BLOB" column="Person"/>
            </persistence>]]>
        </value>
    </constructor-arg>
</bean>

<bean id="pojo_csndra_cache" class="org.apache.ignite.cache.store.cassandra.persistence.KeyValuePersistenceSettings">
    <constructor-arg type="java.lang.String">
        <value><![CDATA[
            <persistence keyspace="hello" table="pojo_persons">
                <keyPersistence class="my.apache.ignite.examples.collocation.PersonKey" strategy="POJO">
                    <partitionKey>
                        <field name="companyId" column="key_companyid"/>
                    </partitionKey>

                     <clusterKey>
                        <field name="name" column="key_name" />
                    </clusterKey>
                </keyPersistence>

                <valuePersistence class="my.apache.ignite.examples.collocation.Person" strategy="POJO">
                    <field name="name" column="name" />
                    <field name="age" />
                    <field name="salary" index="true"/>
                    <field name="companyId" />
                </valuePersistence>
            </persistence>]]>
        </value>
    </constructor-arg>
</bean>

我的Spring bean是

<import resource="classpath:cassandra/connection-settings.xml" />
<import resource="classpath:persistence/primitive/persistence-settings.xml" />

<bean id="ignite.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="localHost" value="127.0.0.1"/>

    <property name="gridLogger">
        <bean class="org.apache.ignite.logger.slf4j.Slf4jLogger"/>        
    </property>

    <property name="lifecycleBeans">
        <list>
            <bean class="org.apache.ignite.cache.store.cassandra.bean.CassandraLifeCycleBean">
                <property name="jmxPort" value="9981"/>
                <property name="cassandraConfigFile" value="C:\\\ignite-cassandra\\\src\\\main\\\resources\\\cassandra\\\embedded-cassandra.yaml"/>
            </bean>
        </list>
    </property>

    <property name="cacheConfiguration">
        <list>
            <bean class="org.apache.ignite.configuration.CacheConfiguration">
                <property name="name" value="primitive_csndra_cache"/>
                <property name="cacheMode" value="PARTITIONED"/>
                <property name="atomicityMode" value="ATOMIC"/>
                <property name="backups" value="0"/>
                <property name="readThrough" value="true"/>
                <property name="writeThrough" value="true"/>
                <property name="copyOnRead" value="false"/>
                <property name="eagerTtl" value="false"/>
                <property name="memoryMode" value="OFFHEAP_TIERED"/>
                <property name="offHeapMaxMemory" value="#{10 * 1024 * 1024}"/>
                <property name="swapEnabled" value="false"/>
                <property name="affinity">
                    <bean class="org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction">
                        <property name="partitions" value="10"/>
                    </bean>
                </property>
                <property name="cacheStoreFactory">
                    <bean class="org.apache.ignite.cache.store.cassandra.CassandraCacheStoreFactory">
                        <property name="dataSourceBean" value="cassandraAdminDataSource"/>
                        <property name="persistenceSettingsBean" value="primitive_csndra_cache"/>
                    </bean>
                </property>
                <property name="managementEnabled" value="true"/>
                <property name="readFromBackup" value="true"/>
            </bean>

            <bean class="org.apache.ignite.configuration.CacheConfiguration">
                <property name="name" value="blob_csndra_cache"/>
                <property name="cacheMode" value="PARTITIONED"/>
                <property name="atomicityMode" value="ATOMIC"/>
                <property name="backups" value="0"/>
                <property name="readThrough" value="true"/>
                <property name="writeThrough" value="true"/>
                <property name="copyOnRead" value="false"/>
                <property name="eagerTtl" value="false"/>
                <property name="memoryMode" value="OFFHEAP_TIERED"/>
                <property name="offHeapMaxMemory" value="#{10 * 1024 * 1024}"/>
                <property name="swapEnabled" value="false"/>
                <property name="affinity">
                    <bean class="org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction">
                        <property name="partitions" value="10"/>
                    </bean>
                </property>
                <property name="cacheStoreFactory">
                    <bean class="org.apache.ignite.cache.store.cassandra.CassandraCacheStoreFactory">
                        <property name="dataSourceBean" value="cassandraAdminDataSource"/>
                        <property name="persistenceSettingsBean" value="blob_csndra_cache"/>
                    </bean>
                </property>
                <property name="managementEnabled" value="true"/>
                <property name="readFromBackup" value="true"/>
            </bean>

            <bean class="org.apache.ignite.configuration.CacheConfiguration">
                <property name="name" value="pojo_csndra_cache"/>
                <property name="cacheMode" value="PARTITIONED"/>
                <property name="atomicityMode" value="ATOMIC"/>
                <property name="backups" value="0"/>
                <property name="readThrough" value="true"/>
                <property name="writeThrough" value="true"/>
                <property name="copyOnRead" value="false"/>
                <property name="eagerTtl" value="false"/>
                <property name="memoryMode" value="OFFHEAP_TIERED"/>
                <property name="offHeapMaxMemory" value="#{10 * 1024 * 1024}"/>
                <property name="swapEnabled" value="false"/>
                <property name="affinity">
                    <bean class="org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction">
                        <property name="partitions" value="10"/>
                    </bean>
                </property>
                <property name="cacheStoreFactory">
                    <bean class="org.apache.ignite.cache.store.cassandra.CassandraCacheStoreFactory">
                        <property name="dataSourceBean" value="cassandraAdminDataSource"/>
                        <property name="persistenceSettingsBean" value="pojo_csndra_cache"/>
                    </bean>
                </property>
                <property name="managementEnabled" value="true"/>
                <property name="readFromBackup" value="true"/>
            </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>
                            <!-- In distributed environment, replace with actual host IP address. -->
                            <value>127.0.0.1:47500..47509</value>
                        </list>
                    </property>
                </bean>
            </property>
        </bean>
    </property>
</bean>

当我尝试开始点火时,它会抛出

  

org.apache.ignite.IgniteCheckedException:无法开始嵌入   卡桑德拉

之后

  

java.lang.RuntimeException:致命配置错误

  

org.apache.cassandra.exceptions.ConfigurationException:无法绑定到地址/x.x.x.x:7000。将cassandra.yaml中的listen_address设置为您可以绑定到的接口,例如,您在EC2上的专用IP地址

我在yaml中设置了正确的地址。请输入任何内容?

0 个答案:

没有答案