Package org.apache.openjpa.datacache

Examples of org.apache.openjpa.datacache.DataCache


            if (sm == null)
                return;

            sm.evict();
            if (_evictDataCache && sm.getObjectId() != null) {
                DataCache cache = _conf.getDataCacheManagerInstance().selectCache(sm);
                if (cache != null)
                    cache.remove(sm.getObjectId());
            }
        }
        catch (OpenJPAException ke) {
            throw ke;
        } catch (RuntimeException re) {
View Full Code Here


            if (sm == null)
                return;

            sm.evict();
            if (_evictDataCache && sm.getObjectId() != null) {
                DataCache cache = sm.getMetaData().getDataCache();
                if (cache != null)
                    cache.remove(sm.getObjectId());
            }
        }
        catch (OpenJPAException ke) {
            throw ke;
        } catch (RuntimeException re) {
View Full Code Here

            if (sm == null)
                return;

            sm.evict();
            if (_evictDataCache && sm.getObjectId() != null) {
                DataCache cache = _conf.getDataCacheManagerInstance().selectCache(sm);
                if (cache != null)
                    cache.remove(sm.getObjectId());
            }
        }
        catch (OpenJPAException ke) {
            throw ke;
        } catch (RuntimeException re) {
View Full Code Here

            if (sm == null)
                return;

            sm.evict();
            if (_evictDataCache && sm.getObjectId() != null) {
                DataCache cache = sm.getMetaData().getDataCache();
                if (cache != null)
                    cache.remove(sm.getObjectId());
            }
        }
        catch (OpenJPAException ke) {
            throw ke;
        } catch (RuntimeException re) {
View Full Code Here

            if (sm == null)
                return;

            sm.evict();
            if (_evictDataCache && sm.getObjectId() != null) {
                DataCache cache = _conf.getDataCacheManagerInstance().selectCache(sm);
                if (cache != null)
                    cache.remove(sm.getObjectId());
            }
        }
        catch (OpenJPAException ke) {
            throw ke;
        } catch (RuntimeException re) {
View Full Code Here

            return true;

        // if the field isn't loaded in the state manager, it still might be
        // loaded in the data cache, in which case we still have to correct
        // it to keep the cache in sync
        DataCache cache = _mgr.selectCache(sm);
        if (cache == null)
            return false;

        // can't retrieve an embedded object directly, so always assume the
        // field is loaded and needs to be corrected
        if (sm.isEmbedded())
            return true;

        PCData pc = cache.get(sm.getObjectId());
        if (pc == null)
            return false;
        return pc.isLoaded(field);
    }
View Full Code Here

        assertNotNull(policy);
        assertTrue(policy.getClass() + " not TestPolicy", policy instanceof TestPolicy);
       
    }
    public void testPluginConfiguration() {
        DataCache cache = ((StoreCacheImpl)emf.getStoreCache()).getDelegate();
        assertTrue(cache instanceof PartitionedDataCache);
        assertFalse(cache.getPartitionNames().isEmpty());
        assertNotNull(cache.getPartition("a", false));
        assertNotNull(cache.getPartition("b", false));
        assertNull(cache.getPartition("c", false));
        assertCacheConfiguration("a", 100);
        assertCacheConfiguration("b", 200);
    }
View Full Code Here

        assertCacheConfiguration("a", 100);
        assertCacheConfiguration("b", 200);
    }
   
    void assertCacheConfiguration(String name, int size) {
        DataCache cache = emf.getConfiguration().getDataCacheManagerInstance().getDataCache(name);
        assertNotNull(cache);
        assertTrue(cache instanceof ConcurrentDataCache);
        assertEquals(size, ((ConcurrentDataCache)cache).getCacheSize());
    }
