Explorar el Código

Expose the list of pack files in the DfsBlockCache

Callers may want to inspect the contents of the cache, which this allows
them to do in a read-only fashion without any locking.

Change-Id: Ifd78e8ce34e26e5cc33e9dd61d70c593ce479ee0
tags/v1.2.0.201112221803-r
Dave Borowitz hace 12 años
padre
commit
dff9d56b94

+ 19
- 2
org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsBlockCache.java Ver fichero



import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.Collection;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReferenceArray; import java.util.concurrent.atomic.AtomicReferenceArray;
/** Cache of pack files, indexed by description. */ /** Cache of pack files, indexed by description. */
private final Map<DfsPackDescription, DfsPackFile> packCache; private final Map<DfsPackDescription, DfsPackFile> packCache;


/** View of pack files in the pack cache. */
private final Collection<DfsPackFile> packFiles;

/** Number of times a block was found in the cache. */ /** Number of times a block was found in the cache. */
private final AtomicLong statHit; private final AtomicLong statHit;


readAheadLimit = cfg.getReadAheadLimit(); readAheadLimit = cfg.getReadAheadLimit();
readAheadService = cfg.getReadAheadService(); readAheadService = cfg.getReadAheadService();


packCache = new HashMap<DfsPackDescription, DfsPackFile>();
packCache = new ConcurrentHashMap<DfsPackDescription, DfsPackFile>(
16, 0.75f, 1);
packFiles = Collections.unmodifiableCollection(packCache.values());


statHit = new AtomicLong(); statHit = new AtomicLong();
statMiss = new AtomicLong(); statMiss = new AtomicLong();
return statEvict; return statEvict;
} }


/**
* Get the pack files stored in this cache.
*
* @return a collection of pack files, some of which may not actually be
* present; the caller should check the pack's cached size.
*/
public Collection<DfsPackFile> getPackFiles() {
return packFiles;
}

DfsPackFile getOrCreate(DfsPackDescription dsc, DfsPackKey key) { DfsPackFile getOrCreate(DfsPackDescription dsc, DfsPackKey key) {
// TODO This table grows without bound. It needs to clean up // TODO This table grows without bound. It needs to clean up
// entries that aren't in cache anymore, and aren't being used // entries that aren't in cache anymore, and aren't being used

Cargando…
Cancelar
Guardar