Robotregent
Robotregent

Reputation: 95

Jackrabbit clustering with a H2 database in mixed mode

I have a Magnolia CMS system and I try to configure a clustered repository for a workspace with user generated content. We will have an author and a public instance, each with a dedicated MYSQL database for the magnolia default repository. The user generated content should be stored in a h2 database which will be located in a shared directory. We can't start the h2 database directly in server mode, therefore, the connections to the h2 database will be configured as mixed mode with the flag AUTO_SERVER=true (see http://www.h2database.com/html/features.html#auto_mixed_mode).

The initializing of the repositories is flawless. Once data is stored in the clustered repository the next reboot stops/hangs during the loading phase of the clustered repository (see log).

Did i miss a configuration? Is it even possible to use a h2 in mixed mode for jackrabbit clustering?

repository.xml:

<JCR>
    <RepositoryMapping>
        <Map name="userGeneratedContent" repositoryName="magnoliacluster" workspaceName="userGeneratedContent" />
        <Map name="website" repositoryName="magnolia" workspaceName="website" />
        <Map name="config" repositoryName="magnolia" workspaceName="config" />
        <Map name="users" repositoryName="magnolia" workspaceName="users" />
        <Map name="userroles" repositoryName="magnolia" workspaceName="userroles" />
        <Map name="usergroups" repositoryName="magnolia" workspaceName="usergroups" />
        <Map name="mgnlSystem" repositoryName="magnolia" workspaceName="mgnlSystem" /> <!-- System internal data -->
        <Map name="mgnlVersion" repositoryName="magnolia" workspaceName="mgnlVersion" /> <!-- magnolia version workspace -->
    </RepositoryMapping>

    <!-- magnolia default repository -->
    <Repository name="magnolia" provider="info.magnolia.jackrabbit.ProviderImpl" loadOnStartup="true">
        <param name="configFile" value="${magnolia.repositories.jackrabbit.config}" />
        <param name="repositoryHome" value="${magnolia.repositories.home}/magnolia" />
        <!-- the default node types are loaded automatically
            <param name="customNodeTypes" value="WEB-INF/config/repo-conf/nodetypes/magnolia_nodetypes.xml" />
        -->
        <param name="contextFactoryClass" value="org.apache.jackrabbit.core.jndi.provider.DummyInitialContextFactory" />
        <param name="providerURL" value="localhost" />
        <param name="bindName" value="${magnolia.webapp}" />
        <workspace name="website" />
        <workspace name="config" />
        <workspace name="users" />
        <workspace name="userroles" />
        <workspace name="usergroups" />
        <workspace name="mgnlSystem" />
        <workspace name="mgnlVersion" />
    </Repository>

    <!-- magnolia cluster repository -->
    <Repository name="magnoliacluster" provider="info.magnolia.jackrabbit.ProviderImpl" loadOnStartup="true">
        <param name="configFile" value="${magnolia.repositories.jackrabbit.cluster.config}" />
        <param name="repositoryHome" value="${magnolia.repositories.home}/magnoliacluster" />
        <!-- the default node types are loaded automatically
            <param name="customNodeTypes" value="WEB-INF/config/repo-conf/nodetypes/magnolia_nodetypes.xml" />
        -->
        <param name="contextFactoryClass" value="org.apache.jackrabbit.core.jndi.provider.DummyInitialContextFactory" />
        <param name="providerURL" value="localhost" />
        <param name="bindName" value="cluster-${magnolia.webapp}" />
        <workspace name="userGeneratedContent" />
    </Repository>
</JCR>

clustered-jackrabbit-bundle-h2-search.xml:

