[jbosscache-issues] [JBoss JIRA] Closed: (JBCACHE-1495) the searchable cache indexes are not updated if there were data manipulation in transaction or batch
Navin Surtani (JIRA)
jira-events at lists.jboss.org
Wed Jul 21 07:09:53 EDT 2010
[ https://jira.jboss.org/browse/JBCACHE-1495?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Navin Surtani closed JBCACHE-1495.
----------------------------------
Resolution: Out of Date
Just clearing up an old fix. I believe this issue was fixed but was reported a year before the time of close and I can't exactly remember how it was fixed.
> the searchable cache indexes are not updated if there were data manipulation in transaction or batch
> -----------------------------------------------------------------------------------------------------
>
> Key: JBCACHE-1495
> URL: https://jira.jboss.org/browse/JBCACHE-1495
> Project: JBoss Cache
> Issue Type: Bug
> Security Level: Public(Everyone can see)
> Components: SearchableCache
> Environment: searchable cache version 1.0.0 GA
> Reporter: Yan Falken
> Assignee: Navin Surtani
> Priority: Blocker
>
> // runnable unit test:
> package problems;
> import org.hibernate.search.annotations.Field;
> 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.config.Configuration;
> import org.jboss.cache.config.CacheLoaderConfig;
> import org.jboss.cache.search.SearchableCacheFactory;
> import org.jboss.cache.search.SearchableCache;
> 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.util.Properties;
> import java.io.Serializable;
> @Test(groups = {"unit"}, sequential = true)
> public class IndexingInTransaction {
> private static final Fqn fname = Fqn.fromString("blah");
> private Cache coreCache;
> private SearchableCache searchableCache;
> Node node;
> public IndexingInTransaction() {
> init();
> }
> @BeforeMethod
> public void init() {
> CacheFactory factory = new DefaultCacheFactory();
> Configuration c = new Configuration();
> c.setInvocationBatchingEnabled(true);
> CacheLoaderConfig clc = new CacheLoaderConfig();
> JdbmCacheLoaderConfig jclc = new JdbmCacheLoaderConfig();
> jclc.setAsync(false);
> jclc.setFetchPersistentState(false);
> jclc.setIgnoreModifications(false);
> jclc.setPurgeOnStartup(true);
> jclc.setLocation("/tmp/c1");
> clc.addIndividualCacheLoaderConfig(jclc);
> c.setCacheLoaderConfig(clc);
> coreCache = factory.createCache(c, false);
> SearchableCacheFactory f = new SearchableCacheFactory();
> Properties p = new Properties();
> p.put("hibernate.search.default.indexBase", "/tmp/c1idx");
> searchableCache = f.createSearchableCache(coreCache, p, Entity.class);
> searchableCache.create();
> searchableCache.start();
> node = searchableCache.getRoot().addChild(fname);
> }
> @Test
> public void testPutEntitiesWithoutTransaction() {
> for (int i = 1; i <= 10; i++) {
> Entity e = getEntity(i);
> System.out.println("caching: " + e);
> Node c = node.addChild(Fqn.fromString(e.getName()));
> c.put(""+ e.getId(), e);
> }
> assertFalse(searchableCache.createQuery(
> Entity.searchByName("Name5")).list().isEmpty());
> }
> @Test
> public void testPutEntitiesWithTransaction() throws Exception {
> ((CacheSPI)(coreCache)).getTransactionManager().begin();
> for (int i = 11; i <= 20; i++) {
> Entity e = getEntity(i);
> System.out.println("caching: " + e);
> Node c = node.addChild(Fqn.fromString(e.getName()));
> c.put(""+ e.getId(), e);
> }
> ((CacheSPI)(coreCache)).getTransactionManager().commit();
> assertFalse(searchableCache.createQuery(
> Entity.searchByName("Name15")).list().isEmpty());
> }
> Entity getEntity(long id) {
> return new Entity(id, "Name" + id, "Surname" + id, true);
> }
> // public static void main(String[] args) {
> // IndexingInTransaction stb = new IndexingInTransaction();
> // stb.init();
> // }
> }
> @ProvidedId
> @Indexed
> class Entity implements Serializable {
> public static final String IDX_NAME = "name";
> public static final String IDX_SURNAME = "surname";
> private long id;
> @Field(store = Store.YES)
> private String name;
> @Field (store = Store.YES)
> private String surname;
> private boolean dead;
> Entity(long id, String name, String surname, boolean dead) {
> this.id = id;
> this.name = name;
> this.surname = surname;
> this.dead = dead;
> }
> public long getId() {
> return id;
> }
> public String getName() {
> return name;
> }
> public String getSurname() {
> return surname;
> }
> public boolean isDead() {
> return dead;
> }
> public static Query searchByName(String name) {
> BooleanQuery query = new BooleanQuery();
> query.add(new TermQuery(
> new Term(Entity.IDX_NAME,
> name.toLowerCase())),
> BooleanClause.Occur.MUST);
> return query;
> }
> @Override
> public String toString() {
> return "Entity{" +
> "id=" + id +
> ", name='" + name + '\'' +
> ", surname='" + surname + '\'' +
> ", dead=" + dead +
> '}';
> }
> }
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the jbosscache-issues
mailing list