accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mwa...@apache.org
Subject [accumulo] 01/03: Fixes #725 - Log deprecated properties (#726)
Date Tue, 30 Oct 2018 19:51:48 GMT
This is an automated email from the ASF dual-hosted git repository.

mwalch pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/accumulo.git

commit 16722b17b0f04aff726be3bd222b4ed2f72a43b0
Author: Michael Schnitzler <schnitzler.michael+github@gmail.com>
AuthorDate: Fri Oct 26 12:25:38 2018 +0200

    Fixes #725 - Log deprecated properties (#726)
---
 .../accumulo/core/conf/ConfigSanityCheck.java      | 14 +++++--
 .../org/apache/accumulo/core/conf/Property.java    | 46 ++++++++++++++--------
 .../org/apache/accumulo/core/conf/ReplacedBy.java  | 33 ++++++++++++++++
 3 files changed, 73 insertions(+), 20 deletions(-)

diff --git a/core/src/main/java/org/apache/accumulo/core/conf/ConfigSanityCheck.java b/core/src/main/java/org/apache/accumulo/core/conf/ConfigSanityCheck.java
index 1e0d43b..8073d8c 100644
--- a/core/src/main/java/org/apache/accumulo/core/conf/ConfigSanityCheck.java
+++ b/core/src/main/java/org/apache/accumulo/core/conf/ConfigSanityCheck.java
@@ -66,6 +66,16 @@ public class ConfigSanityCheck {
         fatal(PREFIX + "improperly formatted value for key (" + key + ", type=" + prop.getType()
             + ") : " + value);
 
+      if (prop!=null) { 
+          if (prop.hasAnnotation(Deprecated.class)) {
+            log.warn("Use of {} is deprecated.", key);
+          }
+          ReplacedBy replacedBy = prop.getAnnotation(ReplacedBy.class);
+          if (replacedBy != null) {
+            log.warn("Consider using {} instead of {}.", replacedBy.replacedByProperty(),
key);
+          }
+      }
+
       if (key.equals(Property.INSTANCE_ZK_TIMEOUT.getKey())) {
         instanceZkTimeoutValue = value;
       }
@@ -94,10 +104,6 @@ public class ConfigSanityCheck {
           new CheckTimeDurationBetween(1000, 300000));
     }
 
-    if (!usingVolumes) {
-      log.warn("Use of {} and {} are deprecated. Consider using {} instead.", INSTANCE_DFS_URI,
-          INSTANCE_DFS_DIR, Property.INSTANCE_VOLUMES);
-    }
   }
 
   private interface CheckTimeDuration {
diff --git a/core/src/main/java/org/apache/accumulo/core/conf/Property.java b/core/src/main/java/org/apache/accumulo/core/conf/Property.java
index 5272646..2e919be 100644
--- a/core/src/main/java/org/apache/accumulo/core/conf/Property.java
+++ b/core/src/main/java/org/apache/accumulo/core/conf/Property.java
@@ -96,21 +96,6 @@ public enum Property {
       "Zookeeper session timeout; "
           + "max value when represented as milliseconds should be no larger than "
           + Integer.MAX_VALUE),
-  @Deprecated
-  INSTANCE_DFS_URI("instance.dfs.uri", "", PropertyType.URI,
-      "This property is deprecated since 1.6.0. "
-          + "A url accumulo should use to connect to DFS. If this is empty, accumulo"
-          + " will obtain this information from the hadoop configuration. This property"
-          + " will only be used when creating new files if instance.volumes is empty."
-          + " After an upgrade to 1.6.0 Accumulo will start using absolute paths to"
-          + " reference files. Files created before a 1.6.0 upgrade are referenced via"
-          + " relative paths. Relative paths will always be resolved using this config"
-          + " (if empty using the hadoop config)."),
-  @Deprecated
-  INSTANCE_DFS_DIR("instance.dfs.dir", "/accumulo", PropertyType.ABSOLUTEPATH,
-      "This property is deprecated since 1.6.0. "
-          + "HDFS directory in which accumulo instance will run. "
-          + "Do not change after accumulo is initialized."),
   @Sensitive
   INSTANCE_SECRET("instance.secret", "DEFAULT", PropertyType.STRING,
       "A secret unique to a given instance that all servers must know in order"
@@ -131,6 +116,23 @@ public enum Property {
           + " reference files created at that location before the config change. To use"
           + " a comma or other reserved characters in a URI use standard URI hex"
           + " encoding. For example replace commas with %2C."),
+  @Deprecated
+  @ReplacedBy(replacedByProperty=INSTANCE_VOLUMES)
+  INSTANCE_DFS_URI("instance.dfs.uri", "", PropertyType.URI,
+		  "This property is deprecated since 1.6.0. "
+				  + "A url accumulo should use to connect to DFS. If this is empty, accumulo"
+				  + " will obtain this information from the hadoop configuration. This property"
+				  + " will only be used when creating new files if instance.volumes is empty."
+				  + " After an upgrade to 1.6.0 Accumulo will start using absolute paths to"
+				  + " reference files. Files created before a 1.6.0 upgrade are referenced via"
+				  + " relative paths. Relative paths will always be resolved using this config"
+				  + " (if empty using the hadoop config)."),
+  @Deprecated
+  @ReplacedBy(replacedByProperty=INSTANCE_VOLUMES)
+  INSTANCE_DFS_DIR("instance.dfs.dir", "/accumulo", PropertyType.ABSOLUTEPATH,
+		  "This property is deprecated since 1.6.0. "
+				  + "HDFS directory in which accumulo instance will run. "
+				  + "Do not change after accumulo is initialized."),
   INSTANCE_VOLUMES_REPLACEMENTS("instance.volumes.replacements", "", PropertyType.STRING,
       "Since accumulo stores absolute URIs changing the location of a namenode "
           + "could prevent Accumulo from starting. The property helps deal with "
@@ -1077,7 +1079,7 @@ public enum Property {
     return false;
   }
 
-  private <T extends Annotation> boolean hasAnnotation(Class<T> annotationType)
{
+  public <T extends Annotation> boolean hasAnnotation(Class<T> annotationType)
{
     Logger log = LoggerFactory.getLogger(getClass());
     try {
       for (Annotation a : getClass().getField(name()).getAnnotations())
@@ -1089,6 +1091,18 @@ public enum Property {
     return false;
   }
 
+  public <T extends Annotation> T getAnnotation(Class<T> annotationType) {
+	    Logger log = LoggerFactory.getLogger(getClass());
+	    try {
+	      for (Annotation a : getClass().getField(name()).getAnnotations())
+	        if (annotationType.isInstance(a))
+	          return (T) a;
+	    } catch (SecurityException | NoSuchFieldException e) {
+	      log.error("{}", e.getMessage(), e);
+	    }
+	    return null;
+	  }
+
   private static <T extends Annotation> boolean hasPrefixWithAnnotation(String key,
       Class<T> annotationType) {
     for (String prefix : validPrefixes) {
diff --git a/core/src/main/java/org/apache/accumulo/core/conf/ReplacedBy.java b/core/src/main/java/org/apache/accumulo/core/conf/ReplacedBy.java
new file mode 100644
index 0000000..6d5e525
--- /dev/null
+++ b/core/src/main/java/org/apache/accumulo/core/conf/ReplacedBy.java
@@ -0,0 +1,33 @@
+/*
+ * 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.conf;
+
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * An annotation to denote that an {@link AccumuloConfiguration} {@link Property} key is
replaced by
+ * a different {@link AccumuloConfiguration} {@link Property} key. This usually means that
the
+ * {@link AccumuloConfiguration} {@link Property} key is {@link Deprecated}.
+ */
+@Inherited
+@Retention(RetentionPolicy.RUNTIME)
+@interface ReplacedBy {
+
+  Property replacedByProperty();
+}


Mime
View raw message