[exo-jcr-commits] exo-jcr SVN: r1155 - in jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query: jbosscache and 1 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Wed Dec 23 08:42:23 EST 2009
Author: nzamosenchuk
Date: 2009-12-23 08:42:22 -0500 (Wed, 23 Dec 2009)
New Revision: 1155
Modified:
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/AbstractQueryHandler.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/DefaultChangesFilter.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JbossCacheIndexChangesFilter.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JbossCacheIndexInfos.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/IndexInfos.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java
Log:
EXOJCR-327: ADefault index infos, shouldn't have ioMode or system flag: fixed. If no IndexInfos defined for QueryHandler, indexInfos (default impl) is used.
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/AbstractQueryHandler.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/AbstractQueryHandler.java 2009-12-23 13:17:28 UTC (rev 1154)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/AbstractQueryHandler.java 2009-12-23 13:42:22 UTC (rev 1155)
@@ -225,7 +225,7 @@
*/
public IndexInfos getIndexInfos()
{
- return indexInfos;
+ return indexInfos == null ? new IndexInfos() : indexInfos;
}
}
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/DefaultChangesFilter.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/DefaultChangesFilter.java 2009-12-23 13:17:28 UTC (rev 1154)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/DefaultChangesFilter.java 2009-12-23 13:42:22 UTC (rev 1155)
@@ -20,7 +20,6 @@
import org.exoplatform.services.jcr.config.QueryHandlerEntry;
import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
-import org.exoplatform.services.jcr.impl.core.query.lucene.IndexInfos;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
@@ -59,12 +58,10 @@
if (!parentHandler.isInitialized())
{
- parentHandler.setIndexInfos(new IndexInfos(true, IndexerIoMode.READ_WRITE));
parentHandler.init();
}
if (!handler.isInitialized())
{
- handler.setIndexInfos(new IndexInfos(false, IndexerIoMode.READ_WRITE));
handler.init();
}
}
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JbossCacheIndexChangesFilter.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JbossCacheIndexChangesFilter.java 2009-12-23 13:17:28 UTC (rev 1154)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JbossCacheIndexChangesFilter.java 2009-12-23 13:42:22 UTC (rev 1155)
@@ -118,12 +118,14 @@
if (!parentHandler.isInitialized())
{
- parentHandler.setIndexInfos(new JbossCacheIndexInfos(cache, true, ioMode));
+ // TODO: uncomment it, when JbossCacheIndexInfos is finished.
+ // parentHandler.setIndexInfos(new JbossCacheIndexInfos(cache, true, ioMode));
parentHandler.init();
}
if (!handler.isInitialized())
{
- handler.setIndexInfos(new JbossCacheIndexInfos(cache, false, ioMode));
+ // TODO: uncomment it, when JbossCacheIndexInfos is finished.
+ // handler.setIndexInfos(new JbossCacheIndexInfos(cache, false, ioMode));
handler.init();
}
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JbossCacheIndexInfos.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JbossCacheIndexInfos.java 2009-12-23 13:17:28 UTC (rev 1154)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JbossCacheIndexInfos.java 2009-12-23 13:42:22 UTC (rev 1155)
@@ -43,15 +43,25 @@
private final Log log = ExoLogger.getLogger(this.getClass().getName());
- public static final String INDEX_NAMES = "$names".intern();
+ private static final String INDEX_NAMES = "$names".intern();
- public static final String SYSINDEX_NAMES = "$sysNames".intern();
+ private static final String SYSINDEX_NAMES = "$sysNames".intern();
- public static final String LIST = "$list".intern();
+ private static final String LIST = "$list".intern();
private final Cache<Serializable, Object> cache;
/**
+ * Flag notifies if this IndexInfos is from system search manager or not.
+ */
+ private boolean system;
+
+ /**
+ * {@link IndexerIoMode} is used to define current mode.
+ */
+ private IndexerIoMode ioMode = IndexerIoMode.READ_WRITE;
+
+ /**
* This FQN points to cache node, where list of indexes for this {@link IndexInfos} instance is stored.
*/
private final Fqn namesFqn;
@@ -70,24 +80,21 @@
*/
public JbossCacheIndexInfos(String fileName, Cache<Serializable, Object> cache, boolean system, IndexerIoMode ioMode)
{
- super(fileName, system, ioMode);
+ super(fileName);
this.cache = cache;
namesFqn = Fqn.fromString(system ? SYSINDEX_NAMES : INDEX_NAMES);
- }
-
- @Override
- public void write() throws IOException
- {
- boolean dirty = isDirty();
- // write to FS
- super.write();
- // write to cache
- if (dirty)
+ if (ioMode == IndexerIoMode.READ_ONLY)
{
- // send to cache new list.
+ // Currently READ_ONLY is set, so new lists should be fired to multiIndex.
+ cache.addCacheListener(this);
}
}
+ /**
+ * CacheListener method, that accepts event, when cache node changed. This class is registered as cache listener,
+ * only in READ_ONLY mode.
+ * @param event
+ */
@NodeModified
public void cacheNodeModified(NodeModifiedEvent event)
{
@@ -107,10 +114,27 @@
}
}
+ /**
+ * @see org.exoplatform.services.jcr.impl.core.query.lucene.IndexInfos#getIoMode()
+ */
+ public IndexerIoMode getIoMode()
+ {
+ return ioMode;
+ }
+
+ /**
+ * Returns true if this {@link IndexInfos} corresponds to SystemSearchManager
+ * @return
+ */
+ public boolean isSystem()
+ {
+ return system;
+ }
+
@Override
public void setIoMode(IndexerIoMode ioMode) throws IOException
{
- if (getIoMode() != ioMode)
+ if (this.ioMode != ioMode)
{
super.setIoMode(ioMode);
if (ioMode == IndexerIoMode.READ_WRITE)
@@ -118,6 +142,8 @@
// Now is read-write. Index list is actual and shouldn't be refreshed.
// Remove listener to avoid asserting if ioMode is RO on each cache event
cache.removeCacheListener(this);
+ // re-read from FS current actual list.
+ refresh();
}
else
{
@@ -127,4 +153,20 @@
}
}
+ /**
+ * @see org.exoplatform.services.jcr.impl.core.query.lucene.IndexInfos#write()
+ */
+ @Override
+ public void write() throws IOException
+ {
+ boolean dirty = isDirty();
+ // write to FS
+ super.write();
+ // write to cache
+ if (dirty)
+ {
+ // send to cache new list.
+ }
+ }
+
}
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/IndexInfos.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/IndexInfos.java 2009-12-23 13:17:28 UTC (rev 1154)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/IndexInfos.java 2009-12-23 13:42:22 UTC (rev 1155)
@@ -78,18 +78,11 @@
private MultiIndex multiIndex;
/**
- * {@link IndexerIoMode} is used to define current mode.
- */
- private IndexerIoMode ioMode;
-
- private final boolean system;
-
- /**
* Creates a new IndexInfos using <code>"indexes"</code> as a filename.
*/
- public IndexInfos(boolean system, IndexerIoMode ioMode)
+ public IndexInfos()
{
- this(DEFALUT_NAME, system, ioMode);
+ this(DEFALUT_NAME);
}
/**
@@ -97,11 +90,9 @@
*
* @param fileName the name of the file where infos are stored.
*/
- public IndexInfos(String fileName, boolean system, IndexerIoMode ioMode)
+ public IndexInfos(String fileName)
{
this.name = fileName;
- this.system = system;
- this.ioMode = ioMode;
}
/**
@@ -135,6 +126,7 @@
*/
public void read() throws IOException
{
+ // clear current lists
InputStream in = new IndexInputStream(dir.openInput(name));
try
{
@@ -154,6 +146,20 @@
}
/**
+ * re-reads list of indexes from FS
+ * @throws IOException
+ */
+ public void refresh() throws IOException
+ {
+ names.clear();
+ indexes.clear();
+ if (exists())
+ {
+ read();
+ }
+ }
+
+ /**
* Writes the index infos to disk if they are dirty.
*
* @param dir the directory where to write the index infos.
@@ -295,19 +301,7 @@
*/
public void setIoMode(IndexerIoMode ioMode) throws IOException
{
- if (this.ioMode != ioMode)
- {
- this.ioMode = ioMode;
- if (ioMode == IndexerIoMode.READ_WRITE)
- {
- names.clear();
- indexes.clear();
- if (exists())
- {
- read();
- }
- }
- }
+ // do nothing
}
/**
@@ -316,7 +310,7 @@
*/
public IndexerIoMode getIoMode()
{
- return ioMode;
+ return IndexerIoMode.READ_WRITE;
}
/**
@@ -352,15 +346,6 @@
}
/**
- * Returns true if this {@link IndexInfos} corresponds to SystemSearchManager
- * @return
- */
- public boolean isSystem()
- {
- return system;
- }
-
- /**
* Returns true, if changes weren't saved to FS.
* @return
*/
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java 2009-12-23 13:17:28 UTC (rev 1154)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java 2009-12-23 13:42:22 UTC (rev 1155)
@@ -2434,7 +2434,7 @@
// release reader if any
releaseMultiReader();
// get new indexInfo
- IndexInfos newIndexNames = new IndexInfos(indexNames.isSystem(), ioMode);
+ IndexInfos newIndexNames = new IndexInfos();
newIndexNames.setMultiIndex(this);
newIndexNames.setDirectory(indexDir);
if (newIndexNames.exists())
More information about the exo-jcr-commits
mailing list