Package org.apache.derby.iapi.services.cache

Examples of org.apache.derby.iapi.services.cache.Cacheable


     * @param partialKey the partial (or exact) key to match, or
     * <code>null</code> to match all keys
     */
    private void cleanCache(Matchable partialKey) throws StandardException {
        for (CacheEntry entry : cache.values()) {
            final Cacheable dirtyObject;
            entry.lock();
            try {
                if (!entry.isValid()) {
                    // no need to clean an invalid entry
                    continue;
                }
                Cacheable c = entry.getCacheable();
                if (partialKey != null && !partialKey.match(c.getIdentity())) {
                    // don't clean objects that don't match the partial key
                    continue;
                }
                if (!c.isDirty()) {
                    // already clean
                    continue;
                }

                // Increment the keep count for this entry to prevent others
View Full Code Here


     * @exception StandardException if an error occurs while cleaning
     */
    void cleanEntry(CacheEntry entry) throws StandardException {
        // Fetch the cacheable while having exclusive access to the entry.
        // Release the lock before cleaning to avoid blocking others.
        Cacheable item;
        entry.lock();
        try {
            item = entry.getCacheable();
            if (item == null) {
                // nothing to do
View Full Code Here

        for (CacheEntry entry : cache.values()) {
            entry.lock();
            try {
                // never remove kept entries
                if (!entry.isKept()) {
                    Cacheable c = entry.getCacheable();
                    // If c is null, it's not in the cache and there's no need
                    // to remove it. If c is dirty, we can't remove it yet.
                    if (c != null && !c.isDirty()) {
                        removeEntry(c.getIdentity());
                    }
                }
            } finally {
                entry.unlock();
            }
View Full Code Here

    public boolean discard(Matchable partialKey) {
        boolean allRemoved = true;
        for (CacheEntry entry : cache.values()) {
            entry.lock();
            try {
                Cacheable c = entry.getCacheable();
                if (c == null) {
                    // not in the cache - no need to remove it
                    continue;
                }
                if (partialKey != null && !partialKey.match(c.getIdentity())) {
                    // not a match, don't remove it
                    continue;
                }
                if (entry.isKept()) {
                    // still in use, don't remove it
                    allRemoved = false;
                    continue;
                }
                removeEntry(c.getIdentity());
            } finally {
                entry.unlock();
            }
        }
        return allRemoved;
View Full Code Here

    public Collection<Cacheable> values() {
        ArrayList<Cacheable> values = new ArrayList<Cacheable>();
        for (CacheEntry entry : cache.values()) {
            entry.lock();
            try {
                Cacheable c = entry.getCacheable();
                if (c != null) {
                    values.add(c);
                }
            } finally {
                entry.unlock();
View Full Code Here

                continue;
            }

            // This variable will hold a dirty cacheable that should be cleaned
            // after the try/finally block.
            final Cacheable dirty;

            e.lock();
            try {
                if (!isEvictable(e, h, true)) {
                    continue;
                }

                // The entry is not in use, and has not been used for at least
                // one round on the clock. See if it needs to be cleaned.
                Cacheable c = e.getCacheable();
                if (!c.isDirty()) {
                    // Not in use and not dirty. Take over the holder.
                    h.switchEntry(entry);
                    cacheManager.evictEntry(c.getIdentity());
                    return h;
                }

                // Ask the background cleaner to clean the entry.
                BackgroundCleaner cleaner = cacheManager.getBackgroundCleaner();
View Full Code Here

            try {
                if (!isEvictable(e, h, false)) {
                    continue;
                }

                final Cacheable c = e.getCacheable();
                if (c.isDirty()) {
                    // Don't evict dirty entries.
                    continue;
                }

                // mark as evicted to prevent reuse
                h.setEvicted();

                // remove from cache manager
                cacheManager.evictEntry(c.getIdentity());

                // remove from clock
                removeHolder(index, h);

                // move position back because of the removal so that we don't
View Full Code Here

           
            Object[] removeInfo =
                            droppedTableStubInfo.get(logInstant);
            Object identity = removeInfo[1];
            //delete the entry in the container cache.
            Cacheable ccentry =  containerCache.findCached(identity);
            if(ccentry!=null)
              containerCache.remove(ccentry);

            //delete the stub we don't require it during recovery
                        synchronized( this)
View Full Code Here

        }
    }

  public Cacheable createIdentity( Object key, Object createParameter ) throws StandardException
  {
        Cacheable cacheable = this;

        //
        // The createParameter arg is unused.
        //
        return cacheable.setIdentity( key );
  }
View Full Code Here

           
            Object[] removeInfo =
                            (Object[]) droppedTableStubInfo.get(logInstant);
            Object identity = removeInfo[1];
            //delete the entry in the container cache.
            Cacheable ccentry =  containerCache.findCached(identity);
            if(ccentry!=null)
              containerCache.remove(ccentry);

            //delete the stub we don't require it during recovery
                        synchronized( this)
View Full Code Here

TOP

Related Classes of org.apache.derby.iapi.services.cache.Cacheable

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.