分布式缓存 - Terracotta& Ehcache - 客户端错误:无法创建工具包

时间:2016-02-24 14:21:53

标签: java ehcache distributed-caching terracotta

我正在使用ehcache(2.10.1)和terracotta(开源4.3.1)实现分布式缓存。我尝试在一台机器上使用两个JVM实例和一个terracotta服务器,代码按预期工作而没有错误。

现在我正在尝试运行相同的兵马俑服务器,但在虚拟机上运行客户端。当我在VM上运行客户端时,我收到以下消息和错误:

2016-02-23 14:27:10,943  INFO TerracottaClient:209 - Thread [main] [cacheManager: no name]: Creating new ClusteredInstanceFactory
2016-02-23 14:27:10,954  WARN TerracottaClusteredInstanceHelper:148 - ehcache-terracotta jar is detected in the current classpath. The use of ehcache-terracotta jar is no longer needed in this version of Ehcache.

2016-02-23 14:27:11,241 INFO - Terracotta 4.3.1, as of 20151016-121959 (Revision 26592 from 4.3.1)
2016-02-23 14:27:12,177 INFO - Successfully loaded base configuration from server at 'A.B.C.D:9510'.

2016-02-23 14:27:12,222 INFO - Log file: '/root/terracotta/client-logs/terracotta-client.log'.

2016-02-23 14:27:18,202 INFO - Connection successfully established to server at A.B.C.D:9510
2016-02-23 14:27:24,731  INFO AnnotationSizeOfFilter:53 - Using regular expression provided through VM argument net.sf.ehcache.pool.sizeof.ignore.pattern for IgnoreSizeOf annotation : ^.*cache\..*IgnoreSizeOf$

Exception in thread "main" net.sf.ehcache.CacheException: Unable to load class net.sf.ehcache.terracotta.StandaloneTerracottaClusteredInstanceFactory. Initial cause was org.terracotta.toolkit.ToolkitInstantiationException: java.lang.RuntimeException: Unable to create toolkit.
    at net.sf.ehcache.util.ClassLoaderUtil.createNewInstance(ClassLoaderUtil.java:90)
    at net.sf.ehcache.terracotta.TerracottaClusteredInstanceHelper.newClusteredInstanceFactory(TerracottaClusteredInstanceHelper.java:157)
    at net.sf.ehcache.terracotta.TerracottaClient.createNewClusteredInstanceFactory(TerracottaClient.java:180)
    at net.sf.ehcache.terracotta.TerracottaClient.createClusteredInstanceFactory(TerracottaClient.java:129)
    at net.sf.ehcache.CacheManager.doInit(CacheManager.java:463)
    at net.sf.ehcache.CacheManager.init(CacheManager.java:395)
    at net.sf.ehcache.CacheManager.<init>(CacheManager.java:295)
    at com.cisco.dcextract.ExtractCache.main(ExtractCache.java:13)

使用的tc-config.xml文件:

<?xml version="1.0" encoding="UTF-8"?>
<con:tc-config xmlns:con="http://www.terracotta.org/config">
  <servers>
    <server host="A.B.C.D" name="tcservername" >
      <data>c:\datacache</data>
      <tsa-port>9510</tsa-port>
      <jmx-port>9520</jmx-port>
    <tsa-group-port>9530</tsa-group-port>
    <offheap>
              <enabled>true</enabled>
              <maxDataSize>2g</maxDataSize>
     </offheap>
      <logs>terracotta/server-logs</logs>
     </server>
    <update-check>
      <enabled>true</enabled>
    </update-check>
  </servers>
  <clients>
    <logs>terracotta/client-logs</logs>
  </clients>  
</con:tc-config>

使用的ehcache.xml文件:

<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="ehcache.xsd"
             updateCheck="true" monitoring="autodetect">
             <terracottaConfig url="A.B.C.D:9510" />

   <defaultCache
            maxElementsInMemory="10000"
            eternal="false"
            timeToIdleSeconds="120"
            timeToLiveSeconds="120"
            overflowToDisk="true"
            diskSpoolBufferSizeMB="30"
            diskPersistent="false"
            diskExpiryThreadIntervalSeconds="120"
            memoryStoreEvictionPolicy="LRU"
            />

    <cache name="cache1290"
           maxElementsInMemory="1000000"
           eternal="false"
           overflowToDisk="false"
           diskSpoolBufferSizeMB="20"
           timeToIdleSeconds="100"
           timeToLiveSeconds="100"
           memoryStoreEvictionPolicy="LRU">
    <terracotta/> 
     </cache>
</ehcache>

在客户端上运行程序时,我已经包含了terracotta-toolkit-runtime-4.3.1.jar&amp;其他必需的罐子。我正在尝试调试错误。可能是错误的原因是什么?

日志文件内容(仅添加相关部分)

2016-02-25 15:37:28,852 [main] INFO com.terracottatech.console - Connection successfully established to server at 173.39.65.73:9510

2016-02-25 15:37:28,852 [WorkerThread(client_coordination_stage, 0)] INFO com.tc.object.RemoteServerMapManager - ClientID[6]: Sending outstanding servermap requests, num msgs: 0

2016-02-25 15:37:28,853 [main] INFO com.terracottatech.tsa - Connection successfully established to server at 173.39.65.73:9510

2016-02-25 15:37:28,853 [WorkerThread(client_coordination_stage, 0)] INFO com.tc.management.remote.protocol.terracotta.TunnelingEventHandler - Client JMX server ready; sending notification to L2 server

2016-02-25 15:37:28,853 [WorkerThread(client_coordination_stage, 0)] INFO com.tc.platform.rejoin.RejoinManagerImpl - This node joined the cluster - rejoinEnabled: false newNodeId: ClientID[6]

2016-02-25 15:37:28,855 [WorkerThread(client_coordination_stage, 0)] INFO com.tc.cluster.DsoClusterImpl - NODE_JOINED ClientID[6] rejoinHappened false

2016-02-25 15:37:33,417 [main] INFO com.tc.management.remote.protocol.terracotta.TunneledDomainManager - Sending current registered tunneled domains to L2 server to set up the tunneled connections for the mbeans that match.

2016-02-25 15:37:34,553 [L1 VM Shutdown Hook] INFO com.terracottatech.tsa - Running L1 VM shutdown hook

2016-02-25 15:37:34,553 [L1 VM Shutdown Hook] INFO com.terracottatech.tsa - shuting down Terracotta Client hook=true force=false

2016-02-25 15:37:34,553 [L1 VM Shutdown Hook] INFO com.terracotta.toolkit.factory.impl.ToolkitNotifierFactoryImpl - Shutting Down Notifier Thread Pool
2016-02-25 15:37:34,554 [CommonShutDownHook] INFO com.terracottatech.tsa - L1 Exiting...
2016-02-25 15:37:34,789 [L1 VM Shutdown Hook] INFO com.tc.object.tx.RemoteTransactionManagerImpl - ClientID[6]: stop(): took 0 millis to complete
2016-02-25 15:37:34,790 [L1 VM Shutdown Hook] INFO com.tc.net.protocol.transport.ConnectionHealthCheckerImpl: DSO Client - Connection to [dhcp-173-39-65-73.cisco.com:9510] CLOSED. Health Monitoring for this node is now disabled.
2016-02-25 15:37:34,790 [L1 VM Shutdown Hook] INFO com.tc.net.protocol.transport.ClientConnectionEstablisher - waiting for connection establisher to finish null
2016-02-25 15:37:34,790 [L1 VM Shutdown Hook] INFO com.tc.platform.rejoin.ClientChannelEventController - Got channel event - type: CHANNEL_CLOSED_EVENT, event: com.tc.net.protocol.tcm.ChannelEventImpl@1768481525[type = CHANNEL_CLOSED_EVENT, timestamp = Thu Feb 25 15:37:34 IST 2016, channel  = ChannelID[NULL_ID, Status:CLOSED]:10.197.70.109:35582 <--> 173.39.65.73:9510 remote node  : GroupID[0]

2 个答案:

答案 0 :(得分:0)

该问题可能是由于缺少依赖项或版本不匹配所致。我也面临同样的问题,通过添加以下依赖项组合来解决它。

<dependencies>
    <dependency>
        <groupId>net.sf.ehcache</groupId>
        <artifactId>ehcache-core</artifactId>
        <version>2.5.6</version>
    </dependency>
    <dependency>
        <groupId>net.sf.ehcache</groupId>
        <artifactId>ehcache-terracotta</artifactId>
        <version>2.5.6</version>
    </dependency>
    <dependency>
        <groupId>org.terracotta</groupId>
        <artifactId>terracotta-toolkit-1.5-runtime</artifactId>
        <version>4.5.0</version>
    </dependency>
    <dependency>
        <groupId>org.terracotta</groupId>
        <artifactId>terracotta-toolkit-runtime</artifactId>
        <version>4.3.2</version>
    </dependency>
</dependencies>

<repositories>
    <repository>
        <id>terracotta-repository</id>
        <url>http://www.terracotta.org/download/reflector/releases</url>
        <releases>
            <enabled>true</enabled>
        </releases>
    </repository>
</repositories>

答案 1 :(得分:0)

我遇到了同样的问题,它通过添加来解决:

    <dependency>
        <groupId>net.sf.ehcache</groupId>
        <artifactId>ehcache-terracotta</artifactId>
        <version>2.5.6</version>
    </dependency>
    <dependency>
        <groupId>org.terracotta</groupId>
        <artifactId>terracotta-toolkit-runtime-ee</artifactId>
        <version>4.1.1</version>
    </dependency>

和仓库:

<repositories>
    <repository>
        <id>terracotta-repository</id>
        <url>http://www.terracotta.org/download/reflector/releases</url>
        <releases>
            <enabled>true</enabled>
        </releases>
    </repository>
</repositories>