Зажечь кеш на существующей Кассандре - PullRequest
0 голосов
/ 08 января 2019

Я новичок в Ignite, пытаюсь использовать Ignite в качестве кэша Cassandra. Я использую свою локальную машину для зажигания и хочу подключить мою удаленную Cassandra. Cassandra запускается как встроенная, когда я даю 127.0.0.1 для Ignite и Cassandra (настройки соединения и yaml). Но когда я пытаюсь подключиться к удаленному.

Это мое соединение 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>

и моя бобовая весна

<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: не удалось запустить встроенный Cassandra

с последующим

java.lang.RuntimeException: фатальная ошибка конфигурации

и

org.apache.cassandra.exceptions.ConfigurationException: Невозможно выполнить привязку к адресу /x.x.x.x:7000. Установите для listen_address в cassandra.yaml интерфейс, который вы можете привязать, например, свой частный IP-адрес в EC2

Я установил правильный адрес в yaml. Любой вклад, пожалуйста?

...