View Full Code Here

            "Port=5636, Addresses=127.0.0.1:6636");
        OpenJPAEntityManagerFactory pmfReceiver = createDistinctFactory(
            TCPRemoteCommitProvider.class,
            "Port=6636, Addresses=127.0.0.1:5636");
        // Get the datacaches from each pmf
        DataCache dcSender =
            ((OpenJPAEntityManagerFactorySPI) pmfSender).getConfiguration()
                .getDataCacheManagerInstance().getSystemDataCache();
        DataCache dcReceiver =
            ((OpenJPAEntityManagerFactorySPI) pmfReceiver).getConfiguration()
                .getDataCacheManagerInstance().getSystemDataCache();

        deleteAll(RuntimeTest1.class);
        deleteAll(RuntimeTest2.class);

        _runtime1sOids = null;
        _runtime2sOids = null;

        String transType = "normal";
        String rcpType = "OIDs";
        if (asLargeTransaction) {
            transType = "large";
            rcpType = "classes";
        }
        System.out.println("-------------------");
        System.out.println(
            "2 PMFs created, acting as a cluster using ports 5636 and 6636");
        System.out.println("Testing scenario:");
        System.out
            .println("  1 Seed datastore with instances of RuntimeTest1 AND "
                + "RuntimeTest2 objs.\n"
                + "  2 pmf2 fills its cache with both sets of objs.\n"
                + "  3 pmf1 does a "
                + transType
                + " tx that invokes an operation of "
                + changeOperation.getName()
                + " to affect a single Runtime1 \n"
                + "    assert that both pmf1 and pmf2's data caches dropped all"
                + "Runtime1s");
        System.out.println("Remote commit event is transmiting " + rcpType);

        // Create runtimes1s and 2s.
        // Noraml transaction
        OpenJPAEntityManager pmSender = (OpenJPAEntityManager) pmfSender
            .createEntityManager();
        seedDataStore(pmSender, NUM_OBJECTS);
        endEm(pmSender);

        // wait a bit so they get stored
        pause(1);

        OpenJPAEntityManager pm2;
        pm2 = (OpenJPAEntityManager) pmfReceiver.createEntityManager();
        performLoadAll(pm2);
        endEm(pm2);

        pmSender = (OpenJPAEntityManager) pmfSender.createEntityManager();
        performLoadAll(pmSender);
        endEm(pmSender);

        // assert that pmf2's data cache now has all the Runtime1 and 2s.
        for (int i = 0; i < _runtime1sOids.length; i++) {
            assertTrue(dcReceiver.contains(
                Id.newInstance(RuntimeTest1.class, _runtime1sOids[i])));
        }
        for (int i = 0; i < _runtime2sOids.length; i++) {
            assertTrue(dcReceiver.contains(
                Id.newInstance(RuntimeTest2.class, _runtime2sOids[i])));
        }

        // Modify or delete exactly 1 RuntimeTest1 object during a
        // largeTransaction
        changeOperation.operation(pmfSender, asLargeTransaction);

        // assert that pmf1's data cache now only has Runtime2 objects
        if (asLargeTransaction) {
            for (int i = 0; i < _runtime1sOids.length; i++) {
                assertFalse(dcSender.contains(
                    Id.newInstance(RuntimeTest1.class, _runtime1sOids[i])));
            }
        } else {
            // Normal transaction
            for (int i = 0; i < _runtime1sOids.length; i++) {
                if (isDelete && i == 0) {
                    assertFalse(dcSender.contains(
                        Id.newInstance(RuntimeTest1.class, _runtime1sOids[i])));
                } else {
                    // modified the first elemnt, which just updated it.
                    // (for Kodo's data cache).
                    assertTrue(dcSender.contains(
                        Id.newInstance(RuntimeTest1.class, _runtime1sOids[i])));
                }
            }
        }
        for (int i = 0; i < _runtime2sOids.length; i++) {
            assertTrue(dcSender.contains(
                Id.newInstance(RuntimeTest2.class, _runtime2sOids[i])));
        }
        // wait a tiny bit so the rce propagates
        pause(2);
        // assert the pmf2's data cache also now only has Runtime2 objects
        if (asLargeTransaction) {
            for (int i = 0; i < _runtime1sOids.length; i++) {
                assertFalse(dcReceiver.contains(Id.newInstance(
                    RuntimeTest1.class, _runtime1sOids[i]))); //failing here
            }
        } else {
            for (int i = 0; i < _runtime1sOids.length; i++) {
                if (i == 0) {
                    assertFalse(dcReceiver.contains(Id.newInstance(
                        RuntimeTest1.class,
                        _runtime1sOids[i])))//failing here
                } else {
                    assertTrue(dcReceiver.contains(
                        Id.newInstance(RuntimeTest1.class, _runtime1sOids[i])));
                }
            }
        }
        for (int i = 0; i < _runtime2sOids.length; i++) {
            assertTrue(dcReceiver.contains(
                Id.newInstance(RuntimeTest2.class, _runtime2sOids[i])));
        }

        // shutdown
        pmfSender.close();
View Full Code Here

    public void testArrayOfStrings() {
        // check that the data cache contains an efficient representation
        StoreCacheImpl storeCache = (StoreCacheImpl)
            OpenJPAPersistence.cast(emf).getStoreCache();
        DataCache cache = storeCache.getDelegate();
        PCData data = cache.get(internalOid);
        ClassMetaData meta = JPAFacadeHelper.getMetaData(emf,
            AllFieldTypes.class);
        Object cachedFieldData =
            data.getData(meta.getField("arrayOfStrings").getIndex());
        assertTrue(cachedFieldData.getClass().isArray());
View Full Code Here

TOP

Related Classes of org.apache.openjpa.datacache.DataCache

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.