odraese commented on a change in pull request #626: [HIVE-21686] ensure that 
memory allocator does not evict using brute …
URL: https://github.com/apache/hive/pull/626#discussion_r283528740
 
 

 ##########
 File path: 
llap-server/src/test/org/apache/hadoop/hive/llap/cache/TestCacheAllocationsEvictionsCycles.java
 ##########
 @@ -0,0 +1,324 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hive.llap.cache;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hive.common.io.Allocator;
+import org.apache.hadoop.hive.common.io.encoded.MemoryBuffer;
+import org.apache.hadoop.hive.conf.HiveConf;
+import org.apache.hadoop.hive.llap.io.metadata.MetadataCache;
+import org.apache.hadoop.hive.llap.metrics.LlapDaemonCacheMetrics;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Test the full cycle of allocation/accounting/eviction interactions.
+ */
+public class TestCacheAllocationsEvictionsCycles {
+
+  private static final Logger LOG = 
LoggerFactory.getLogger(TestCacheAllocationsEvictionsCycles.class);
+  private static final LlapDaemonCacheMetrics cacheMetrics = 
LlapDaemonCacheMetrics.create("testCache", "testSession");
+
+  private final long maxSize = 1024;
+  private final LowLevelCache dataCache = Mockito.mock(LowLevelCache.class);
+  private final SerDeLowLevelCacheImpl serdCache = 
Mockito.mock(SerDeLowLevelCacheImpl.class);
+  private final MetadataCache metaDataCache = 
Mockito.mock(MetadataCache.class);
+
+  private BuddyAllocator allocator;
+  private MemoryManager memoryManager;
+  private LowLevelCachePolicy cachePolicy;
+  private EvictionTracker evictionTracker;
+
+  @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, 1024 * 1024 * 128);
+    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;
+  }
+
+  /**
+   * Test case to ensure that deallocate it does merge small blocks into 
bigger ones.
+   */
+  @Test(timeout = 6_000L) public void TestMergeOfBlocksAfterDeallocate() {
 
 Review comment:
   Seems, that all other tests (that I read so far) in LLAP followed the 
standard Java method name convention, to start with a lowercase t.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to