Skip to content

Commit

Permalink
TEIID-3422 removing any memory allocation as well
Browse files Browse the repository at this point in the history
  • Loading branch information
shawkins committed Apr 16, 2015
1 parent 6cd764e commit 1d43736
Showing 1 changed file with 10 additions and 10 deletions.
Expand Up @@ -80,7 +80,7 @@ public boolean useSoftCache() {
}

@Test public void testAddGetMultiBlock() throws Exception {
cache = createLayeredCache(1 << 26, 1 << 26, true);
cache = createLayeredCache(1 << 26, 1 << 26, true, true);

CacheEntry ce = new CacheEntry(2l);
Serializer<Integer> s = new SimpleSerializer();
Expand Down Expand Up @@ -159,7 +159,7 @@ private static CacheEntry get(BufferFrontedFileStoreCache cache, Long oid,
}

@Test public void testEviction() throws Exception {
cache = createLayeredCache(1<<15, 1<<15, true);
cache = createLayeredCache(1<<15, 1<<15, true, true);
assertEquals(3, cache.getMaxMemoryBlocks());

CacheEntry ce = new CacheEntry(2l);
Expand Down Expand Up @@ -190,7 +190,7 @@ private static CacheEntry get(BufferFrontedFileStoreCache cache, Long oid,
}

@Test public void testEvictionFails() throws Exception {
cache = createLayeredCache(1<<15, 1<<15, false);
cache = createLayeredCache(1<<15, 1<<15, false, true);
BufferManagerImpl bmi = Mockito.mock(BufferManagerImpl.class);
cache.setBufferManager(bmi);
Serializer<Integer> s = new SimpleSerializer();
Expand All @@ -213,7 +213,7 @@ private void add(BufferFrontedFileStoreCache cache, Serializer<Integer> s,
cache.add(ce, s);
}

private static BufferFrontedFileStoreCache createLayeredCache(int bufferSpace, int objectSize, boolean memStorage) throws TeiidComponentException {
private static BufferFrontedFileStoreCache createLayeredCache(int bufferSpace, int objectSize, boolean memStorage, boolean allocate) throws TeiidComponentException {
BufferFrontedFileStoreCache fsc = new BufferFrontedFileStoreCache();
fsc.cleanerRunning.set(true); //prevent asynch affects
fsc.setMemoryBufferSpace(bufferSpace);
Expand Down Expand Up @@ -260,7 +260,7 @@ public long getLength() {
};
fsc.setStorageManager(sm);
}
fsc.initialize();
fsc.initialize(allocate);
return fsc;
}

Expand All @@ -287,7 +287,7 @@ public long getLength() {
}

@Test public void testDefragTruncateEmpty() throws Exception {
cache = createLayeredCache(1<<15, 1<<15, true);
cache = createLayeredCache(1<<15, 1<<15, true, true);
cache.setMinDefrag(10000000);
Serializer<Integer> s = new SimpleSerializer();
WeakReference<? extends Serializer<?>> ref = new WeakReference<Serializer<?>>(s);
Expand Down Expand Up @@ -316,7 +316,7 @@ public long getLength() {
}

@Test public void testDefragTruncate() throws Exception {
cache = createLayeredCache(1<<15, 1<<15, true);
cache = createLayeredCache(1<<15, 1<<15, true, true);
cache.setMinDefrag(10000000);
Serializer<Integer> s = new SimpleSerializer();
WeakReference<? extends Serializer<?>> ref = new WeakReference<Serializer<?>>(s);
Expand Down Expand Up @@ -350,7 +350,7 @@ public long getLength() {
}

@Test public void testDefragTruncateCompact() throws Exception {
cache = createLayeredCache(1<<15, 1<<15, true);
cache = createLayeredCache(1<<15, 1<<15, true, true);
cache.setCompactBufferFiles(true);
cache.setTruncateInterval(1);
cache.setMinDefrag(10000000);
Expand Down Expand Up @@ -382,7 +382,7 @@ public long getLength() {
}

@Test public void testDefragMin() throws Exception {
cache = createLayeredCache(1<<15, 1<<15, true);
cache = createLayeredCache(1<<15, 1<<15, true, true);
cache.setMinDefrag(10000000);
Serializer<Integer> s = new SimpleSerializer();
WeakReference<? extends Serializer<?>> ref = new WeakReference<Serializer<?>>(s);
Expand Down Expand Up @@ -416,7 +416,7 @@ public long getLength() {
}

@Test public void testLargeMax() throws TeiidComponentException {
createLayeredCache(1 << 20, 1 << 30, false);
createLayeredCache(1 << 20, 1 << 30, false, false);
}

}

0 comments on commit 1d43736

Please sign in to comment.