Магазин кэш-памяти Infinispan JDBC

Я хочу использовать Infinispan JDBC Cache Store вместо LevelDb Cache Store.

Вот ниже моя конфигурация:

<infinispan
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="urn:infinispan:config:6.0 http://www.infinispan.org/schemas/infinispan-config-6.0.xsd
                       urn:infinispan:config:jdbc:6.0 http://www.infinispan.org/schemas/infinispan-cachestore-jdbc-config-6.0.xsd"
   xmlns="urn:infinispan:config:6.0"
   xmlns:jdbc="urn:infinispan:config:jdbc:6.0" >
    <global>
        <globalJmxStatistics enabled="false" allowDuplicateDomains="true"/>
    </global>

    <!-- Define the cache loaders (i.e., cache stores). Passivation is false
     because we want *all* data to be persisted, not just what doesn't fit
     into memory. -->
    <persistence>
        <mixedKeyedJdbcStore fetchPersistentState="false" ignoreModifications="false" purgeOnStartup="false">
            <simpleConnection connectionUrl="jdbc:postgresql://localhost:5432/infinispan_binary_based" driverClass="org.postgresql.Driver" username="postgres" password="postgres"/>
            <stringKeyedTable prefix="ISPN_MIXED_STR_TABLE" createOnStart="true" dropOnExit="true">
                <idColumn name="ID_COLUMN" type="VARCHAR(255)" />
                <dataColumn name="DATA_COLUMN" type="BINARY" />
                <timestampColumn name="TIMESTAMP_COLUMN" type="BIGINT" />
            </stringKeyedTable>
            <binaryKeyedTable prefix="ISPN_MIXED_BINARY_TABLE" createOnStart="true" dropOnExit="true">
                <idColumn name="ID_COLUMN" type="VARCHAR(255)" />
                <dataColumn name="DATA_COLUMN" type="BINARY" />
                <timestampColumn name="TIMESTAMP_COLUMN" type="BIGINT" />
            </binaryKeyedTable>
        </mixedKeyedJdbcStore>
    </persistence>
</namedCache>

but I keep getting this exception:

Message: Unexpected element '{urn:infinispan:config:jdbc:6.0}mixedKeyedJdbcStore'  
  at org.infinispan.configuration.parsing.ParserRegistry.parseElement(ParserRegistry.java:139) [infinispan-core-6.0.2.Final.jar:6.0.2.Final]  
  at org.infinispan.configuration.parsing.XMLExtendedStreamReaderImpl.handleAny(XMLExtendedStreamReaderImpl.java:37) [infinispan-core-6.0.2.Final.jar:6.0.2.Final]  
  at org.infinispan.configuration.parsing.Parser60.parsePersistence(Parser60.java:558) [infinispan-core-6.0.2.Final.jar:6.0.2.Final] 

Я удалил банку хранилища кэша leveldb из своих зависимостей и заменил его банкой хранилища кэша jdbc.

Не могли бы вы сказать мне, если я что-то пропустил? Помогите, пожалуйста?

Заранее спасибо.


person Emowpy    schedule 13.04.2015    source источник


Ответы (1)


Вы объявляете пространство имен с именем jdbc, но не используете его. Вам нужно либо префиксировать все теги в MixedKeyedJdbcStore с помощью jdbc:, либо использовать пространство имен по умолчанию, подобное этому:

<infinispan
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="urn:infinispan:config:6.0 http://www.infinispan.org/schemas/infinispan-config-6.0.xsd
                   urn:infinispan:config:jdbc:6.0 http://www.infinispan.org/schemas/infinispan-cachestore-jdbc-config-6.0.xsd"
    xmlns="urn:infinispan:config:6.0"
    xmlns:jdbc="urn:infinispan:config:jdbc:6.0" >
<global>
    <globalJmxStatistics enabled="false" allowDuplicateDomains="true"/>
</global>

<!-- Define the cache loaders (i.e., cache stores). Passivation is false
 because we want *all* data to be persisted, not just what doesn't fit
 into memory. -->
<namedCache name="testCache">
    <persistence>
        <mixedKeyedJdbcStore xmlns="urn:infinispan:config:jdbc:6.0" fetchPersistentState="false" ignoreModifications="false" purgeOnStartup="false">
            <simpleConnection connectionUrl="jdbc:postgresql://localhost:5432/infinispan_binary_based" driverClass="org.postgresql.Driver" username="postgres" password="postgres"/>
            <stringKeyedTable prefix="ISPN_MIXED_STR_TABLE" createOnStart="true" dropOnExit="true">
                <idColumn name="ID_COLUMN" type="VARCHAR(255)" />
                <dataColumn name="DATA_COLUMN" type="BINARY" />
                <timestampColumn name="TIMESTAMP_COLUMN" type="BIGINT" />
            </stringKeyedTable>
            <binaryKeyedTable prefix="ISPN_MIXED_BINARY_TABLE" createOnStart="true" dropOnExit="true">
                <idColumn name="ID_COLUMN" type="VARCHAR(255)" />
                <dataColumn name="DATA_COLUMN" type="BINARY" />
                <timestampColumn name="TIMESTAMP_COLUMN" type="BIGINT" />
            </binaryKeyedTable>
        </mixedKeyedJdbcStore>
    </persistence>
</namedCache>

Your configuration was also missing a starting namedCache tag, but I assume it was a copypaste mistake, otherwise the error message would be different.

person Jakub Markos    schedule 14.04.2015
comment
В дополнение к этому у меня возникла проблема с объединением jar хранилища кеша jdbc в хранилище кеша infinispan. Я только что добавил путь к классам зависимостей в файле манифеста. Спасибо. - person Emowpy; 21.04.2015