首页 > 解决方案 > Infinispan:为缓存“测试”提供的配置缺少它的命名配置

问题描述

我正在尝试更多地了解 infispan ,并且如文档中所述,我克隆了教程repo。为了轻松上手,我使用了官方的docker 镜像(我尝试了各种标签,包括但不限于 13.0.0.Dev01、13.1、latest)。

不幸的是,例如,当尝试启动远程缓存教程时InfinispanRemoteContinuousQuery,我收到以下错误:

WARN: ISPN004005: Error received from the server: org.infinispan.commons.CacheConfigurationException: ISPN005031: The supplied configuration for cache 'test' is missing a named configuration for it: <distributed-cache name="test">
    <encoding media-type="application/x-protostream"/>
</distributed-cache>
Exception in thread "main" org.infinispan.client.hotrod.exceptions.HotRodClientException:Request for messageId=7 returned server error (status=0x85): org.infinispan.commons.CacheConfigurationException: ISPN005031: The supplied configuration for cache 'test' is missing a named configuration for it: <distributed-cache name="test">
    <encoding media-type="application/x-protostream"/>
</distributed-cache>
    at org.infinispan.client.hotrod.impl.protocol.Codec20.checkForErrorsInResponseStatus(Codec20.java:333)
    [..]

由于这些是教程,我显然还不知道我在做什么,我不知道配置中缺少什么,代码看起来像这样......

public static final String USER = "Titus Bramble";
public static final String PASSWORD = "Shambles";

public static final String TUTORIAL_CACHE_NAME = "test";
public static final String HOST = "127.0.0.1";

public static final String TUTORIAL_CACHE_CONFIG =
     "<distributed-cache name=\"CACHE_NAME\">\n"
     + "    <encoding media-type=\"application/x-protostream\"/>\n"
     + "</distributed-cache>";

/**
* Returns the configuration builder with the connection information
*
* @return a Configuration Builder with the connection config
*/
public static final ConfigurationBuilder connectionConfig() {
  ConfigurationBuilder builder = new ConfigurationBuilder();
  builder.addServer().host("127.0.0.1").port(ConfigurationProperties.DEFAULT_HOTROD_PORT).security()
        .authentication()
        //Add user credentials.
        .username(USER)
        .password(PASSWORD);

  // Docker 4 Mac Workaround. Don't use BASIC intelligence in production
  builder.clientIntelligence(ClientIntelligence.BASIC);

  // Make sure the remote cache is available.
  // If the cache does not exist, the cache will be created
  builder.remoteCache(TUTORIAL_CACHE_NAME)
        .configuration(TUTORIAL_CACHE_CONFIG.replace("CACHE_NAME", TUTORIAL_CACHE_NAME));
  return builder;
}

/**
* Connect to the running Infinispan Server in localhost:11222.
*
* This method illustrates how to connect to a running Infinispan Server with a downloaded
* distribution or a container.
*
* @return a connected RemoteCacheManager
*/
public static final RemoteCacheManager connect() {
 ConfigurationBuilder builder = connectionConfig();

  RemoteCacheManager cacheManager = new RemoteCacheManager(builder.build());

  // Clear the cache in case it already exists from a previous running tutorial
  cacheManager.getCache(TUTORIAL_CACHE_NAME).clear();

  // Return the connected cache manager
  return cacheManager;
}

这是一个 Infinispan 问题还是我只是在这里遗漏了一步?

标签: javainfinispan

解决方案


推荐阅读