JBoss Cache SVN: r7937 - searchable/trunk/src/main/java/org/jboss/cache/search.
by jbosscache-commits@lists.jboss.org
Author: seahawk(a)volny.cz
Date: 2009-03-23 12:40:35 -0400 (Mon, 23 Mar 2009)
New Revision: 7937
Modified:
searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCoreListener.java
Log:
@NodeRemoved changed to public to be callable.
Modified: searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCoreListener.java
===================================================================
--- searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCoreListener.java 2009-03-23 16:32:33 UTC (rev 7936)
+++ searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCoreListener.java 2009-03-23 16:40:35 UTC (rev 7937)
@@ -85,7 +85,7 @@
@NodeRemoved
- protected void handleNodeRemoved(NodeRemovedEvent event) throws InvalidKeyException
+ public void handleNodeRemoved(NodeRemovedEvent event) throws InvalidKeyException
{
log.debug("Entered the SCL. @NodeRemoved annotation found");
15 years, 9 months
RE: UK Pharmacy Discount ID 752
by 1965-2009 Pfizer Inc.
About this mailing:
You are receiving this e-mail because you subscribed to MSN Featured Offers. Microsoft respects your privacy. If you do not wish to receive this MSN Featured Offers e-mail, please click the "Unsubscribe" link below. This will not unsubscribe you from e-mail communications from third-party advertisers that may appear in MSN Feature Offers. This shall not constitute an offer by MSN. MSN shall not be responsible or liable for the advertisers' content nor any of the goods or service advertised. Prices and item availability subject to change without notice.
©2009 Microsoft | Unsubscribe at http://buplukeb.cn | More news at http://buplukeb.cn | Prvacy at http://buplukeb.cn
Microsoft Corporation, One Microsoft Way, Redmond, WA 98052
15 years, 9 months
JBoss Cache SVN: r7935 - in core/trunk/src/main/docbook: tutorial/en and 1 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2009-03-21 04:45:56 -0400 (Sat, 21 Mar 2009)
New Revision: 7935
Modified:
core/trunk/src/main/docbook/faq/en/master.xml
core/trunk/src/main/docbook/tutorial/en/master.xml
core/trunk/src/main/docbook/userguide/en/master.xml
Log:
Updated version, release date and copyright date
Modified: core/trunk/src/main/docbook/faq/en/master.xml
===================================================================
--- core/trunk/src/main/docbook/faq/en/master.xml 2009-03-20 16:00:05 UTC (rev 7934)
+++ core/trunk/src/main/docbook/faq/en/master.xml 2009-03-21 08:45:56 UTC (rev 7935)
@@ -6,8 +6,8 @@
<bookinfo>
<title>Frequently Asked Questions about JBoss Cache</title>
<!-- Release version and date -->
- <releaseinfo>Release 3.0.0 Naga</releaseinfo>
- <pubdate>October 2008</pubdate>
+ <releaseinfo>Release 3.1.0 Cascabel</releaseinfo>
+ <pubdate>April 2009</pubdate>
<author>
<firstname>Manik</firstname>
@@ -59,6 +59,7 @@
<year>2006</year>
<year>2007</year>
<year>2008</year>
+ <year>2009</year>
<holder>JBoss, a division of Red Hat Inc., and all authors as named.</holder>
</copyright>
</bookinfo>
Modified: core/trunk/src/main/docbook/tutorial/en/master.xml
===================================================================
--- core/trunk/src/main/docbook/tutorial/en/master.xml 2009-03-20 16:00:05 UTC (rev 7934)
+++ core/trunk/src/main/docbook/tutorial/en/master.xml 2009-03-21 08:45:56 UTC (rev 7935)
@@ -3,8 +3,8 @@
<articleinfo>
<title>JBoss Cache Core Edition Tutorial</title>
<!-- Release version and date -->
- <releaseinfo>Release 3.0.0 Naga</releaseinfo>
- <pubdate>October 2008</pubdate>
+ <releaseinfo>Release 3.1.0 Cascabel</releaseinfo>
+ <pubdate>April 2009</pubdate>
<author>
<firstname>Manik</firstname>
@@ -24,6 +24,7 @@
<year>2006</year>
<year>2007</year>
<year>2008</year>
+ <year>2009</year>
<holder>JBoss, a division of Red Hat Inc., and all authors as named.</holder>
</copyright>
Modified: core/trunk/src/main/docbook/userguide/en/master.xml
===================================================================
--- core/trunk/src/main/docbook/userguide/en/master.xml 2009-03-20 16:00:05 UTC (rev 7934)
+++ core/trunk/src/main/docbook/userguide/en/master.xml 2009-03-21 08:45:56 UTC (rev 7935)
@@ -22,8 +22,8 @@
<subtitle>A clustered, transactional cache</subtitle>
<!-- Release version and date -->
- <releaseinfo>Release 3.0.0 Naga</releaseinfo>
- <pubdate>October 2008</pubdate>
+ <releaseinfo>Release 3.1.0 Cascabel</releaseinfo>
+ <pubdate>April 2009</pubdate>
<!-- Authors/contributors -->
<author>
@@ -57,6 +57,7 @@
<year>2006</year>
<year>2007</year>
<year>2008</year>
+ <year>2009</year>
<holder>JBoss, a division of Red Hat Inc., and all authors as named.</holder>
</copyright>
15 years, 9 months
Build failed in Hudson: jboss-cache-searchable-trunk-jdk1.5 » JBoss Cache - Searchable Edition #22
by jboss-qa-internal@redhat.com
See http://hudson.qa.jboss.com/hudson/job/jboss-cache-searchable-trunk-jdk1.5...
Changes:
[manik.surtani(a)jboss.com] Fixed release script again
[manik.surtani(a)jboss.com] Fixed script
[Navin Surtani] Commented out pojo classes ...
[manik.surtani(a)jboss.com]
[manik.surtani(a)jboss.com]
------------------------------------------
started
Building remotely on soavmg8-linux
$ /qa/tools/opt/jdk1.5.0_15/bin/java -Xmx512m -cp /home/hudson/hudson_workspace/maven-agent.jar:/qa/tools/opt/maven-2.0.9/boot/classworlds-1.1.jar hudson.maven.agent.Main /qa/tools/opt/maven-2.0.9 /qa/services/hudson/hudson_release/WEB-INF/slave.jar /home/hudson/hudson_workspace/maven-interceptor.jar 38097
channel started
Executing Maven: -B -N -B -f http://hudson.qa.jboss.com/hudson/job/jboss-cache-searchable-trunk-jdk1.5... -cpu -U clean site -P codeCoverage
[INFO] Scanning for projects...
WAGON_VERSION: 1.0-beta-2
[INFO] ------------------------------------------------------------------------
[INFO] Building JBoss Cache - Searchable Edition
[INFO] task-segment: [clean, site]
[INFO] ------------------------------------------------------------------------
[INFO] snapshot org.codehaus.mojo:emma-maven-plugin:1.0-SNAPSHOT: checking for updates from snapshots.jboss.org
[INFO] snapshot org.codehaus.mojo:emma-maven-plugin:1.0-SNAPSHOT: checking for updates from Main Maven Repo
[INFO] snapshot org.codehaus.mojo:emma-maven-plugin:1.0-SNAPSHOT: checking for updates from snapshots.repository.codehaus.org
[INFO] snapshot org.codehaus.mojo:emma-maven-plugin:1.0-SNAPSHOT: checking for updates from snapshots.jboss.org
[INFO] snapshot org.codehaus.mojo:emma-maven-plugin:1.0-SNAPSHOT: checking for updates from e-xml.sourceforge.net
[INFO] artifact org.apache.maven.plugins:maven-eclipse-plugin: checking for updates from repository.jboss.org
[INFO] artifact org.apache.maven.plugins:maven-eclipse-plugin: checking for updates from Main Maven Repo
[INFO] artifact org.apache.maven.plugins:maven-eclipse-plugin: checking for updates from snapshots.repository.codehaus.org
[INFO] artifact org.apache.maven.plugins:maven-eclipse-plugin: checking for updates from central
[HUDSON] Archiving /home/hudson/hudson_workspace/workspace/jboss-cache-searchable-trunk-jdk1.5/./pom.xml to /home/hudson/hudson_workspace/jobs/jboss-cache-searchable-trunk-jdk1.5/modules/org.jboss.cache$jbosscache-searchable/builds/2009-01-05_00-01-59/archive/org.jboss.cache/jbosscache-searchable/1.0.0-SNAPSHOT/pom.xml
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] The plugin 'org.apache.maven.plugins:maven-eclipse-plugin' does not exist or no valid version could be found
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8 seconds
[INFO] Finished at: Mon Jan 05 00:02:16 EST 2009
[INFO] Final Memory: 8M/15M
[INFO] ------------------------------------------------------------------------
Waiting for Hudson to finish collecting data
15 years, 9 months
JBoss Cache SVN: r7934 - in core/trunk/src/main: resources/config-samples and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2009-03-20 12:00:05 -0400 (Fri, 20 Mar 2009)
New Revision: 7934
Modified:
core/trunk/src/main/docbook/userguide/en/modules/configuration_reference.xml
core/trunk/src/main/docbook/userguide/en/modules/replication.xml
core/trunk/src/main/resources/config-samples/all.xml
Log:
NBST docs and sample cfgs
Modified: core/trunk/src/main/docbook/userguide/en/modules/configuration_reference.xml
===================================================================
--- core/trunk/src/main/docbook/userguide/en/modules/configuration_reference.xml 2009-03-20 15:15:43 UTC (rev 7933)
+++ core/trunk/src/main/docbook/userguide/en/modules/configuration_reference.xml 2009-03-20 16:00:05 UTC (rev 7934)
@@ -2938,6 +2938,17 @@
before throwing an exception and aborting startup.
</entry>
</row>
+ <row>
+ <entry><emphasis role="bold">nonBlocking</emphasis></entry>
+ <entry>useNonBlockingStateTransfer</entry>
+ <entry>true, false</entry>
+ <entry>false</entry>
+ <entry>
+ This configuration switch enables the Non-Blocking State Transfer mechanism, new in 3.1.0. Note that
+ this requires MVCC as a node locking scheme, and that STREAMING_STATE_TRANSFER is present in the
+ JGroups stack used.
+ </entry>
+ </row>
</tbody>
</tgroup>
</table>
Modified: core/trunk/src/main/docbook/userguide/en/modules/replication.xml
===================================================================
--- core/trunk/src/main/docbook/userguide/en/modules/replication.xml 2009-03-20 15:15:43 UTC (rev 7933)
+++ core/trunk/src/main/docbook/userguide/en/modules/replication.xml 2009-03-20 16:00:05 UTC (rev 7934)
@@ -665,7 +665,23 @@
</listitem>
</orderedlist>
</section>
+
<section>
+ <title>Non-Blocking State Transfer</title>
+ <para>
+ New in JBoss Cache 3.1.0, Non-Blocking State Transfer (NBST) allows senders to generate and stream state while
+ not stopping handling their "work as usual" transactions. This is particularly important if there is a large
+ volume of state, where generation and streaming of the state can take some time and can cause ongoing
+ transactions on the sender to time out and fail.
+ </para>
+ <para>
+ To achieve this, NBST should be enabled (see
+ configuration reference), and you need to be using MVCC as a node locking scheme. In addition, you need to
+ use JGroups' STREAMING_STATE_TRANSFER protocol in your cluster properties.
+ </para>
+ </section>
+
+ <section>
<title>Configuring State Transfer</title>
<para>
To ensure state transfer behaves as expected, it is important that all nodes in the cluster are configured
Modified: core/trunk/src/main/resources/config-samples/all.xml
===================================================================
--- core/trunk/src/main/resources/config-samples/all.xml 2009-03-20 15:15:43 UTC (rev 7933)
+++ core/trunk/src/main/resources/config-samples/all.xml 2009-03-20 16:00:05 UTC (rev 7934)
@@ -75,7 +75,7 @@
<!--
Defines whether to retrieve state on startup
-->
- <stateRetrieval timeout="20000" fetchInMemoryState="false"/>
+ <stateRetrieval timeout="20000" fetchInMemoryState="false" nonBlocking="false"/>
<!--
Network calls are synchronous.
15 years, 9 months
JBoss Cache SVN: r7933 - in core/tags/3.1.0.BETA1: src/main/java/org/jboss/cache and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2009-03-20 11:15:43 -0400 (Fri, 20 Mar 2009)
New Revision: 7933
Modified:
core/tags/3.1.0.BETA1/pom.xml
core/tags/3.1.0.BETA1/src/main/java/org/jboss/cache/Version.java
Log:
JBoss Cache Release Script: Updating 3.1.0.BETA1
Modified: core/tags/3.1.0.BETA1/pom.xml
===================================================================
--- core/tags/3.1.0.BETA1/pom.xml 2009-03-20 15:14:46 UTC (rev 7932)
+++ core/tags/3.1.0.BETA1/pom.xml 2009-03-20 15:15:43 UTC (rev 7933)
@@ -4,7 +4,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<properties>
- <jbosscache-core-version>3.1.0-SNAPSHOT</jbosscache-core-version>
+ <jbosscache-core-version>3.1.0.BETA1</jbosscache-core-version>
<!-- By default only run tests in the "unit" group -->
<defaultTestGroup>unit</defaultTestGroup>
<!-- By default only generate Javadocs when we install the module. -->
@@ -472,7 +472,7 @@
<activeByDefault>false</activeByDefault>
</activation>
<properties>
- <jbosscache-core-version>3.0.3-SNAPSHOT-JBossAS</jbosscache-core-version>
+ <jbosscache-core-version>3.1.0.BETA1-JBossAS</jbosscache-core-version>
<defaultTestGroup>functional,unit</defaultTestGroup>
<protocol.stack>tcp</protocol.stack>
</properties>
Modified: core/tags/3.1.0.BETA1/src/main/java/org/jboss/cache/Version.java
===================================================================
--- core/tags/3.1.0.BETA1/src/main/java/org/jboss/cache/Version.java 2009-03-20 15:14:46 UTC (rev 7932)
+++ core/tags/3.1.0.BETA1/src/main/java/org/jboss/cache/Version.java 2009-03-20 15:15:43 UTC (rev 7933)
@@ -32,10 +32,10 @@
@Immutable
public class Version
{
- public static final String version = "3.1.0-SNAPSHOT";
+ public static final String version = "3.1.0.BETA1";
public static final String codename = "Cascabel";
//public static final String cvs = "$Id$";
- static final byte[] version_id = {'0', '3', '1', '0', 'S'};
+ static final byte[] version_id = {'0','3','1','0','B','E','T','A','1'};
private static final int MAJOR_SHIFT = 11;
private static final int MINOR_SHIFT = 6;
15 years, 9 months
JBoss Cache SVN: r7932 - core/tags.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2009-03-20 11:14:46 -0400 (Fri, 20 Mar 2009)
New Revision: 7932
Added:
core/tags/3.1.0.BETA1/
Log:
JBoss Cache Release Script: Tagging 3.1.0.BETA1
Copied: core/tags/3.1.0.BETA1 (from rev 7931, core/trunk)
15 years, 9 months
JBoss Cache SVN: r7931 - in searchable/trunk: src/main/java/org/jboss/cache/search and 2 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2009-03-20 10:02:50 -0400 (Fri, 20 Mar 2009)
New Revision: 7931
Added:
searchable/trunk/src/main/java/org/jboss/cache/search/TransactionalEventTransactionContext.java
Removed:
searchable/trunk/src/main/java/org/jboss/cache/search/NodeModifiedTransactionContext.java
searchable/trunk/src/main/java/org/jboss/cache/search/NodeRemovedTransactionContext.java
Modified:
searchable/trunk/pom.xml
searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheFactory.java
searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCoreListener.java
searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCoreRemover.java
searchable/trunk/src/test/java/org/jboss/cache/search/NodeModifiedTransactionContextTest.java
searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/IndexingInTransaction.java
searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/NodeRemovedTest.java
Log:
Added more tests
Modified: searchable/trunk/pom.xml
===================================================================
--- searchable/trunk/pom.xml 2009-03-20 00:38:33 UTC (rev 7930)
+++ searchable/trunk/pom.xml 2009-03-20 14:02:50 UTC (rev 7931)
@@ -63,16 +63,6 @@
<version>1.2.0</version>
<scope>test</scope>
</dependency>
-
- <!-- Optional deps -->
- <dependency>
- <groupId>jdbm</groupId>
- <artifactId>jdbm</artifactId>
- <version>1.0</version>
- <optional>true</optional>
- </dependency>
-
-
</dependencies>
<build>
<plugins>
Deleted: searchable/trunk/src/main/java/org/jboss/cache/search/NodeModifiedTransactionContext.java
===================================================================
--- searchable/trunk/src/main/java/org/jboss/cache/search/NodeModifiedTransactionContext.java 2009-03-20 00:38:33 UTC (rev 7930)
+++ searchable/trunk/src/main/java/org/jboss/cache/search/NodeModifiedTransactionContext.java 2009-03-20 14:02:50 UTC (rev 7931)
@@ -1,103 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright ${year}, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.cache.search;
-
-import org.hibernate.search.backend.TransactionContext;
-import org.jboss.cache.notifications.event.NodeModifiedEvent;
-
-import javax.transaction.Synchronization;
-import javax.transaction.Transaction;
-
-/**
- * This class implements the {@link org.hibernate.search.backend.TransactionContext} interface. It
- * retrieves transaction context information from the {@link org.jboss.cache.notifications.event.NodeModifiedEvent} that gets passed in.
- * <p />
- * It is used by the {@link SearchableCoreListener} to pass transaction information to a Hibernate Search {@link org.hibernate.search.backend.Work} object.
- * <p />
- * @author Navin Surtani (<a href="mailto:nsurtani@redhat.com">nsurtani(a)redhat.com</a>)
- * @see SearchableCoreListener
- */
-public class NodeModifiedTransactionContext implements TransactionContext
-{
-
- NodeModifiedEvent event;
-
- /**
- * Creates a new instance of NodeModifiedTransactionContext.
- * <p />
- * @param event a NodeModifiedEvent to wrap. Should not be null.
- * @throws NullPointerException if event is null.
- */
- public NodeModifiedTransactionContext(NodeModifiedEvent event)
- {
- if (event == null) throw new NullPointerException("event cannot be null");
- this.event = event;
- }
-
- /**
- * Returns a boolean value whether or not a transaction is in progress (JTA transaction and in this case *not*
- * an org.hibernate transaction).
- * @return true if a transaction is in progress, false otherwise.
- */
- public boolean isTransactionInProgress()
- {
- return (event.getTransaction() != null);
- }
-
- /**
- * Returns a JTA transaction.
- * @return a JTA transaction if one is available, or a null otherwise.
- * @see org.jboss.cache.notifications.event.NodeModifiedEvent#getTransaction()
- */
-
- public Object getTransactionIdentifier()
- {
- return event.getTransaction();
- }
-
- /**
- * Registers the synchronization passed in as a parameter with the ongoing transaction.
- * <p />
- * If there is no ongoing transaction, then this method will do nothing and simply return.
- * <p />
- * @param synchronization synchronization to register. Must not be null.
- * @throws NullPointerException if the synchronization is null.
- */
- public void registerSynchronization(Synchronization synchronization)
- {
- if (synchronization == null) throw new NullPointerException("Synchronization passed in is null!");
-
- Transaction transaction = event.getTransaction();
- if (transaction != null)
- {
- try
- {
- transaction.registerSynchronization(synchronization);
- }
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
- }
- }
-}
Deleted: searchable/trunk/src/main/java/org/jboss/cache/search/NodeRemovedTransactionContext.java
===================================================================
--- searchable/trunk/src/main/java/org/jboss/cache/search/NodeRemovedTransactionContext.java 2009-03-20 00:38:33 UTC (rev 7930)
+++ searchable/trunk/src/main/java/org/jboss/cache/search/NodeRemovedTransactionContext.java 2009-03-20 14:02:50 UTC (rev 7931)
@@ -1,52 +0,0 @@
-package org.jboss.cache.search;
-
-import org.hibernate.search.backend.TransactionContext;
-import org.jboss.cache.notifications.event.NodeRemovedEvent;
-
-import javax.transaction.Synchronization;
-import javax.transaction.Transaction;
-
-/**
- * @author Navin Surtani (<a href="mailto:nsurtani@redhat.com">nsurtani(a)redhat.com</a>)
- */
-public class NodeRemovedTransactionContext implements TransactionContext
-{
-
- NodeRemovedEvent event;
-
- public NodeRemovedTransactionContext(NodeRemovedEvent event)
- {
- if (event == null) throw new NullPointerException("event cannot be null");
- this.event = event;
- }
-
- public boolean isTransactionInProgress()
- {
- return (event.getTransaction() != null);
- }
-
- public Object getTransactionIdentifier()
- {
- return event.getTransaction();
- }
-
- public void registerSynchronization(Synchronization synchronization)
- {
- if (synchronization == null) throw new NullPointerException("Synchronization passed in is null!");
-
- Transaction transaction = event.getTransaction();
- if (transaction != null)
- {
- try
- {
- transaction.registerSynchronization(synchronization);
- }
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
-
-
- }
- }
-}
Modified: searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheFactory.java
===================================================================
--- searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheFactory.java 2009-03-20 00:38:33 UTC (rev 7930)
+++ searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheFactory.java 2009-03-20 14:02:50 UTC (rev 7931)
@@ -101,8 +101,8 @@
c.addCacheListener(coreListener);
//Create secondary listener
- SearchableCoreRemover remover = new SearchableCoreRemover(searchFactory);
- c.addCacheListener(remover);
+// SearchableCoreRemover remover = new SearchableCoreRemover(searchFactory);
+// c.addCacheListener(remover);
//Create the searchableCache and pass it on.
SearchableCache sc = new SearchableCacheImpl(c, searchFactory);
Modified: searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCoreListener.java
===================================================================
--- searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCoreListener.java 2009-03-20 00:38:33 UTC (rev 7930)
+++ searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCoreListener.java 2009-03-20 14:02:50 UTC (rev 7931)
@@ -22,6 +22,8 @@
package org.jboss.cache.search;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.hibernate.search.backend.TransactionContext;
import org.hibernate.search.backend.Work;
import org.hibernate.search.backend.WorkType;
@@ -29,12 +31,12 @@
import org.jboss.cache.notifications.annotation.CacheListener;
import org.jboss.cache.notifications.annotation.NodeModified;
import org.jboss.cache.notifications.annotation.NodeRemoved;
+import org.jboss.cache.notifications.annotation.TransactionRegistered;
import org.jboss.cache.notifications.event.NodeModifiedEvent;
import org.jboss.cache.notifications.event.NodeRemovedEvent;
-import org.jboss.cache.notifications.event.NodeEvent;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.jboss.cache.notifications.event.TransactionRegisteredEvent;
+import javax.transaction.Transaction;
import java.util.Map;
/**
@@ -93,7 +95,7 @@
Map dataMap = event.getData();
if (log.isTraceEnabled()) log.trace("Called event.getData() and saved to a Map");
- TransactionContext ctx = new NodeRemovedTransactionContext(event);
+ TransactionContext ctx = new TransactionalEventTransactionContext(event);
for (Object key : dataMap.keySet())
{
@@ -115,6 +117,22 @@
}
/**
+ * Transaction commencement needs to be handled explicitly
+ */
+ @TransactionRegistered
+ public void handleTransactionBoundary(TransactionRegisteredEvent event)
+ {
+ Transaction transactionId = event.getTransaction();
+
+ // TODO find some way to notify Hibernate Search that a transaction has commenced.
+
+ // According to http://www.hibernate.org/hib_docs/search/reference/en/html/search-batchin...
+ // work is flushed automatically by HS when the transaction commits so there is nothing else to do there. We just need an
+ // internal equivalent of fullTextSession.beginTransaction() and force it to use the transactionId provided.
+ }
+
+
+ /**
* If the modification type is PUT_MAP or PUT_DATA then this method will be called.
* Takes in the event as a parameter
*
@@ -130,7 +148,7 @@
if (log.isTraceEnabled()) log.trace("Called event.getData() and saved to a Map");
- TransactionContext ctx = new NodeModifiedTransactionContext(event);
+ TransactionContext ctx = new TransactionalEventTransactionContext(event);
for (Object key : dataMap.keySet())
{
@@ -168,7 +186,7 @@
{
Map dataMap = event.getData();
- TransactionContext ctx = new NodeModifiedTransactionContext(event);
+ TransactionContext ctx = new TransactionalEventTransactionContext(event);
for (Object key : dataMap.keySet())
{
Modified: searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCoreRemover.java
===================================================================
--- searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCoreRemover.java 2009-03-20 00:38:33 UTC (rev 7930)
+++ searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCoreRemover.java 2009-03-20 14:02:50 UTC (rev 7931)
@@ -1,16 +1,14 @@
package org.jboss.cache.search;
-import org.jboss.cache.notifications.annotation.CacheListener;
-import org.jboss.cache.notifications.annotation.NodeModified;
-import org.jboss.cache.notifications.annotation.NodeRemoved;
-import org.jboss.cache.notifications.event.NodeEvent;
-import org.jboss.cache.notifications.event.NodeRemovedEvent;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.search.backend.TransactionContext;
import org.hibernate.search.backend.Work;
import org.hibernate.search.backend.WorkType;
import org.hibernate.search.engine.SearchFactoryImplementor;
+import org.jboss.cache.notifications.annotation.CacheListener;
+import org.jboss.cache.notifications.annotation.NodeRemoved;
+import org.jboss.cache.notifications.event.NodeRemovedEvent;
import java.util.Map;
@@ -41,7 +39,7 @@
Map dataMap = event.getData();
if (log.isTraceEnabled()) log.trace("Called event.getData() and saved to a Map");
- TransactionContext ctx = new NodeRemovedTransactionContext(event);
+ TransactionContext ctx = new TransactionalEventTransactionContext(event);
for (Object key : dataMap.keySet())
{
Copied: searchable/trunk/src/main/java/org/jboss/cache/search/TransactionalEventTransactionContext.java (from rev 7930, searchable/trunk/src/main/java/org/jboss/cache/search/NodeModifiedTransactionContext.java)
===================================================================
--- searchable/trunk/src/main/java/org/jboss/cache/search/TransactionalEventTransactionContext.java (rev 0)
+++ searchable/trunk/src/main/java/org/jboss/cache/search/TransactionalEventTransactionContext.java 2009-03-20 14:02:50 UTC (rev 7931)
@@ -0,0 +1,103 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.cache.search;
+
+import org.hibernate.search.backend.TransactionContext;
+import org.jboss.cache.notifications.event.TransactionalEvent;
+
+import javax.transaction.Synchronization;
+import javax.transaction.Transaction;
+
+/**
+ * This class implements the {@link org.hibernate.search.backend.TransactionContext} interface. It
+ * retrieves transaction context information from the {@link org.jboss.cache.notifications.event.NodeModifiedEvent} that gets passed in.
+ * <p />
+ * It is used by the {@link SearchableCoreListener} to pass transaction information to a Hibernate Search {@link org.hibernate.search.backend.Work} object.
+ * <p />
+ * @author Navin Surtani (<a href="mailto:nsurtani@redhat.com">nsurtani(a)redhat.com</a>)
+ * @see SearchableCoreListener
+ */
+public class TransactionalEventTransactionContext implements TransactionContext
+{
+
+ TransactionalEvent event;
+
+ /**
+ * Creates a new instance of NodeModifiedTransactionContext.
+ * <p />
+ * @param event a NodeModifiedEvent to wrap. Should not be null.
+ * @throws NullPointerException if event is null.
+ */
+ public TransactionalEventTransactionContext(TransactionalEvent event)
+ {
+ if (event == null) throw new NullPointerException("event cannot be null");
+ this.event = event;
+ }
+
+ /**
+ * Returns a boolean value whether or not a transaction is in progress (JTA transaction and in this case *not*
+ * an org.hibernate transaction).
+ * @return true if a transaction is in progress, false otherwise.
+ */
+ public boolean isTransactionInProgress()
+ {
+ return (event.getTransaction() != null);
+ }
+
+ /**
+ * Returns a JTA transaction.
+ * @return a JTA transaction if one is available, or a null otherwise.
+ * @see org.jboss.cache.notifications.event.NodeModifiedEvent#getTransaction()
+ */
+
+ public Object getTransactionIdentifier()
+ {
+ return event.getTransaction();
+ }
+
+ /**
+ * Registers the synchronization passed in as a parameter with the ongoing transaction.
+ * <p />
+ * If there is no ongoing transaction, then this method will do nothing and simply return.
+ * <p />
+ * @param synchronization synchronization to register. Must not be null.
+ * @throws NullPointerException if the synchronization is null.
+ */
+ public void registerSynchronization(Synchronization synchronization)
+ {
+ if (synchronization == null) throw new NullPointerException("Synchronization passed in is null!");
+
+ Transaction transaction = event.getTransaction();
+ if (transaction != null)
+ {
+ try
+ {
+ transaction.registerSynchronization(synchronization);
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+}
Modified: searchable/trunk/src/test/java/org/jboss/cache/search/NodeModifiedTransactionContextTest.java
===================================================================
--- searchable/trunk/src/test/java/org/jboss/cache/search/NodeModifiedTransactionContextTest.java 2009-03-20 00:38:33 UTC (rev 7930)
+++ searchable/trunk/src/test/java/org/jboss/cache/search/NodeModifiedTransactionContextTest.java 2009-03-20 14:02:50 UTC (rev 7931)
@@ -13,7 +13,7 @@
@Test (expectedExceptions = NullPointerException.class)
public void nullConstuctor()
{
- NodeModifiedTransactionContext nmtc = new NodeModifiedTransactionContext(null);
+ TransactionalEventTransactionContext nmtc = new TransactionalEventTransactionContext(null);
}
Modified: searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/IndexingInTransaction.java
===================================================================
--- searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/IndexingInTransaction.java 2009-03-20 00:38:33 UTC (rev 7930)
+++ searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/IndexingInTransaction.java 2009-03-20 14:02:50 UTC (rev 7931)
@@ -1,28 +1,33 @@
package org.jboss.cache.search.blackbox;
+import org.apache.lucene.index.Term;
+import org.apache.lucene.search.BooleanClause;
+import org.apache.lucene.search.BooleanQuery;
+import org.apache.lucene.search.Query;
+import org.apache.lucene.search.TermQuery;
import org.hibernate.search.annotations.Field;
+import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.ProvidedId;
-import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.Store;
-import org.jboss.cache.*;
-import org.jboss.cache.loader.jdbm.JdbmCacheLoaderConfig;
+import org.jboss.cache.Cache;
+import org.jboss.cache.CacheFactory;
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.DefaultCacheFactory;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.Node;
+import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.config.Configuration;
-import org.jboss.cache.config.CacheLoaderConfig;
+import org.jboss.cache.loader.FileCacheLoaderConfig;
+import org.jboss.cache.search.SearchableCache;
import org.jboss.cache.search.SearchableCacheFactory;
-import org.jboss.cache.search.SearchableCache;
+import static org.testng.AssertJUnit.assertFalse;
+import static org.testng.AssertJUnit.assertTrue;
+import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import org.testng.annotations.BeforeMethod;
-import org.apache.lucene.search.Query;
-import org.apache.lucene.search.BooleanQuery;
-import org.apache.lucene.search.TermQuery;
-import org.apache.lucene.search.BooleanClause;
-import org.apache.lucene.index.Term;
-import static org.testng.AssertJUnit.*;
-
+import java.io.Serializable;
+import java.util.List;
import java.util.Properties;
-import java.util.List;
-import java.io.Serializable;
@Test(groups = {"unit"}, sequential = true)
public class IndexingInTransaction
@@ -50,14 +55,14 @@
CacheLoaderConfig clc = new CacheLoaderConfig();
- JdbmCacheLoaderConfig jclc = new JdbmCacheLoaderConfig();
- jclc.setAsync(false);
- jclc.setFetchPersistentState(false);
- jclc.setIgnoreModifications(false);
- jclc.setPurgeOnStartup(true);
- jclc.setLocation("/tmp/c1");
+ FileCacheLoaderConfig fclc = new FileCacheLoaderConfig();
+ fclc.setAsync(false);
+ fclc.setFetchPersistentState(false);
+ fclc.setIgnoreModifications(false);
+ fclc.setPurgeOnStartup(true);
+ fclc.setLocation("/tmp/c1");
- clc.addIndividualCacheLoaderConfig(jclc);
+ clc.addIndividualCacheLoaderConfig(fclc);
c.setCacheLoaderConfig(clc);
coreCache = factory.createCache(c, false);
Modified: searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/NodeRemovedTest.java
===================================================================
--- searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/NodeRemovedTest.java 2009-03-20 00:38:33 UTC (rev 7930)
+++ searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/NodeRemovedTest.java 2009-03-20 14:02:50 UTC (rev 7931)
@@ -1,18 +1,21 @@
package org.jboss.cache.search.blackbox;
-import org.testng.annotations.Test;
-import org.testng.annotations.BeforeMethod;
-import org.jboss.cache.search.test.Person;
+import org.apache.lucene.analysis.standard.StandardAnalyzer;
+import org.apache.lucene.queryParser.ParseException;
+import org.apache.lucene.queryParser.QueryParser;
+import org.apache.lucene.search.Query;
+import org.jboss.cache.Cache;
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.DefaultCacheFactory;
+import org.jboss.cache.config.Configuration;
import org.jboss.cache.search.SearchableCache;
import org.jboss.cache.search.SearchableCacheFactory;
-import org.jboss.cache.search.SearchableCoreRemover;
-import org.jboss.cache.Cache;
-import org.jboss.cache.DefaultCacheFactory;
-import org.apache.lucene.queryParser.QueryParser;
-import org.apache.lucene.queryParser.ParseException;
-import org.apache.lucene.analysis.standard.StandardAnalyzer;
-import org.apache.lucene.search.Query;
+import org.jboss.cache.search.test.Person;
+import org.jboss.cache.transaction.DummyTransactionManagerLookup;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+import javax.transaction.TransactionManager;
import java.util.List;
/**
@@ -24,6 +27,7 @@
{
Person p1 = new Person();
SearchableCache searchableCache;
+ TransactionManager tm;
@BeforeMethod
public void setUp()
@@ -32,7 +36,10 @@
p1.setBlurb("Smelly");
p1.setAge(12);
- Cache cache = new DefaultCacheFactory().createCache(true);
+ Configuration cfg = new Configuration();
+ cfg.setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
+ Cache cache = new DefaultCacheFactory().createCache(cfg, true);
+ tm = ((CacheSPI) cache).getTransactionManager();
searchableCache = new SearchableCacheFactory().createSearchableCache(cache, Person.class);
}
@@ -56,4 +63,26 @@
assert found.size() == 0;
}
+ public void testRemoveNodeWithTx() throws Exception
+ {
+ tm.begin();
+ searchableCache.put("/a", "key", p1);
+ tm.commit();
+
+ QueryParser parser = new QueryParser("name", new StandardAnalyzer());
+ Query luceneQuery = parser.parse("cat");
+ List found = searchableCache.createQuery(luceneQuery, Person.class).list();
+
+ assert found.size() == 1;
+
+ tm.begin();
+ searchableCache.removeNode("/a");
+ tm.commit();
+
+ parser = new QueryParser("name", new StandardAnalyzer());
+ luceneQuery = parser.parse("cat");
+ found = searchableCache.createQuery(luceneQuery, Person.class).list();
+
+ assert found.size() == 0;
+ }
}
15 years, 9 months
Build failed in Hudson: jboss-cache-searchable-trunk-jdk1.6 » JBoss Cache - Searchable Edition #22
by jboss-qa-internal@redhat.com
See http://hudson.qa.jboss.com/hudson/job/jboss-cache-searchable-trunk-jdk1.6...
Changes:
[manik.surtani(a)jboss.com] Fixed release script again
[manik.surtani(a)jboss.com] Fixed script
[Navin Surtani] Commented out pojo classes ...
[manik.surtani(a)jboss.com]
[manik.surtani(a)jboss.com]
------------------------------------------
started
Building remotely on soavmg10-linux
$ java -Xmx512m -cp /home/hudson/hudson_workspace/maven-agent.jar:/qa/tools/opt/maven-2.0.9/boot/classworlds-1.1.jar hudson.maven.agent.Main /qa/tools/opt/maven-2.0.9 /qa/services/hudson/hudson_release/WEB-INF/slave.jar /home/hudson/hudson_workspace/maven-interceptor.jar 51659
channel started
Executing Maven: -B -N -B -f http://hudson.qa.jboss.com/hudson/job/jboss-cache-searchable-trunk-jdk1.6... -cpu -U clean site -P codeCoverage
[INFO] Scanning for projects...
WAGON_VERSION: 1.0-beta-2
[INFO] ------------------------------------------------------------------------
[INFO] Building JBoss Cache - Searchable Edition
[INFO] task-segment: [clean, site]
[INFO] ------------------------------------------------------------------------
[INFO] snapshot org.codehaus.mojo:emma-maven-plugin:1.0-SNAPSHOT: checking for updates from snapshots.jboss.org
[INFO] snapshot org.codehaus.mojo:emma-maven-plugin:1.0-SNAPSHOT: checking for updates from Main Maven Repo
[INFO] snapshot org.codehaus.mojo:emma-maven-plugin:1.0-SNAPSHOT: checking for updates from snapshots.repository.codehaus.org
[INFO] snapshot org.codehaus.mojo:emma-maven-plugin:1.0-SNAPSHOT: checking for updates from snapshots.jboss.org
[INFO] snapshot org.codehaus.mojo:emma-maven-plugin:1.0-SNAPSHOT: checking for updates from e-xml.sourceforge.net
[INFO] artifact org.apache.maven.plugins:maven-eclipse-plugin: checking for updates from repository.jboss.org
[INFO] artifact org.apache.maven.plugins:maven-eclipse-plugin: checking for updates from Main Maven Repo
[INFO] artifact org.apache.maven.plugins:maven-eclipse-plugin: checking for updates from snapshots.repository.codehaus.org
[INFO] artifact org.apache.maven.plugins:maven-eclipse-plugin: checking for updates from central
[HUDSON] Archiving /home/hudson/hudson_workspace/workspace/jboss-cache-searchable-trunk-jdk1.6/./pom.xml to /home/hudson/hudson_workspace/jobs/jboss-cache-searchable-trunk-jdk1.6/modules/org.jboss.cache$jbosscache-searchable/builds/2009-01-05_00-01-59/archive/org.jboss.cache/jbosscache-searchable/1.0.0-SNAPSHOT/pom.xml
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] The plugin 'org.apache.maven.plugins:maven-eclipse-plugin' does not exist or no valid version could be found
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8 seconds
[INFO] Finished at: Mon Jan 05 00:02:16 EST 2009
[INFO] Final Memory: 14M/33M
[INFO] ------------------------------------------------------------------------
Waiting for Hudson to finish collecting data
15 years, 9 months
JBoss Cache SVN: r7930 - in searchable/trunk/src: test/java/org/jboss/cache/search/blackbox and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: navssurtani
Date: 2009-03-19 20:38:33 -0400 (Thu, 19 Mar 2009)
New Revision: 7930
Added:
searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCoreRemover.java
searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/NodeRemovedTest.java
Modified:
searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheFactory.java
searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCoreListener.java
searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/IndexingInTransaction.java
Log:
More commit noise -
Modified: searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheFactory.java
===================================================================
--- searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheFactory.java 2009-03-19 18:08:54 UTC (rev 7929)
+++ searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheFactory.java 2009-03-20 00:38:33 UTC (rev 7930)
@@ -100,6 +100,10 @@
SearchableCoreListener coreListener = new SearchableCoreListener(searchFactory);
c.addCacheListener(coreListener);
+ //Create secondary listener
+ SearchableCoreRemover remover = new SearchableCoreRemover(searchFactory);
+ c.addCacheListener(remover);
+
//Create the searchableCache and pass it on.
SearchableCache sc = new SearchableCacheImpl(c, searchFactory);
return sc;
Modified: searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCoreListener.java
===================================================================
--- searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCoreListener.java 2009-03-19 18:08:54 UTC (rev 7929)
+++ searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCoreListener.java 2009-03-20 00:38:33 UTC (rev 7930)
@@ -31,6 +31,7 @@
import org.jboss.cache.notifications.annotation.NodeRemoved;
import org.jboss.cache.notifications.event.NodeModifiedEvent;
import org.jboss.cache.notifications.event.NodeRemovedEvent;
+import org.jboss.cache.notifications.event.NodeEvent;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -49,7 +50,6 @@
public SearchableCoreListener(SearchFactoryImplementor searchFactory)
{
-
this.searchFactory = searchFactory;
}
@@ -63,8 +63,7 @@
@NodeModified
public void updateLuceneIndexes(NodeModifiedEvent event) throws InvalidKeyException
{
-
- if (log.isTraceEnabled()) log.trace("You have entered the SearchableListener");
+ if (log.isDebugEnabled()) log.debug("You have entered the SearchableListener");
if (!event.isPre())
{
if (log.isTraceEnabled()) log.trace("event.isPre is false. Going to start updating indexes");
@@ -87,14 +86,13 @@
protected void handleNodeRemoved(NodeRemovedEvent event) throws InvalidKeyException
{
- if (log.isWarnEnabled()) log.debug("Entered the SCL. @NodeRemoved annotation found");
- if (!event.isPre())
+ log.debug("Entered the SCL. @NodeRemoved annotation found");
+ if (event.isPre())
{
// Directly going to handle the deletion of data.
Map dataMap = event.getData();
if (log.isTraceEnabled()) log.trace("Called event.getData() and saved to a Map");
-
TransactionContext ctx = new NodeRemovedTransactionContext(event);
for (Object key : dataMap.keySet())
@@ -107,15 +105,13 @@
searchFactory.getWorker().performWork(new Work(dataMap.get(key), cacheEntityId.getDocumentId(), WorkType.DELETE), ctx);
- searchFactory.getWorker().performWork(new Work(dataMap.get(key), cacheEntityId.getDocumentId(), WorkType.ADD), ctx);
-
if (log.isTraceEnabled())
{
log.debug("Added your object into Lucene with Fqn " + fqnString + " and key " + keyString);
}
}
- }
+ }
}
/**
Added: searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCoreRemover.java
===================================================================
--- searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCoreRemover.java (rev 0)
+++ searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCoreRemover.java 2009-03-20 00:38:33 UTC (rev 7930)
@@ -0,0 +1,64 @@
+package org.jboss.cache.search;
+
+import org.jboss.cache.notifications.annotation.CacheListener;
+import org.jboss.cache.notifications.annotation.NodeModified;
+import org.jboss.cache.notifications.annotation.NodeRemoved;
+import org.jboss.cache.notifications.event.NodeEvent;
+import org.jboss.cache.notifications.event.NodeRemovedEvent;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.hibernate.search.backend.TransactionContext;
+import org.hibernate.search.backend.Work;
+import org.hibernate.search.backend.WorkType;
+import org.hibernate.search.engine.SearchFactoryImplementor;
+
+import java.util.Map;
+
+/**
+ * @author Navin Surtani (<a href="mailto:nsurtani@redhat.com">nsurtani(a)redhat.com</a>)
+ */
+@CacheListener
+public class SearchableCoreRemover
+{
+ private SearchFactoryImplementor searchFactory;
+ private static final Log log = LogFactory.getLog(SearchableCoreListener.class);
+
+ public SearchableCoreRemover(SearchFactoryImplementor searchFactory)
+ {
+ this.searchFactory = searchFactory;
+ }
+
+
+ @NodeRemoved
+ public void logEvent(NodeRemovedEvent event) throws InvalidKeyException
+ {
+ log.debug("Entered - SearchableCoreRemover with @NodeRemoved");
+ if (event.isPre())
+ {
+ System.out.println("Event isPre()");
+
+ // Directly going to handle the deletion of data.
+ Map dataMap = event.getData();
+ if (log.isTraceEnabled()) log.trace("Called event.getData() and saved to a Map");
+
+ TransactionContext ctx = new NodeRemovedTransactionContext(event);
+
+ for (Object key : dataMap.keySet())
+ {
+ CacheEntityId cacheEntityId = new CacheEntityId(event.getFqn(), (String) key);
+ if (log.isTraceEnabled()) log.trace("Created new CacheEntityId");
+
+ String fqnString = cacheEntityId.getFqn().toString(); // Vars for logging
+ String keyString = (String) key;
+
+
+ searchFactory.getWorker().performWork(new Work(dataMap.get(key), cacheEntityId.getDocumentId(), WorkType.DELETE), ctx);
+
+ if (log.isTraceEnabled())
+ {
+ log.debug("Added your object into Lucene with Fqn " + fqnString + " and key " + keyString);
+ }
+ }
+ }
+ }
+}
Modified: searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/IndexingInTransaction.java
===================================================================
--- searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/IndexingInTransaction.java 2009-03-19 18:08:54 UTC (rev 7929)
+++ searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/IndexingInTransaction.java 2009-03-20 00:38:33 UTC (rev 7930)
@@ -107,7 +107,9 @@
searchableCache.removeNode(Fqn.fromString("Name15"));
List l = searchableCache.createQuery(Entity.searchByName("Name15")).list();
+ System.out.println(l.size());
+ System.out.println("Cache listeners are " + coreCache.getCacheListeners());
// bug: collection is not empty - there is null as there are inconsistencies in the indexes
assertTrue("there should be no record found", l.isEmpty());
Added: searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/NodeRemovedTest.java
===================================================================
--- searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/NodeRemovedTest.java (rev 0)
+++ searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/NodeRemovedTest.java 2009-03-20 00:38:33 UTC (rev 7930)
@@ -0,0 +1,59 @@
+package org.jboss.cache.search.blackbox;
+
+import org.testng.annotations.Test;
+import org.testng.annotations.BeforeMethod;
+import org.jboss.cache.search.test.Person;
+import org.jboss.cache.search.SearchableCache;
+import org.jboss.cache.search.SearchableCacheFactory;
+import org.jboss.cache.search.SearchableCoreRemover;
+import org.jboss.cache.Cache;
+import org.jboss.cache.DefaultCacheFactory;
+import org.apache.lucene.queryParser.QueryParser;
+import org.apache.lucene.queryParser.ParseException;
+import org.apache.lucene.analysis.standard.StandardAnalyzer;
+import org.apache.lucene.search.Query;
+
+import java.util.List;
+
+/**
+ * @author Navin Surtani (<a href="mailto:nsurtani@redhat.com">nsurtani(a)redhat.com</a>)
+ */
+
+@Test
+public class NodeRemovedTest
+{
+ Person p1 = new Person();
+ SearchableCache searchableCache;
+
+ @BeforeMethod
+ public void setUp()
+ {
+ p1.setName("Cat");
+ p1.setBlurb("Smelly");
+ p1.setAge(12);
+
+ Cache cache = new DefaultCacheFactory().createCache(true);
+ searchableCache = new SearchableCacheFactory().createSearchableCache(cache, Person.class);
+
+ }
+
+ public void testRemoveNode() throws ParseException
+ {
+ searchableCache.put("/a", "key", p1);
+
+ QueryParser parser = new QueryParser("name", new StandardAnalyzer());
+ Query luceneQuery = parser.parse("cat");
+ List found = searchableCache.createQuery(luceneQuery, Person.class).list();
+
+ assert found.size() == 1;
+
+ searchableCache.removeNode("/a");
+
+ parser = new QueryParser("name", new StandardAnalyzer());
+ luceneQuery = parser.parse("cat");
+ found = searchableCache.createQuery(luceneQuery, Person.class).list();
+
+ assert found.size() == 0;
+ }
+
+}
15 years, 9 months