Author: nzamosenchuk
Date: 2012-02-10 08:04:52 -0500 (Fri, 10 Feb 2012)
New Revision: 5602
Modified:
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JBossCacheIndexChangesFilter.java
Log:
EXOJCR-1747 : merging RSYNC brainch into 1.15.x
Modified:
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JBossCacheIndexChangesFilter.java
===================================================================
---
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JBossCacheIndexChangesFilter.java 2012-02-10
13:00:38 UTC (rev 5601)
+++
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JBossCacheIndexChangesFilter.java 2012-02-10
13:04:52 UTC (rev 5602)
@@ -29,6 +29,8 @@
import org.exoplatform.services.jcr.impl.core.query.IndexingTree;
import org.exoplatform.services.jcr.impl.core.query.QueryHandler;
import org.exoplatform.services.jcr.impl.core.query.SearchManager;
+import org.exoplatform.services.jcr.impl.core.query.lucene.IndexInfos;
+import org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex;
import org.exoplatform.services.jcr.jbosscache.ExoJBossCacheFactory;
import org.exoplatform.services.jcr.jbosscache.ExoJBossCacheFactory.CacheType;
import org.exoplatform.services.jcr.jbosscache.PrivilegedJBossCacheHelper;
@@ -75,10 +77,25 @@
public static final Boolean PARAM_JBOSSCACHE_SHAREABLE_DEFAULT = Boolean.FALSE;
+ // RSYNC SERVER CONFIGURATION
+ public static final String PARAM_RSYNC_ENTRY_NAME = "rsync-entry-name";
+
+ public static final String PARAM_RSYNC_ENTRY_PATH = "rsync-entry-path";
+
+ public static final String PARAM_RSYNC_PORT = "rsync-port";
+
+ public static final int PARAM_RSYNC_PORT_DEFAULT = 873;
+
+ // TODO
+ public static final String PARAM_RSYNC_USER = "rsync-user";
+
+ public static final String PARAM_RSYNC_PASSWORD = "rsync-password";
+
+ // Fields
private final Cache<Serializable, Object> cache;
private final Fqn<String> rootFqn;
-
+
private final JmxRegistrationManager jmxManager;
public static final String LISTWRAPPER = "$lists".intern();
@@ -173,18 +190,50 @@
if (!parentHandler.isInitialized())
{
- parentHandler.setIndexInfos(new JBossCacheIndexInfos(rootFqn, cache, true,
modeHandler));
+ parentHandler.setIndexInfos(createIndexInfos(true, modeHandler, config,
parentHandler));
parentHandler.setIndexUpdateMonitor(new JBossCacheIndexUpdateMonitor(rootFqn,
cache, true, modeHandler));
parentHandler.init();
}
if (!handler.isInitialized())
{
- handler.setIndexInfos(new JBossCacheIndexInfos(rootFqn, cache, false,
modeHandler));
+ handler.setIndexInfos(createIndexInfos(false, modeHandler, config, handler));
handler.setIndexUpdateMonitor(new JBossCacheIndexUpdateMonitor(rootFqn, cache,
false, modeHandler));
handler.init();
}
}
+ /**
+ * Factory method for creating corresponding IndexInfos class. RSyncIndexInfos created
if RSync configured
+ * and JBossCacheIndexInfos otherwise
+ *
+ * @param system
+ * @param modeHandler
+ * @param config
+ * @param handler
+ * @return
+ * @throws RepositoryConfigurationException
+ */
+ private IndexInfos createIndexInfos(Boolean system, IndexerIoModeHandler modeHandler,
QueryHandlerEntry config,
+ QueryHandler handler) throws RepositoryConfigurationException
+ {
+ // read RSYNC configuration
+ String rsyncEntryName = config.getParameterValue(PARAM_RSYNC_ENTRY_NAME, null);
+ String rsyncEntryPath = config.getParameterValue(PARAM_RSYNC_ENTRY_PATH, null);
+ int rsyncPort = config.getParameterInteger(PARAM_RSYNC_PORT,
PARAM_RSYNC_PORT_DEFAULT);
+
+ // rsync configured
+ if (rsyncEntryName != null)
+ {
+ return new RsyncIndexInfos(rootFqn, cache, system, modeHandler,
((SearchIndex)handler).getContext()
+ .getIndexDirectory(), rsyncPort, rsyncEntryName, rsyncEntryPath);
+ }
+ else
+ {
+ return new JBossCacheIndexInfos(rootFqn, cache, system, modeHandler);
+ }
+
+ }
+
protected Log getLogger()
{
return log;
@@ -204,9 +253,9 @@
return true;
}
- /**
- * {@inheritDoc}
- */
+ /**
+ * {@inheritDoc}
+ */
@Override
public void close()
{
@@ -224,8 +273,9 @@
});
}
}
- catch (Exception e) {
+ catch (Exception e)
+ {
log.warn("Not all JBoss Cache MBeans were unregistered.");
}
- }
+ }
}