<Repository>
    <FileSystem class="org.apache.jackrabbit.core.fs.db.DbFileSystem">
        <param name="url" value="jdbc:h2:/PATH/TO/db;AUTO_SERVER=TRUE"/>
        <param name="schemaObjectPrefix" value="fs_"/>
        <param name="user" value="sa"/>
        <param name="password" value="sa"/>
    </FileSystem>
    <Security appName="magnolia">
        <SecurityManager class="org.apache.jackrabbit.core.DefaultSecurityManager" />
        <AccessManager
            class="org.apache.jackrabbit.core.security.DefaultAccessManager">
        </AccessManager>
        <LoginModule
            class="info.magnolia.jaas.sp.jcr.JackrabbitAuthenticationModule">
        </LoginModule>
    </Security>
    <DataStore class="org.apache.jackrabbit.core.data.FileDataStore">
        <param name="url" value="jdbc:h2:/PATH/TO/db;AUTO_SERVER=TRUE"/>
        <param name="schemaObjectPrefix" value="datastore_"/>
        <param name="user" value="sa"/>
        <param name="password" value="sa"/>
    </DataStore>
    <Workspaces rootPath="${rep.home}/workspaces"
        defaultWorkspace="default" />
    <Workspace name="default">
        <FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
            <param name="path" value="${wsp.home}/default" />
        </FileSystem>
        <PersistenceManager class="org.apache.jackrabbit.core.persistence.pool.H2PersistenceManager">
            <param name="url" value="jdbc:h2:/PATH/TO/db;AUTO_SERVER=TRUE"/>
            <param name="schemaObjectPrefix" value="ws_${wsp.name}_"/>
            <param name="user" value="sa"/>
            <param name="password" value="sa"/>
        </PersistenceManager>
        <SearchIndex class="org.apache.jackrabbit.core.query.lucene.SearchIndex">
            <param name="path" value="${wsp.home}/index" />
            <param name="useCompoundFile" value="true" />
            <param name="minMergeDocs" value="100" />
            <param name="volatileIdleTime" value="3" />
            <param name="maxMergeDocs" value="100000" />
            <param name="mergeFactor" value="10" />
            <param name="maxFieldLength" value="10000" />
            <param name="bufferSize" value="10" />
            <param name="cacheSize" value="1000" />
            <param name="forceConsistencyCheck" value="false" />
            <param name="autoRepair" value="true" />
            <param name="queryClass" value="org.apache.jackrabbit.core.query.QueryImpl" />
            <param name="resultFetchSize" value="100" />
            <param name="extractorPoolSize" value="3" />
            <param name="extractorTimeout" value="100" />
            <param name="extractorBackLogSize" value="100" />
            <!-- needed to highlight the searched term -->
            <param name="supportHighlighting" value="true"/>
        </SearchIndex>
        <WorkspaceSecurity>
            <AccessControlProvider
                class="info.magnolia.cms.core.MagnoliaAccessProvider" />
        </WorkspaceSecurity>
    </Workspace>
    <Versioning rootPath="${rep.home}/version">
        <FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
            <param name="path" value="${rep.home}/workspaces/version" />
        </FileSystem>
        <PersistenceManager
                class="org.apache.jackrabbit.core.persistence.bundle.H2PersistenceManager">
            <param name="url" value="jdbc:h2:${rep.home}/version/db" />
            <param name="schemaObjectPrefix" value="version_" />
        </PersistenceManager>
    </Versioning>
    <Cluster>
        <Journal class="org.apache.jackrabbit.core.journal.DatabaseJournal">
            <param name="driver" value="org.h2.Driver" />
            <param name="url" value="jdbc:h2:/PATH/TO/db;AUTO_SERVER=TRUE"/>
            <param name="schemaObjectPrefix" value="journal_"/>
            <param name="databaseType" value="h2"/>
            <param name="user" value="sa"/>
            <param name="password" value="sa"/>
        </Journal>
    </Cluster>
</Repository>

log:

---------------------------------------------
MAGNOLIA LICENSE
---------------------------------------------
Version number : 5.3.5
Build          : 4. November 2014 (rev. of UNKNOWN)
Edition        : Enterprise Edition
Provider       : Magnolia International Ltd. ([email protected])
2016-07-27 11:17:59,919 INFO  info.magnolia.cms.beans.config.ConfigLoader       : Initializing content repositories
2016-07-27 11:17:59,922 INFO  info.magnolia.repository.DefaultRepositoryManager : Loading JCR
2016-07-27 11:17:59,931 INFO  info.magnolia.repository.DefaultRepositoryManager : Loading JCR magnolia
2016-07-27 11:17:59,951 INFO  info.magnolia.jackrabbit.ProviderImpl             : Loading repository at /PATH/author/repositories/magnolia (config file: /PATH/WEB-INF/config/repo-conf/jackrabbit-bundle-h2-search.xml) - cluster id: "<unset>"
Jul 27, 2016 11:18:00 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /PATH/webapps/manager
Jul 27, 2016 11:18:00 AM org.apache.catalina.startup.TldConfig execute
INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
Jul 27, 2016 11:18:00 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory /PATH/webapps/manager has finished in 417 ms
2016-07-27 11:18:02,174 INFO  info.magnolia.repository.DefaultRepositoryManager : Loading JCR magnoliacluster
2016-07-27 11:18:02,174 INFO  info.magnolia.jackrabbit.ProviderImpl             : Loading repository at /PATH/author/repositories/magnoliacluster (config file: /PATH/WEB-INF/config/repo-conf/clustered-jackrabbit-bundle-h2-search.xml) - cluster id: "<unset>"

Ps.: I'm not sure why it says 'cluster id: ""'. Although I have it set as org.apache.jackrabbit.core.cluster.node_id in my properties file.

Upvotes: 2

Views: 983

Answers (1)

Nicolas Barb&#233;
Nicolas Barb&#233;

Reputation: 624

From the following wiki page:

The cluster id identifies the instance and is used to write changes to the journal as well as to load changes from the journal. Make sure this is a unique value and is not shared with the other nodes in the cluster.

Cluster id can be defined either in the properties file (most convenient way) or in the persistence manager in the cluster configuration (both ways are used in the attached files)

Since you haven't provided any cluster id in your jackrabbit configuration file above, could you please check that your magnolia.properties file contains one? If not, just set an unique value for each Magnolia instances accessing the JCR cluster.

Upvotes: 1

Related Questions