3 Replies Latest reply on Sep 16, 2010 8:09 AM by sannegrinovero

    Lucene Directory & JDBC loader & Marshalling Exception

    garcimouche

      Hi,

       

      I'm using the Infinispan implementation of the Lucene Directory with a jdbc binary store. My xml config is:

       

      <namedCache name="luceneIndex">
              <loaders passivation="false" shared="true" preload="false">
                  <loader
                      fetchPersistentState="false" ignoreModifications="false"
                      purgeOnStartup="false">
                      <properties>
                          <property name="bucketTableNamePrefix" value="ISPN_BUCKET_TABLE" />
                          <property name="idColumnName" value="ID_COLUMN" />
                          <property name="dataColumnName" value="DATA_COLUMN" />
                          <property name="timestampColumnName" value="TIMESTAMP_COLUMN" />
                          <property name="timestampColumnType" value="BIGINT" />
                          <property name="connectionFactoryClass"
                              value="org.infinispan.loaders.jdbc.connectionfactory.PooledConnectionFactory" />
                          <property name="connectionUrl" value="jdbc:mysql:///infinispan" />
                          <property name="userName" value="infinispan" />
                          <property name="driverClass" value="com.mysql.jdbc.Driver" />
                          <property name="idColumnType" value="VARCHAR(255)" />
                          <property name="dataColumnType" value="BINARY" />
                          <property name="dropTableOnExit" value="true" />
                          <property name="createTableOnStart" value="true" />
                      </properties>
                  </loader>
              </loaders>
              <eviction strategy="NONE"/>
              
              <clustering mode="distribution">
                  <l1 enabled="true" lifespan="60000" />
                  <hash numOwners="2" />
                  <sync />
              </clustering>
              <invocationBatching enabled="true" />
              <transaction syncCommitPhase="true" syncRollbackPhase="true"
                  transactionManagerLookupClass="org.infinispan.transaction.lookup.JBossStandaloneJTAManagerLookup"
                  useEagerLocking="true" />
          </namedCache>

       

      I try to create a new index using the lucene IndexWriter class and got this exception:

       

      2010-05-26 12:44:12,318 ERROR (org.infinispan.marshall.VersionAwareMarshaller)[main:] Unable to read version id from first two bytes of stream, barfing.
      2010-05-26 12:44:12,320 ERROR (org.infinispan.loaders.jdbc.JdbcUtil)[main:] I/O error while unmarshalling from stream
      java.io.IOException: Unable to read version id from first two bytes of stream: Read past end of file
          at org.infinispan.marshall.VersionAwareMarshaller.startObjectInput(VersionAwareMarshaller.java:155)
          at org.infinispan.marshall.VersionAwareMarshaller.objectFromByteBuffer(VersionAwareMarshaller.java:107)
          at org.infinispan.marshall.AbstractMarshaller.objectFromInputStream(AbstractMarshaller.java:24)
          at org.infinispan.loaders.jdbc.JdbcUtil.unmarshall(JdbcUtil.java:88)
          at org.infinispan.loaders.jdbc.binary.JdbcBinaryCacheStore.loadBucket(JdbcBinaryCacheStore.java:220)
          at org.infinispan.loaders.bucket.BucketBasedCacheStore.storeLockSafe(BucketBasedCacheStore.java:59)
          at org.infinispan.loaders.LockSupportCacheStore.store(LockSupportCacheStore.java:147)
          at org.infinispan.interceptors.DistCacheStoreInterceptor.visitPutKeyValueCommand(DistCacheStoreInterceptor.java:81)
          at org.infinispan.commands.write.PutKeyValueCommand.acceptVisitor(PutKeyValueCommand.java:76)
          at org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:118)
          at org.infinispan.interceptors.CacheLoaderInterceptor.visitPutKeyValueCommand(CacheLoaderInterceptor.java:78)
      
       .......more stack entries
      
      

       

      I run version 4.1.0.ALPHA2 of infinispan. Anyone can give me a pointer ? ( I tried using JdbcStringBasedCacheStore but I guess the infinispan-lucene keys are not String compliant...).

      Thank you.

        • 1. Re: Lucene Directory & JDBC loader & Marshalling Exception
          sannegrinovero

          Exactly the keys are not Strings but objects, you should use JdbcBinaryCacheStore.

          Here is a sample configuration I've been using with MySQL:

           

          <namedCache name="ScarletIndexes">
                <clustering mode="distribution">
                   <stateRetrieval />
                   <sync />
                   <hash rehashEnabled="true" numOwners="2" rehashWait="120000" />
                   <l1 enabled="true" lifespan="600000" />
                </clustering>
                <jmxStatistics enabled="true" />
                <loaders passivation="false" shared="true" preload="true">
                   <loader fetchPersistentState="false" ignoreModifications="false" purgeOnStartup="false">

           

                      <!-- See the documentation for more configuration examples and flags. -->
                      <properties>
                         <property name="createTableOnStart" value="true" />

           

                         <!-- Settings for MySQL: -->
                         <property name="connectionUrl" value="jdbc:mysql://localhost:3306/databasename" />
                         <property name="userName" value="user" />
                         <property name="password" value="password" />
                         <property name="driverClass" value="com.mysql.jdbc.Driver" />
                         <property name="dataColumnType" value="BLOB" />

           

                         <!-- Settings for HSQLDB: -->
                         <!--<property name="connectionUrl" value="jdbc:hsqldb:." />-->
                         <!--<property name="userName" value="sa" />-->
                         <!--<property name="password" value="" />-->
                         <!--<property name="driverClass" value="org.hsqldb.jdbcDriver" />-->
                         <!--<property name="dataColumnType" value="BINARY" />-->

           

                         <property name="connectionFactoryClass" value="org.infinispan.loaders.jdbc.connectionfactory.SimpleConnectionFactory" />
                         <!--
                            <property name="connectionFactoryClass" value="org.infinispan.loaders.jdbc.connectionfactory.ManagedConnectionFactory" />
                         -->
                         <!--<property name="datasourceJndiLocation" value="..." />-->
                         <property name="bucketTableNamePrefix" value="scar_lucene" />
                         <!--<property name="cacheName" value="ScarletIndexes" />-->
                         <property name="idColumnType" value="VARCHAR(256)" />
                         <property name="idColumnName" value="idCol" />
                         <property name="dataColumnName" value="dataCol" />

           

                         <property name="timestampColumnName" value="timestampCol" />
                         <property name="timestampColumnType" value="BIGINT" />
                      </properties>
                      <async enabled="true" flushLockTimeout="15000" threadPoolSize="3" />
                   </loader>
                </loaders>
                <eviction wakeUpInterval="5000" maxEntries="-1" strategy="NONE" />
                <expiration maxIdle="-1" />
             </namedCache>

          • 2. Re: Lucene Directory & JDBC loader & Marshalling Exception
            garcimouche

            I changed the dataTypeCoolumn from BINARY to BLOB as you suggest and it works. Thanks Sanne for your help and the wonderful idea of implementing an Infinispan Directory on top of Lucene. I'll resume my testing.

            • 3. Re: Lucene Directory & JDBC loader & Marshalling Exception
              sannegrinovero

              in contrast to what I posted earlier, since version 4.1.0 it's possible to use JdbcStringBasedCacheStore if you configure the appropriate key2StringConverter (as explained on the wiki and in other forum posts).