4 Replies Latest reply on May 13, 2013 10:40 AM by singhl1

    Basic Modeshape config

    singhl1

      I am very new to modeshape 3.1, and my requirement is to store files to a Modeshape repository, my configuration will be a Web App on Tomcat 6 with Spring 3 and MS SQL database.

       

      I am a little confused about transactions and the need for a database, do I still need a database if my content is all to be stored on a file system?

       

      My json cofig is:

       

      {

          "name": "Repository",

          "jndiName": "",

          "workspaces": {

              "predefined": ["defaultWorkspace"],

              "default": "defaultWorkspace",

              "allowCreation": true

          },

          "security": {

              "anonymous": {

                  "roles": ["readonly", "readwrite", "admin"],

                  "useOnFailedLogin": false

              }

          },

          "storage": {

              "cacheConfiguration": "infinispan-configuration.xml",

              "cacheName": "isisRepository",

              "binaryStorage": {

                  "type": "file",

                  "directory": "/isis-repo/ModeShape"

              }

          },

          "query": {

              "enabled": true,

              "enableFullTextSearch": true,

              "rebuildUponStartup": "if_missing",

              "indexStorage": {

                  "type": "ram"

              },

              "textExtracting": {

                  "extractors": {

                      "tikaExtractor": {

                          "name": "Tika content-based extractor",

                          "classname": "tika"

                      }

                  }

              }

          },

          "sequencing": {

              "removeDerivedContentWithOriginal": true,

              "sequencers": {

                  "Images in separate location": {

                      "classname": "ImageSequencer",

                      "pathExpression": "defaultWorkspace://(*.(gif|png|pict|jpg))/jcr:content[@jcr:data] => defaultWorkspace:/sequenced/images"

                  },

                  "Images in the same location": {

                      "classname": "org.modeshape.sequencer.image.ImageMetadataSequencer",

                      "pathExpressions": ["defaultWorkspace://(*.(gif|png|pict|jpg))/jcr:content[@jcr:data]"]

                  }

              }

          }

      }

       

       

      My infinispan config is:

       

      <?xml version="1.0" encoding="UTF-8"?>

      <infinispan xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

                xsi:schemaLocation="urn:infinispan:config:5.1 http://www.infinispan.org/schemas/infinispan-config-5.1.xsd"

                xmlns="urn:infinispan:config:5.1">

          <global>

              <globalJmxStatistics enabled="false" allowDuplicateDomains="true"/>

          </global>

       

       

          <default>

          </default>

       

       

          <namedCache name="iRepository">

              <loaders passivation="false" shared="false" preload="false">

                  <loader class="org.infinispan.loaders.file.FileCacheStore"

                          fetchPersistentState="false" purgeOnStartup="false">

                      <properties>

                          <property name="location" value="/isis-repo/ModeShape/content" />

                      </properties>

                  </loader>

              </loaders>

       

       

              <transaction

                  transactionMode="NON_TRANSACTIONAL" />

                      transactionManagerLookupClass="org.infinispan.transaction.lookup.JBossStandaloneJTAManagerLookup"

                     

                     lockingMode="OPTIMISTIC"

       

       

          </namedCache>

       

       

      </infinispan>

       

      I have tired various configs for the transaction part, but cannot get it to work, any help greatly appreciated, especially trying to get the config to work with spring and tomcat.

        • 1. Re: Basic Modeshape config
          rhauch

          I am very new to modeshape 3.1, and my requirement is to store files to a Modeshape repository, my configuration will be a Web App on Tomcat 6 with Spring 3 and MS SQL database.

           

          I am a little confused about transactions and the need for a database, do I still need a database if my content is all to be stored on a file system?

           

          No, if you store your content on the file system (using the FileCacheStore in the Infinispan configuration) then you do not need to store anything in a database. Basically, you can choose a variety of ways to persist your information, and if you create a large enough cluster you can even just keep your information in-memory by configuring Infinispan to maintain multiple copies of all information. See the discussion of clustering topologies in our documentation.

           

          ModeShape is transactional and strongly-consistent, so you will need to configure Infinispan to use transactions internally via the "transactionMode" in the Infinispan configuration. Note that you used "NON_TRANSACTIONAL", which is incorrect. (Other applications can use Infinispan in a non-transactional way, but ModeShape needs to be able to atomically update multiple entries in Infinispan, which is why we expect Infinispan to use transactions.)

           

          IIRC, Tomcat 6 does not have a built-in transaction manager, which means you'll need to configure and use a standalone JTA transaction manager implementation, and then make sure that Infinispan can find it (via its "transactionManagerLookupClass" configuration parameter).

           

          Some notes/problems about your ModeShape configuration

           

          • You're storing the searc indexes in RAM, which means that every time ModeShape starts it will have to rebuild the indexes. This maybe okay in development or in smaller production repositories, but for other situations you will probably want to consider storing these on the file system, too.
          • The "cacheName" field must have a value that matches the name of a cache in your Infinispan configuration, but the current value of "isisRepository" does not match an existing one. Therefore, ModeShape will ask Infinispan for a repository with that name, and since one is not configured Infinispan will create a new one using the "default" settings. We highly recommend you explicitly configure all Infinispan caches used in ModeShape repositories.
          • You've configured full-text search. This is fine, but be aware that this does add overhead to maintaining the indexes. If you are not going to use full-text search, we recommend you turn this off.
          • You've configured two sequencers with the same input, so in effect each image will be sequenced twice (once by each sequencer). This is okay for development/testing, but you will likely not want to do this in production.
          • You're telling Infinispan to store the content in the "/isis-repo/ModeShape/content" folder, and ModeShape to store binaries in the "/isis-repo/ModeShape" folder. I'd recommend changing the latter to be "/isis-repo/ModeShape/binaries" for consistency. (I would also recommend storing the indexes under "/isis-repo/ModeShape/indexes", if you choose to store them on the file system.)

           

          I have tired various configs for the transaction part, but cannot get it to work, any help greatly appreciated, especially trying to get the config to work with spring and tomcat.

           

          I suspect the main problem is the wrong "cacheName" parameter in the ModeShape configuration. If correcting that doesn't work, make sure that you're Infinispan configuration is in a file named "infinispan-configuration.xml" and on the application classpath. (This is what you're specifying in the ModeShape configuration's "cacheConfiguration" field.)

          • 2. Re: Basic Modeshape config
            singhl1

            Ok - if i understand correctly, I do NOT need a database. But i do need a transaction manager for infinispan, JTA as you suggest, and infinispan needs to find it - from what i remember, there is an interface ineed to implement which will retrurn the transaction manager (org.infinispan.transaction.lookup.TransactionManagerLookup), is that ok?

             

            I need to change my search index to be file based.

             

            Correct the cache name.

             

            I will look at the full text search stuff.

             

            And also the sequencers and content stuff.

            • 3. Re: Basic Modeshape config
              rhauch

              Ok - if i understand correctly, I do NOT need a database. But i do need a transaction manager for infinispan, JTA as you suggest, and infinispan needs to find it

              Correct.

              from what i remember, there is an interface ineed to implement which will retrurn the transaction manager (org.infinispan.transaction.lookup.TransactionManagerLookup), is that ok?

              Yes. Infinispan provides several implementation classes, and we use one in our tests that instantiates Atomikos (see here). If you use something else or need to configure it differently (since you're using Spring), you'll need to implement one yourself.

               

              Good luck.

              • 4. Re: Basic Modeshape config
                singhl1

                OK - thanks, makes more sense now, many thanks for the quick response.