Created
May 4, 2019 00:14
-
-
Save b-slim/3793afd2f8792a2ee5e0d2f6dbada8f1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class TestCacheAllocationsEvictionsCycles { | |
private final long maxSize = 1024; | |
private BuddyAllocator allocator; | |
private MemoryManager memoryManager; | |
private LowLevelCachePolicy cachePolicy; | |
private LlapDaemonCacheMetrics cacheMetrics = LlapDaemonCacheMetrics.create("testCache", "testSession"); | |
private Logger LOG = LoggerFactory.getLogger(TestCacheAllocationsEvictionsCycles.class); | |
private EvictionTracker evictionTracker; | |
private LowLevelCache dataCache = Mockito.mock(LowLevelCache.class); | |
private SerDeLowLevelCacheImpl serdCache = Mockito.mock(SerDeLowLevelCacheImpl.class); | |
private MetadataCache metaDataCache = Mockito.mock(MetadataCache.class); | |
@Before public void setUp() throws Exception { | |
Configuration conf = new Configuration(); | |
// Set lambda to 1 so the heap size becomes 1 (LRU). | |
conf.setDouble(HiveConf.ConfVars.LLAP_LRFU_LAMBDA.varname, 1.0f); | |
int minBufferSize = 1; | |
cachePolicy = new LowLevelLrfuCachePolicy(minBufferSize, maxSize, conf); | |
memoryManager = new LowLevelCacheMemoryManager(maxSize, cachePolicy, cacheMetrics); | |
int maxAllocationSize = 1024; | |
int minAllocationSize = 8; | |
allocator = | |
new BuddyAllocator(true, | |
false, | |
minAllocationSize, | |
maxAllocationSize, | |
1, | |
maxSize, | |
0, | |
null, | |
memoryManager, | |
cacheMetrics, | |
"no-force-eviction", | |
true); | |
EvictionDispatcher evictionDispatcher = new EvictionDispatcher(dataCache, serdCache, metaDataCache, allocator); | |
evictionTracker = new EvictionTracker(evictionDispatcher); | |
cachePolicy.setEvictionListener(evictionTracker); | |
} | |
@After public void tearDown() throws Exception { | |
LOG.info("Purge the cache on tear down"); | |
cachePolicy.purge(); | |
allocator = null; | |
memoryManager = null; | |
cachePolicy = null; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment