accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dlmar...@apache.org
Subject accumulo git commit: ACCUMULO-4463: removed some unused methods
Date Tue, 09 May 2017 22:16:27 GMT
Repository: accumulo
Updated Branches:
  refs/heads/ACCUMULO-4463 cc5739453 -> d98fba14b


ACCUMULO-4463: removed some unused methods


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/d98fba14
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/d98fba14
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/d98fba14

Branch: refs/heads/ACCUMULO-4463
Commit: d98fba14b226b7c47a7700876e16c832c3100806
Parents: cc57394
Author: Dave Marion <dlmarion@apache.org>
Authored: Tue May 9 18:15:26 2017 -0400
Committer: Dave Marion <dlmarion@apache.org>
Committed: Tue May 9 18:15:26 2017 -0400

----------------------------------------------------------------------
 .../cache/BlockCacheConfiguration.java          |  4 --
 .../cache/BlockCacheConfigurationHelper.java    | 14 ++-----
 .../core/file/blockfile/cache/CacheType.java    |  4 --
 .../cache/lru/LruBlockCacheConfiguration.java   |  2 +
 .../cache/BlockConfigurationHelperTest.java     | 32 ++++++++++++++++
 .../file/blockfile/cache/CacheTypeTest.java     | 30 ---------------
 .../file/blockfile/cache/TestLruBlockCache.java | 40 ++++++++++----------
 .../tserver/TabletServerResourceManager.java    | 18 +++++----
 8 files changed, 69 insertions(+), 75 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/d98fba14/core/src/main/java/org/apache/accumulo/core/file/blockfile/cache/BlockCacheConfiguration.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/file/blockfile/cache/BlockCacheConfiguration.java
b/core/src/main/java/org/apache/accumulo/core/file/blockfile/cache/BlockCacheConfiguration.java
index bfcfbdf..a7e0828 100644
--- a/core/src/main/java/org/apache/accumulo/core/file/blockfile/cache/BlockCacheConfiguration.java
+++ b/core/src/main/java/org/apache/accumulo/core/file/blockfile/cache/BlockCacheConfiguration.java
@@ -30,12 +30,8 @@ public class BlockCacheConfiguration {
   /** Approximate block size */
   private final long blockSize;
 
-  protected final BlockCacheConfigurationHelper helper;
-
   public BlockCacheConfiguration(AccumuloConfiguration conf, CacheType type, String implName)
{
 
-    helper = new BlockCacheConfigurationHelper(conf, type, implName);
-
     switch (type) {
       case INDEX:
         this.maxSize = conf.getAsBytes(Property.TSERV_INDEXCACHE_SIZE);

http://git-wip-us.apache.org/repos/asf/accumulo/blob/d98fba14/core/src/main/java/org/apache/accumulo/core/file/blockfile/cache/BlockCacheConfigurationHelper.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/file/blockfile/cache/BlockCacheConfigurationHelper.java
b/core/src/main/java/org/apache/accumulo/core/file/blockfile/cache/BlockCacheConfigurationHelper.java
index 867114d..84b90e6 100644
--- a/core/src/main/java/org/apache/accumulo/core/file/blockfile/cache/BlockCacheConfigurationHelper.java
+++ b/core/src/main/java/org/apache/accumulo/core/file/blockfile/cache/BlockCacheConfigurationHelper.java
@@ -22,7 +22,6 @@ import org.apache.accumulo.core.conf.ConfigurationCopy;
 public class BlockCacheConfigurationHelper {
 
   private final ConfigurationCopy conf;
-  private final String implName;
   private String basePropertyName;
 
   public BlockCacheConfigurationHelper(AccumuloConfiguration conf, CacheType type, String
implName) {
@@ -31,26 +30,21 @@ public class BlockCacheConfigurationHelper {
 
   public BlockCacheConfigurationHelper(ConfigurationCopy conf, CacheType type, String implName)
{
     this.conf = conf;
-    this.implName = implName;
-    this.basePropertyName = type.getPropertyPrefix(implName);
+    this.basePropertyName = BlockCacheManager.CACHE_PROPERTY_BASE + implName + "." + type.name().toLowerCase()
+ ".";
   }
 
-  public void switchCacheType(CacheType type) {
-    this.basePropertyName = type.getPropertyPrefix(implName);
+  public String getPropertyPrefix() {
+    return basePropertyName;
   }
 
   public String getFullPropertyName(String propertySuffix) {
     return this.basePropertyName + propertySuffix;
   }
 
-  public void set(String propertySuffix, String value) {
+  public void setIfAbsent(String propertySuffix, String value) {
     conf.setIfAbsent(getFullPropertyName(propertySuffix), value);
   }
 
-  public String getValue(String propertySuffix) {
-    return conf.get(getFullPropertyName(propertySuffix));
-  }
-
   public ConfigurationCopy getConfiguration() {
     return this.conf;
   }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/d98fba14/core/src/main/java/org/apache/accumulo/core/file/blockfile/cache/CacheType.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/file/blockfile/cache/CacheType.java
b/core/src/main/java/org/apache/accumulo/core/file/blockfile/cache/CacheType.java
index f65ac34..9e26c05 100644
--- a/core/src/main/java/org/apache/accumulo/core/file/blockfile/cache/CacheType.java
+++ b/core/src/main/java/org/apache/accumulo/core/file/blockfile/cache/CacheType.java
@@ -21,8 +21,4 @@ public enum CacheType {
 
   DATA, INDEX, SUMMARY;
 
-  public String getPropertyPrefix(String impl) {
-    return BlockCacheManager.CACHE_PROPERTY_BASE + impl + "." + name().toLowerCase() + ".";
-  }
-
 }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/d98fba14/core/src/main/java/org/apache/accumulo/core/file/blockfile/cache/lru/LruBlockCacheConfiguration.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/file/blockfile/cache/lru/LruBlockCacheConfiguration.java
b/core/src/main/java/org/apache/accumulo/core/file/blockfile/cache/lru/LruBlockCacheConfiguration.java
index ba8a125..377a849 100644
--- a/core/src/main/java/org/apache/accumulo/core/file/blockfile/cache/lru/LruBlockCacheConfiguration.java
+++ b/core/src/main/java/org/apache/accumulo/core/file/blockfile/cache/lru/LruBlockCacheConfiguration.java
@@ -22,6 +22,7 @@ import java.util.Map;
 import org.apache.accumulo.core.conf.AccumuloConfiguration;
 import org.apache.accumulo.core.conf.Property;
 import org.apache.accumulo.core.file.blockfile.cache.BlockCacheConfiguration;
+import org.apache.accumulo.core.file.blockfile.cache.BlockCacheConfigurationHelper;
 import org.apache.accumulo.core.file.blockfile.cache.CacheType;
 
 public final class LruBlockCacheConfiguration extends BlockCacheConfiguration {
@@ -77,6 +78,7 @@ public final class LruBlockCacheConfiguration extends BlockCacheConfiguration
{
   public LruBlockCacheConfiguration(AccumuloConfiguration conf, CacheType type, String implName)
{
     super(conf, type, implName);
     Map<String,String> props = conf.getAllPropertiesWithPrefix(Property.GENERAL_ARBITRARY_PROP_PREFIX);
+    BlockCacheConfigurationHelper helper = new BlockCacheConfigurationHelper(conf, type,
implName);
     this.acceptableFactor = getOrDefault(props, helper.getFullPropertyName(ACCEPTABLE_FACTOR_PROPERTY),
DEFAULT_ACCEPTABLE_FACTOR);
     this.minFactor = getOrDefault(props, helper.getFullPropertyName(MIN_FACTOR_PROPERTY),
DEFAULT_MIN_FACTOR);
     this.singleFactor = getOrDefault(props, helper.getFullPropertyName(SINGLE_FACTOR_PROPERTY),
DEFAULT_SINGLE_FACTOR);

http://git-wip-us.apache.org/repos/asf/accumulo/blob/d98fba14/core/src/test/java/org/apache/accumulo/core/file/blockfile/cache/BlockConfigurationHelperTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/accumulo/core/file/blockfile/cache/BlockConfigurationHelperTest.java
b/core/src/test/java/org/apache/accumulo/core/file/blockfile/cache/BlockConfigurationHelperTest.java
new file mode 100644
index 0000000..1dcd71a
--- /dev/null
+++ b/core/src/test/java/org/apache/accumulo/core/file/blockfile/cache/BlockConfigurationHelperTest.java
@@ -0,0 +1,32 @@
+/*
+ * 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.accumulo.core.file.blockfile.cache;
+
+import org.apache.accumulo.core.conf.DefaultConfiguration;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class BlockConfigurationHelperTest {
+
+  @Test
+  public void testGetPropertyPrefix() throws Exception {
+    BlockCacheConfigurationHelper helper = new BlockCacheConfigurationHelper(new DefaultConfiguration(),
CacheType.DATA, "lru");
+    Assert.assertEquals("general.custom.cache.block.lru.data.", helper.getPropertyPrefix());
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/d98fba14/core/src/test/java/org/apache/accumulo/core/file/blockfile/cache/CacheTypeTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/accumulo/core/file/blockfile/cache/CacheTypeTest.java
b/core/src/test/java/org/apache/accumulo/core/file/blockfile/cache/CacheTypeTest.java
deleted file mode 100644
index d7cb586..0000000
--- a/core/src/test/java/org/apache/accumulo/core/file/blockfile/cache/CacheTypeTest.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * 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.accumulo.core.file.blockfile.cache;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-public class CacheTypeTest {
-
-  @Test
-  public void testGetPropertyPrefix() throws Exception {
-    Assert.assertEquals("general.custom.cache.block.lru.data.", CacheType.DATA.getPropertyPrefix("lru"));
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/d98fba14/core/src/test/java/org/apache/accumulo/core/file/blockfile/cache/TestLruBlockCache.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/accumulo/core/file/blockfile/cache/TestLruBlockCache.java
b/core/src/test/java/org/apache/accumulo/core/file/blockfile/cache/TestLruBlockCache.java
index 4bf0eba..dc2c4a6 100644
--- a/core/src/test/java/org/apache/accumulo/core/file/blockfile/cache/TestLruBlockCache.java
+++ b/core/src/test/java/org/apache/accumulo/core/file/blockfile/cache/TestLruBlockCache.java
@@ -137,7 +137,7 @@ public class TestLruBlockCache extends TestCase {
     cc.set(Property.TSERV_DEFAULT_BLOCKSIZE, Long.toString(blockSize));
     cc.set(Property.TSERV_INDEXCACHE_SIZE, Long.toString(maxSize));
     BlockCacheConfigurationHelper helper = new BlockCacheConfigurationHelper(cc, CacheType.INDEX,
factory.getCacheImplName());
-    helper.set(LruBlockCacheConfiguration.EVICTION_THREAD_PROPERTY, Boolean.FALSE.toString());
+    helper.setIfAbsent(LruBlockCacheConfiguration.EVICTION_THREAD_PROPERTY, Boolean.FALSE.toString());
     factory.start(helper.getConfiguration());
     LruBlockCache cache = (LruBlockCache) factory.getBlockCache(CacheType.INDEX);
 
@@ -183,12 +183,12 @@ public class TestLruBlockCache extends TestCase {
     cc.set(Property.TSERV_DEFAULT_BLOCKSIZE, Long.toString(blockSize));
     cc.set(Property.TSERV_INDEXCACHE_SIZE, Long.toString(maxSize));
     BlockCacheConfigurationHelper helper = new BlockCacheConfigurationHelper(cc, CacheType.INDEX,
factory.getCacheImplName());
-    helper.set(LruBlockCacheConfiguration.EVICTION_THREAD_PROPERTY, Boolean.FALSE.toString());
-    helper.set(LruBlockCacheConfiguration.MIN_FACTOR_PROPERTY, Float.toString(0.98f));
-    helper.set(LruBlockCacheConfiguration.ACCEPTABLE_FACTOR_PROPERTY, Float.toString(0.99f));
-    helper.set(LruBlockCacheConfiguration.SINGLE_FACTOR_PROPERTY, Float.toString(0.25f));
-    helper.set(LruBlockCacheConfiguration.MULTI_FACTOR_PROPERTY, Float.toString(0.50f));
-    helper.set(LruBlockCacheConfiguration.MEMORY_FACTOR_PROPERTY, Float.toString(0.25f));
+    helper.setIfAbsent(LruBlockCacheConfiguration.EVICTION_THREAD_PROPERTY, Boolean.FALSE.toString());
+    helper.setIfAbsent(LruBlockCacheConfiguration.MIN_FACTOR_PROPERTY, Float.toString(0.98f));
+    helper.setIfAbsent(LruBlockCacheConfiguration.ACCEPTABLE_FACTOR_PROPERTY, Float.toString(0.99f));
+    helper.setIfAbsent(LruBlockCacheConfiguration.SINGLE_FACTOR_PROPERTY, Float.toString(0.25f));
+    helper.setIfAbsent(LruBlockCacheConfiguration.MULTI_FACTOR_PROPERTY, Float.toString(0.50f));
+    helper.setIfAbsent(LruBlockCacheConfiguration.MEMORY_FACTOR_PROPERTY, Float.toString(0.25f));
     factory.start(helper.getConfiguration());
     LruBlockCache cache = (LruBlockCache) factory.getBlockCache(CacheType.INDEX);
 
@@ -251,12 +251,12 @@ public class TestLruBlockCache extends TestCase {
     cc.set(Property.TSERV_DEFAULT_BLOCKSIZE, Long.toString(blockSize));
     cc.set(Property.TSERV_INDEXCACHE_SIZE, Long.toString(maxSize));
     BlockCacheConfigurationHelper helper = new BlockCacheConfigurationHelper(cc, CacheType.INDEX,
factory.getCacheImplName());
-    helper.set(LruBlockCacheConfiguration.EVICTION_THREAD_PROPERTY, Boolean.FALSE.toString());
-    helper.set(LruBlockCacheConfiguration.MIN_FACTOR_PROPERTY, Float.toString(0.98f));
-    helper.set(LruBlockCacheConfiguration.ACCEPTABLE_FACTOR_PROPERTY, Float.toString(0.99f));
-    helper.set(LruBlockCacheConfiguration.SINGLE_FACTOR_PROPERTY, Float.toString(0.33f));
-    helper.set(LruBlockCacheConfiguration.MULTI_FACTOR_PROPERTY, Float.toString(0.33f));
-    helper.set(LruBlockCacheConfiguration.MEMORY_FACTOR_PROPERTY, Float.toString(0.34f));
+    helper.setIfAbsent(LruBlockCacheConfiguration.EVICTION_THREAD_PROPERTY, Boolean.FALSE.toString());
+    helper.setIfAbsent(LruBlockCacheConfiguration.MIN_FACTOR_PROPERTY, Float.toString(0.98f));
+    helper.setIfAbsent(LruBlockCacheConfiguration.ACCEPTABLE_FACTOR_PROPERTY, Float.toString(0.99f));
+    helper.setIfAbsent(LruBlockCacheConfiguration.SINGLE_FACTOR_PROPERTY, Float.toString(0.33f));
+    helper.setIfAbsent(LruBlockCacheConfiguration.MULTI_FACTOR_PROPERTY, Float.toString(0.33f));
+    helper.setIfAbsent(LruBlockCacheConfiguration.MEMORY_FACTOR_PROPERTY, Float.toString(0.34f));
     factory.start(helper.getConfiguration());
     LruBlockCache cache = (LruBlockCache) factory.getBlockCache(CacheType.INDEX);
 
@@ -378,13 +378,13 @@ public class TestLruBlockCache extends TestCase {
     cc.set(Property.TSERV_DEFAULT_BLOCKSIZE, Long.toString(blockSize));
     cc.set(Property.TSERV_INDEXCACHE_SIZE, Long.toString(maxSize));
     BlockCacheConfigurationHelper helper = new BlockCacheConfigurationHelper(cc, CacheType.INDEX,
factory.getCacheImplName());
-    helper.set(LruBlockCacheConfiguration.EVICTION_THREAD_PROPERTY, Boolean.FALSE.toString());
-    helper.set(LruBlockCacheConfiguration.EVICTION_THREAD_PROPERTY, Boolean.FALSE.toString());
-    helper.set(LruBlockCacheConfiguration.MIN_FACTOR_PROPERTY, Float.toString(0.66f));
-    helper.set(LruBlockCacheConfiguration.ACCEPTABLE_FACTOR_PROPERTY, Float.toString(0.99f));
-    helper.set(LruBlockCacheConfiguration.SINGLE_FACTOR_PROPERTY, Float.toString(0.33f));
-    helper.set(LruBlockCacheConfiguration.MULTI_FACTOR_PROPERTY, Float.toString(0.33f));
-    helper.set(LruBlockCacheConfiguration.MEMORY_FACTOR_PROPERTY, Float.toString(0.34f));
+    helper.setIfAbsent(LruBlockCacheConfiguration.EVICTION_THREAD_PROPERTY, Boolean.FALSE.toString());
+    helper.setIfAbsent(LruBlockCacheConfiguration.EVICTION_THREAD_PROPERTY, Boolean.FALSE.toString());
+    helper.setIfAbsent(LruBlockCacheConfiguration.MIN_FACTOR_PROPERTY, Float.toString(0.66f));
+    helper.setIfAbsent(LruBlockCacheConfiguration.ACCEPTABLE_FACTOR_PROPERTY, Float.toString(0.99f));
+    helper.setIfAbsent(LruBlockCacheConfiguration.SINGLE_FACTOR_PROPERTY, Float.toString(0.33f));
+    helper.setIfAbsent(LruBlockCacheConfiguration.MULTI_FACTOR_PROPERTY, Float.toString(0.33f));
+    helper.setIfAbsent(LruBlockCacheConfiguration.MEMORY_FACTOR_PROPERTY, Float.toString(0.34f));
     factory.start(helper.getConfiguration());
     LruBlockCache cache = (LruBlockCache) factory.getBlockCache(CacheType.INDEX);
 

http://git-wip-us.apache.org/repos/asf/accumulo/blob/d98fba14/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServerResourceManager.java
----------------------------------------------------------------------
diff --git a/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServerResourceManager.java
b/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServerResourceManager.java
index 402639f..4e79eea 100644
--- a/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServerResourceManager.java
+++ b/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServerResourceManager.java
@@ -99,7 +99,7 @@ public class TabletServerResourceManager {
 
   private final MemoryManagementFramework memMgmt;
 
-  private final BlockCacheManager factory;
+  private final BlockCacheManager cacheManager;
   private final BlockCache _dCache;
   private final BlockCache _iCache;
   private final BlockCache _sCache;
@@ -176,16 +176,16 @@ public class TabletServerResourceManager {
     long totalQueueSize = acuConf.getAsBytes(Property.TSERV_TOTAL_MUTATION_QUEUE_MAX);
 
     try {
-      factory = BlockCacheManager.getInstance(acuConf);
+      cacheManager = BlockCacheManager.getInstance(acuConf);
     } catch (Exception e) {
       throw new RuntimeException("Error creating BlockCacheFactory", e);
     }
 
-    factory.start(acuConf);
+    cacheManager.start(acuConf);
 
-    _iCache = factory.getBlockCache(CacheType.INDEX);
-    _dCache = factory.getBlockCache(CacheType.DATA);
-    _sCache = factory.getBlockCache(CacheType.SUMMARY);
+    _iCache = cacheManager.getBlockCache(CacheType.INDEX);
+    _dCache = cacheManager.getBlockCache(CacheType.DATA);
+    _sCache = cacheManager.getBlockCache(CacheType.SUMMARY);
 
     Runtime runtime = Runtime.getRuntime();
     if (usingNativeMap) {
@@ -542,7 +542,11 @@ public class TabletServerResourceManager {
       executorService.shutdown();
     }
 
-    this.factory.stop();
+    try {
+	  this.cacheManager.stop();
+	} catch (Exception ex) {
+	  log.error("Error stopping BlockCacheManager", ex);
+	}
 
     for (Entry<String,ExecutorService> entry : threadPools.entrySet()) {
       while (true) {


Mime
View raw message