com.sleepycat.je.evictor
Class TargetSelector

java.lang.Object
  extended by com.sleepycat.je.evictor.TargetSelector
Direct Known Subclasses:
PrivateSelector, SharedSelector

abstract class TargetSelector
extends Object

The TargetSelect choses an IN for eviction. This is the main point of synchronization in the eviction path. There are other points of synchronization when executing the body of the eviction itself, such as when a btree node latch is taken, or log cleaning utilization information is transferred. The implementation of the target selector is different for a private vs. shared cache, because the underlying cache data structures are different. This difference in implementation embodies the difference between private and shared caches.


Nested Class Summary
(package private) static class TargetSelector.EvictProfile
           
(package private)  class TargetSelector.ScanInfo
          Struct returned when selecting a single IN for eviction.
(package private) static class TargetSelector.SetupInfo
          Struct returned when setting up an eviction batch.
 
Field Summary
(package private)  StatGroup stats
           
 
Constructor Summary
TargetSelector(EnvironmentImpl envImpl)
           
 
Method Summary
abstract  void addEnvironment(EnvironmentImpl additionalEnvImpl)
          Only supported by SharedEvictor.
abstract  boolean checkEnv(EnvironmentImpl targetEnvImpl)
           
(package private) abstract  StatGroup getINListStats(StatsConfig config)
           
(package private) abstract  IN getNextIN()
          Returns the next IN in the INList(s), wrapping if necessary.
(package private) abstract  Iterator<IN> getScanIterator()
           
 StatGroup loadStats(StatsConfig config)
           
(package private) static int normalizeLevel(IN in, int evictType)
          Normalize the tree level of the given IN.
abstract  void noteINListChange(int nINs)
          Called whenever INs are added to, or removed from, the INList.
abstract  void removeEnvironment(EnvironmentImpl targetEnvImpl)
          Only supported by SharedEvictor.
(package private)  TargetSelector.ScanInfo selectIN(int maxNodesToIterate)
          Select a single node to evict.
(package private) abstract  void setScanIterator(Iterator<IN> iter)
           
(package private) abstract  TargetSelector.SetupInfo startBatch(boolean doSpecialEviction)
          Must be synchronized! Perform class-specific batch pre-batch processing: Initialize iterator, and do special eviction (UtilizationTracker eviction) if suitable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

stats

final StatGroup stats
Constructor Detail

TargetSelector

TargetSelector(EnvironmentImpl envImpl)
Method Detail

selectIN

TargetSelector.ScanInfo selectIN(int maxNodesToIterate)
Select a single node to evict. Not synchronized! Instead, getNextIN is the main point of synchronization. Note that it is possible that multiple threads will end up perusing the same INs, if the INList is small enough so that the iterator wraps around. Because of that, this method must be thread safe.


normalizeLevel

static int normalizeLevel(IN in,
                          int evictType)
Normalize the tree level of the given IN. Is public for unit testing. A BIN containing evictable LNs is given level 0, so it will be stripped first. For non-duplicate and DBMAP trees, the high order bits are cleared to make their levels correspond; that way, all bottom level nodes (BINs and DBINs) are given the same eviction priority. Note that BINs in a duplicate tree are assigned the same level as BINs in a non-duplicate tree. This isn't always optimal, but is the best we can do considering that BINs in duplicate trees may contain a mix of LNs and DINs. BINs in the mapping tree are also assigned the same level as user DB BINs. When doing by-level eviction (lruOnly=false), this seems counter-intuitive since we should evict user DB nodes before mapping DB nodes. But that does occur because mapping DB INs referencing an open DB are unevictable. The level is only used for selecting among evictable nodes. If we did NOT normalize the level for the mapping DB, then INs for closed evictable DBs would not be evicted until after all nodes in all user DBs were evicted. If there were large numbers of closed DBs, this would have a negative performance impact.


startBatch

abstract TargetSelector.SetupInfo startBatch(boolean doSpecialEviction)
                                      throws DatabaseException
Must be synchronized! Perform class-specific batch pre-batch processing: Initialize iterator, and do special eviction (UtilizationTracker eviction) if suitable. No tree latches may be held when this method is called. Returns the approximate number of total INs in the INList(s), to bound the size of one batch. One eviction batch will scan at most this number of INs. If zero is returned, selectIN should not be called.

Parameters:
doSpecialEviction - Do non-tree eviction, such as flushing the UtilizationProfile. Since special eviction is serialized, and does require I/O, some callers may not want to be blocked doing this
Throws:
DatabaseException

getNextIN

abstract IN getNextIN()
Returns the next IN in the INList(s), wrapping if necessary. This must be called serially, and must be synchronized.


getINListStats

abstract StatGroup getINListStats(StatsConfig config)

noteINListChange

public abstract void noteINListChange(int nINs)
Called whenever INs are added to, or removed from, the INList.


loadStats

public StatGroup loadStats(StatsConfig config)

addEnvironment

public abstract void addEnvironment(EnvironmentImpl additionalEnvImpl)
Only supported by SharedEvictor.


removeEnvironment

public abstract void removeEnvironment(EnvironmentImpl targetEnvImpl)
Only supported by SharedEvictor.


checkEnv

public abstract boolean checkEnv(EnvironmentImpl targetEnvImpl)

getScanIterator

abstract Iterator<IN> getScanIterator()

setScanIterator

abstract void setScanIterator(Iterator<IN> iter)


Copyright (c) 2004-2010 Oracle. All rights reserved.