【问题标题】:EhCache Jgroups ReplicationEhCache Jgroups 复制
【发布时间】:2015-02-27 18:44:04
【问题描述】:

在我基于 sping 的项目(spring 版本 4.1.5.FINAL)中,我使用的是 ehcache-core 版本 2.6.10、ehcache-jgroupsreplication 版本 1.7 和 jgroups 3.1.0.FINAL

这是我的 XML ehcache 配置:

<?xml version="1.0" encoding="UTF-8"?>
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd" name="webCache" >
<diskStore path="java.io.tmpdir/webCache"/>
<cacheManagerPeerProviderFactory class="net.sf.ehcache.distribution.jgroups.JGroupsCacheManagerPeerProviderFactory" properties="udp.xml"/>
<cache name="it.test.cache.CustomCache"
            maxElementsInMemory="1000"
            eternal="false"
            timeToIdleSeconds="600"
            timeToLiveSeconds="6000"
            overflowToDisk="true">
<cacheEventListenerFactory class="net.sf.ehcache.distribution.jgroups.JGroupsCacheReplicatorFactory" properties="replicateAsynchronously=true,replicatePuts=true,replicateUpdates=true,replicateUpdatesViaCopy=false,replicateRemovals=true" />
</cache>  
</ehcache>

这是我的 upd.xml 配置:

<config xmlns="urn:org:jgroups"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="urn:org:jgroups http://www.jgroups.org/schema/jgroups.xsd">
    <UDP
         mcast_port="${jgroups.udp.mcast_port:45588}"
         tos="8"
         ucast_recv_buf_size="200K"
         ucast_send_buf_size="200K"
         mcast_recv_buf_size="200K"
         mcast_send_buf_size="200K"
         max_bundle_size="64K"
         max_bundle_timeout="30"
         ip_ttl="${jgroups.udp.ip_ttl:2}"
         enable_diagnostics="true"
         thread_naming_pattern="cl"
         timer_type="new"
         timer.min_threads="4"
         timer.max_threads="10"
         timer.keep_alive_time="3000"
         timer.queue_max_size="500"
         thread_pool.enabled="true"
         thread_pool.min_threads="2"
         thread_pool.max_threads="8"
         thread_pool.keep_alive_time="5000"
         thread_pool.queue_enabled="true"
         thread_pool.queue_max_size="10000"
         thread_pool.rejection_policy="discard"
         oob_thread_pool.enabled="true"
         oob_thread_pool.min_threads="1"
         oob_thread_pool.max_threads="8"
         oob_thread_pool.keep_alive_time="5000"
         oob_thread_pool.queue_enabled="false"
         oob_thread_pool.queue_max_size="100"
         oob_thread_pool.rejection_policy="Run"/>
    <PING />
    <MERGE3 max_interval="30000"
            min_interval="10000"/>
    <FD_SOCK/>
    <FD_ALL/>
    <VERIFY_SUSPECT timeout="1500"  />
    <BARRIER />
    <pbcast.NAKACK use_mcast_xmit="true"
                   retransmit_timeout="300,600,1200"
                   discard_delivered_msgs="true"/>
    <UNICAST/>
    <pbcast.STABLE stability_delay="1000" desired_avg_gossip="50000"
                   max_bytes="4M"/>
    <pbcast.GMS print_local_addr="true" join_timeout="3000"
                view_bundling="true"/>
    <UFC max_credits="2M"
         min_threshold="0.4"/>
    <MFC max_credits="2M"
         min_threshold="0.4"/>
    <FRAG2 frag_size="60K"  />
    <pbcast.STATE_TRANSFER />
</config>

在我的 spring xml 上下文中,我有以下内容(我将只放置我的 spring 上下文文件的一个片段):

<bean id="settaSystemProps" name="settaSystemProps" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
    <property name="targetObject">
        <bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
            <property name="targetClass" value="java.lang.System" />
            <property name="targetMethod" value="getProperties" />
        </bean>
    </property>
    <property
        name="targetMethod" value="putAll" />
    <property
        name="arguments">
        <util:properties>
            <prop key="jgroups.logging.log_factory_class">it.test.cache.replication.jgroups.log.logback.impl.LogbackLogImpl</prop>
            <prop key="java.net.preferIPv4Stack">true</prop>
        </util:properties>
    </property>
</bean> 
<bean id="webCacheManager" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean" depends-on="settaSystemProps">
    <property name="configLocation" value="classpath:webCoMiEhCacheCfg.xml"/>
</bean>

遗憾的是,通过使用此配置,我无法在集群中发送/接收消息

当我启动我的 tomcat 时,我看到以下打印(并且它没有使用我的自定义日志):

2015 年 2 月 27 日上午 10:31:18 org.jgroups.logging.JDKLogImpl 错误严重: 向集群发送消息失败(65 字节):java.lang.Exception: dest=/228.8.8.8:45588(68 字节),原因:java.io.IOException: Invalid 争论 2015 年 2 月 27 日上午 10:31:19 org.jgroups.logging.JDKLogImpl 错误 Grave:向集群发送消息失败(65 字节): java.lang.Exception: dest=/228.8.8.8:45588 (68 bytes),原因: java.io.IOException:参数无效 2015 年 2 月 27 日上午 10:31:28 org.jgroups.logging.JDKLogImpl 错误严重:发送消息失败 集群(65 字节):java.lang.Exception:dest=/228.8.8.8:45588(68 字节),原因:java.io.IOException:无效参数 2015 年 2 月 27 日 上午 10:31:28 org.jgroups.logging.JDKLogImpl 错误严重:发送失败 到集群的消息(65 字节):java.lang.Exception: dest=/228.8.8.8:45588(68 字节),原因:java.io.IOException: Invalid 论据

谁能告诉我哪里错了?我需要的是在一个由 2 个节点组成的集群上同步 EhCache

谁能提供给我一个有效的配置示例?

谢谢

安杰洛

【问题讨论】:

    标签: ehcache jgroups


    【解决方案1】:

    启动实例时的输出是什么?我认为您可能仍在使用 IPv6。您可以使用 -Djava.net.preferIPv4Stack=true 而不是在 XML 中定义它吗?

    【讨论】:

    • 我按照你的建议试过了,现在似乎可以了;在我的环境中,我设置了以下属性:-Djava.net.preferIPv4Stack=true -Djgroups.logging.log_factory_class=customLog。缓存现在在由 3 个节点(2 个 tomcat 和 1 个 IBM WAS)组成的集群上同步,但在我看来,customLog 没有被使用。无论如何...谢谢您
    • 您可能需要定义自定义日志的完整类名。很高兴听到它现在有效
    • 我使用了完整的限定名(在早期评论中我使用了快捷方式)我会尝试调查,因为我需要使用记录器的 logback 实现...谢谢
    • @Angelo。自定义记录器也不适合我。你能解决问题吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-03-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多