You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tez.apache.org by ab...@apache.org on 2024/12/30 16:48:03 UTC
(tez) branch master updated: TEZ-4387: use new doclet API in Java 9+ (#296) (Laszlo Bodor Co-authored-by Laszlo Attila Toth, reviewed by Ayush Saxena)
This is an automated email from the ASF dual-hosted git repository.
abstractdog pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tez.git
The following commit(s) were added to refs/heads/master by this push:
new c7a3791e9 TEZ-4387: use new doclet API in Java 9+ (#296) (Laszlo Bodor Co-authored-by Laszlo Attila Toth, reviewed by Ayush Saxena)
c7a3791e9 is described below
commit c7a3791e971e30b47ce3a4a465e507a43f609ade
Author: Bodor Laszlo <bo...@gmail.com>
AuthorDate: Mon Dec 30 17:47:58 2024 +0100
TEZ-4387: use new doclet API in Java 9+ (#296) (Laszlo Bodor Co-authored-by Laszlo Attila Toth, reviewed by Ayush Saxena)
---
pom.xml | 1 +
tez-tools/tez-javadoc-tools/findbugs-exclude.xml | 12 +
tez-tools/tez-javadoc-tools/pom.xml | 56 ++++
.../tools/javadoc/doclet/ConfigStandardDoclet.java | 291 +++++++++++++++++++++
.../tez/tools/javadoc/doclet/package-info.java} | 24 +-
.../apache/tez/tools/javadoc/model/Config.java} | 53 ++--
.../tez/tools/javadoc/model/ConfigProperty.java | 115 ++++++++
.../tez/tools/javadoc/model/package-info.java} | 22 +-
.../apache/tez/tools/javadoc/util/HtmlWriter.java | 54 ++--
.../org/apache/tez/tools/javadoc/util/Writer.java | 11 +-
.../apache/tez/tools/javadoc/util/XmlWriter.java | 37 +--
.../tez/tools/javadoc/util/package-info.java} | 21 +-
.../tools/javadoc/doclet/ConfigStandardDoclet.java | 85 +++---
.../tez/tools/javadoc/doclet/package-info.java} | 24 +-
.../org/apache/tez/tools/javadoc/model/Config.java | 23 +-
.../tez/tools/javadoc/model/ConfigProperty.java | 115 ++++++++
.../tez/tools/javadoc/model/package-info.java} | 22 +-
.../apache/tez/tools/javadoc/util/HtmlWriter.java | 43 ++-
.../org/apache/tez/tools/javadoc/util/Writer.java | 4 +-
.../apache/tez/tools/javadoc/util/XmlWriter.java | 33 ++-
.../tez/tools/javadoc/util/package-info.java} | 21 +-
21 files changed, 778 insertions(+), 289 deletions(-)
diff --git a/pom.xml b/pom.xml
index 12fc40891..14cc41ec9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1385,6 +1385,7 @@
</profile>
</profiles>
+ <!-- TODO: TEZ-4597: IncludePublicAnnotationsStandardDoclet is not JDK9+ compatible -->
<reporting>
<plugins>
<plugin>
diff --git a/tez-tools/tez-javadoc-tools/findbugs-exclude.xml b/tez-tools/tez-javadoc-tools/findbugs-exclude.xml
index ad8f6e4ce..d21aa3631 100644
--- a/tez-tools/tez-javadoc-tools/findbugs-exclude.xml
+++ b/tez-tools/tez-javadoc-tools/findbugs-exclude.xml
@@ -13,6 +13,18 @@
-->
<FindBugsFilter>
+ <Match>
+ <Class name="org.apache.tez.tools.javadoc.model.ConfigProperty"/>
+ <Field name="description"/>
+ <Bug pattern="UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD"/>
+ </Match>
+
+ <Match>
+ <Class name="org.apache.tez.tools.javadoc.model.ConfigProperty"/>
+ <Field name="validValues"/>
+ <Bug pattern="UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD"/>
+ </Match>
+
<Match>
<Class name="org.apache.tez.tools.javadoc.model.ConfigProperty"/>
<Field name="validValues"/>
diff --git a/tez-tools/tez-javadoc-tools/pom.xml b/tez-tools/tez-javadoc-tools/pom.xml
index 1ef4d1308..4ef89b691 100644
--- a/tez-tools/tez-javadoc-tools/pom.xml
+++ b/tez-tools/tez-javadoc-tools/pom.xml
@@ -78,6 +78,62 @@
</dependency>
</dependencies>
</profile>
+
+ <profile>
+ <id>java8-16</id>
+ <activation>
+ <jdk>[1.8,16]</jdk>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>add-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>src/main/java-8-16</source>
+ </sources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+
+ <profile>
+ <id>java17</id>
+ <activation>
+ <jdk>[17,)</jdk>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>add-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>src/main/java-17</source>
+ </sources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
</profiles>
diff --git a/tez-tools/tez-javadoc-tools/src/main/java-17/org/apache/tez/tools/javadoc/doclet/ConfigStandardDoclet.java b/tez-tools/tez-javadoc-tools/src/main/java-17/org/apache/tez/tools/javadoc/doclet/ConfigStandardDoclet.java
new file mode 100644
index 000000000..bd321475c
--- /dev/null
+++ b/tez-tools/tez-javadoc-tools/src/main/java-17/org/apache/tez/tools/javadoc/doclet/ConfigStandardDoclet.java
@@ -0,0 +1,291 @@
+/**
+ * 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.tez.tools.javadoc.doclet;
+
+import com.sun.source.util.DocTrees;
+import jdk.javadoc.doclet.Doclet;
+import jdk.javadoc.doclet.DocletEnvironment;
+import jdk.javadoc.doclet.Reporter;
+import org.apache.hadoop.classification.InterfaceAudience.Private;
+import org.apache.hadoop.classification.InterfaceStability.Evolving;
+import org.apache.hadoop.classification.InterfaceStability.Unstable;
+import org.apache.tez.common.annotation.ConfigurationClass;
+import org.apache.tez.common.annotation.ConfigurationProperty;
+import org.apache.tez.tools.javadoc.model.Config;
+import org.apache.tez.tools.javadoc.model.ConfigProperty;
+import org.apache.tez.tools.javadoc.util.HtmlWriter;
+import org.apache.tez.tools.javadoc.util.XmlWriter;
+
+import javax.lang.model.SourceVersion;
+import javax.lang.model.element.AnnotationMirror;
+import javax.lang.model.element.AnnotationValue;
+import javax.lang.model.element.Element;
+import javax.lang.model.element.ElementKind;
+import javax.lang.model.element.ExecutableElement;
+import javax.lang.model.element.Modifier;
+import javax.lang.model.element.TypeElement;
+import javax.lang.model.element.VariableElement;
+import javax.tools.Diagnostic;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
+
+public class ConfigStandardDoclet implements Doclet {
+
+ private static boolean debugMode = false;
+
+ private Reporter reporter;
+
+ private static String stripQuotes(String s) {
+ if (s.charAt(0) == '"' && s.charAt(s.length() - 1) == '"') {
+ return s.substring(1, s.length() - 1);
+ }
+ return s;
+ }
+
+ @Override
+ public void init(Locale locale, Reporter reporter) {
+ this.reporter = reporter;
+ }
+
+ @Override
+ public String getName() {
+ return "Tez";
+ }
+
+ @Override
+ public SourceVersion getSupportedSourceVersion() {
+ return SourceVersion.RELEASE_9;
+ }
+
+ private void logMessage(String message) {
+ if (!debugMode) {
+ return;
+ }
+ reporter.print(Diagnostic.Kind.NOTE, message);
+ }
+
+ @Override
+ public boolean run(DocletEnvironment docEnv) {
+ logMessage("Running doclet " + ConfigStandardDoclet.class.getSimpleName());
+ DocTrees docTrees = docEnv.getDocTrees();
+ for (Element element : docEnv.getIncludedElements()) {
+ if (element.getKind().equals(ElementKind.CLASS) && element instanceof TypeElement) {
+ processDoc(docTrees, (TypeElement) element);
+ }
+ }
+
+ return true;
+ }
+
+ private void processDoc(DocTrees docTrees, TypeElement doc) {
+ logMessage("Parsing : " + doc);
+ if (!doc.getKind().equals(ElementKind.CLASS)) {
+ logMessage("Ignoring non-class: " + doc);
+ return;
+ }
+
+ List<? extends AnnotationMirror> annotations = doc.getAnnotationMirrors();
+ boolean isConfigClass = false;
+ String templateName = null;
+ for (AnnotationMirror annotation : annotations) {
+ logMessage("Checking annotation: " + annotation.getAnnotationType());
+ if (annotation.getAnnotationType().asElement().toString().equals(
+ ConfigurationClass.class.getName())) {
+ isConfigClass = true;
+ Map<? extends ExecutableElement, ? extends AnnotationValue> elementValues = annotation.getElementValues();
+ for (Map.Entry<? extends ExecutableElement, ? extends AnnotationValue> element : elementValues.entrySet()) {
+ if (element.getKey().getSimpleName().toString().equals("templateFileName")) {
+ templateName = stripQuotes(element.getValue().getValue().toString());
+ }
+ }
+ break;
+ }
+ }
+
+ if (!isConfigClass) {
+ logMessage("Ignoring non-config class: " + doc);
+ return;
+ }
+
+ logMessage("Processing config class: " + doc);
+ Config config = new Config(doc.getSimpleName().toString(), templateName);
+ Map<String, ConfigProperty> configProperties = config.getConfigProperties();
+
+ processElements(docTrees, doc, configProperties);
+
+ HtmlWriter writer = new HtmlWriter();
+ try {
+ writer.write(config);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+
+ XmlWriter xmlWriter = new XmlWriter();
+ try {
+ xmlWriter.write(config);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private void processElements(DocTrees docTrees, TypeElement doc, Map<String, ConfigProperty> configProperties) {
+ List<? extends Element> elements = doc.getEnclosedElements();
+ for (Element f : elements) {
+ if (!(f instanceof VariableElement)) {
+ continue;
+ }
+
+ if (!f.getKind().equals(ElementKind.FIELD)) {
+ continue;
+ }
+
+ VariableElement field = (VariableElement) f;
+
+ if (field.getModifiers().contains(Modifier.PRIVATE)) {
+ logMessage("Skipping private field: " + field);
+ continue;
+ }
+ if (field.getModifiers().contains(Modifier.STATIC)) {
+ logMessage("Skipping non-static field: " + field);
+ continue;
+ }
+
+ String fieldName = field.getSimpleName().toString();
+ if (fieldName.endsWith("_PREFIX")) {
+ logMessage("Skipping non-config prefix constant field: " + field);
+ continue;
+ }
+ if (fieldName.equals("TEZ_SITE_XML")) {
+ logMessage("Skipping constant field: " + field);
+ continue;
+ }
+
+ if (fieldName.endsWith("_DEFAULT")) {
+
+ String name = fieldName.substring(0, fieldName.lastIndexOf("_DEFAULT"));
+ if (!configProperties.containsKey(name)) {
+ configProperties.put(name, new ConfigProperty());
+ }
+ ConfigProperty configProperty = configProperties.get(name);
+ if (field.getConstantValue() == null) {
+ String val = field.getConstantValue().toString();
+ logMessage("Got null constant value"
+ + ", name=" + name
+ + ", field=" + fieldName
+ + ", val=" + val);
+ configProperty.setDefaultValue(val);
+ } else {
+ configProperty.setDefaultValue(field.getConstantValue().toString());
+ }
+ configProperty.setInferredType(field.getSimpleName().toString());
+
+ if (name.equals("TEZ_AM_STAGING_DIR") && configProperty.getDefaultValue() != null) {
+ String defaultValue = configProperty.getDefaultValue();
+ defaultValue = defaultValue.replace(System.getProperty("user.name"), "${user.name}");
+ configProperty.setDefaultValue(defaultValue);
+ }
+
+ continue;
+ }
+
+ if (!configProperties.containsKey(fieldName)) {
+ configProperties.put(fieldName, new ConfigProperty());
+ }
+ ConfigProperty configProperty = configProperties.get(fieldName);
+ configProperty.setPropertyName(field.getConstantValue().toString());
+
+ List<? extends AnnotationMirror> annotationDescs = field.getAnnotationMirrors();
+
+ for (AnnotationMirror annotationDesc : annotationDescs) {
+ String elementFqName = annotationDesc.getAnnotationType().asElement().toString();
+ if (elementFqName.equals(Private.class.getCanonicalName())) {
+ configProperty.setPrivate(true);
+ }
+ if (elementFqName.equals(Unstable.class.getCanonicalName())) {
+ configProperty.setUnstable(true);
+ }
+ if (elementFqName.equals(Evolving.class.getCanonicalName())) {
+ configProperty.setEvolving(true);
+ }
+ if (elementFqName.equals(ConfigurationProperty.class.getCanonicalName())) {
+ configProperty.setValidConfigProp(true);
+
+ for (Map.Entry<? extends ExecutableElement, ? extends AnnotationValue> element
+ : annotationDesc.getElementValues().entrySet()) {
+ if (element.getKey().getSimpleName().toString().equals("type")) {
+ configProperty.setType(stripQuotes(element.getValue().getValue().toString()));
+ } else {
+ logMessage("Unhandled annotation property: " + element.getKey().getSimpleName());
+ }
+ }
+ }
+ }
+ configProperty.setDescription(docTrees.getDocCommentTree(field).getFullBody().toString());
+ }
+ }
+
+ @Override
+ public Set<? extends Option> getSupportedOptions() {
+ Option[] options = {
+ new Option() {
+ private final List<String> someOption = Arrays.asList(
+ "-debug",
+ "--debug"
+ );
+
+ @Override
+ public int getArgumentCount() {
+ return 0;
+ }
+
+ @Override
+ public String getDescription() {
+ return "Debug mode";
+ }
+
+ @Override
+ public Option.Kind getKind() {
+ return Kind.STANDARD;
+ }
+
+ @Override
+ public List<String> getNames() {
+ return someOption;
+ }
+
+ @Override
+ public String getParameters() {
+ return "";
+ }
+
+ @Override
+ public boolean process(String opt, List<String> arguments) {
+ debugMode = true;
+ return true;
+ }
+ }
+ };
+ return new HashSet<>(Arrays.asList(options));
+ }
+}
diff --git a/tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/model/Config.java b/tez-tools/tez-javadoc-tools/src/main/java-17/org/apache/tez/tools/javadoc/doclet/package-info.java
similarity index 62%
copy from tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/model/Config.java
copy to tez-tools/tez-javadoc-tools/src/main/java-17/org/apache/tez/tools/javadoc/doclet/package-info.java
index 604d48ac5..190ae4622 100644
--- a/tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/model/Config.java
+++ b/tez-tools/tez-javadoc-tools/src/main/java-17/org/apache/tez/tools/javadoc/doclet/package-info.java
@@ -16,25 +16,7 @@
* limitations under the License.
*/
-package org.apache.tez.tools.javadoc.model;
+@Private
+package org.apache.tez.tools.javadoc.doclet;
-import java.util.Map;
-import java.util.TreeMap;
-
-public class Config {
-
- public final String templateName;
- public final String configName;
- public Map<String, ConfigProperty> configProperties;
-
- public Config(String configName, String templateName) {
- this.configName = configName;
- this.templateName = templateName;
- this.configProperties = new TreeMap<String, ConfigProperty>();
- }
-
- public Config() {
- this(null, null);
- }
-
-}
+import org.apache.hadoop.classification.InterfaceAudience.Private;
\ No newline at end of file
diff --git a/tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/model/ConfigProperty.java b/tez-tools/tez-javadoc-tools/src/main/java-17/org/apache/tez/tools/javadoc/model/Config.java
similarity index 53%
rename from tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/model/ConfigProperty.java
rename to tez-tools/tez-javadoc-tools/src/main/java-17/org/apache/tez/tools/javadoc/model/Config.java
index 89490c4a5..d5121aaad 100644
--- a/tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/model/ConfigProperty.java
+++ b/tez-tools/tez-javadoc-tools/src/main/java-17/org/apache/tez/tools/javadoc/model/Config.java
@@ -18,30 +18,35 @@
package org.apache.tez.tools.javadoc.model;
-public class ConfigProperty {
-
- public String propertyName;
- public String defaultValue;
- public String description;
- public String type = "string";
- public boolean isPrivate = false;
- public boolean isUnstable = false;
- public boolean isEvolving = false;
- public boolean isValidConfigProp = false;
- public String[] validValues;
- public String inferredType;
-
- @Override
- public String toString() {
- return "name=" + propertyName
- + ", defaultValue=" + defaultValue
- + ", description=" + description
- + ", type=" + type
- + ", inferredType=" + inferredType
- + ", private=" + isPrivate
- + ", validValues=" + (validValues == null ? "null" : validValues)
- + ", isConfigProp=" + isValidConfigProp;
+import java.util.Map;
+import java.util.TreeMap;
+
+public class Config {
+
+ private final String templateName;
+ private final String configName;
+ private Map<String, ConfigProperty> configProperties;
+
+ public Config(String configName, String templateName) {
+ this.configName = configName;
+ this.templateName = templateName;
+ this.setConfigProperties(new TreeMap<String, ConfigProperty>());
}
-}
+ public String getTemplateName() {
+ return templateName;
+ }
+ public String getConfigName() {
+ return configName;
+ }
+
+ public Map<String, ConfigProperty> getConfigProperties() {
+ return configProperties;
+ }
+
+ public void setConfigProperties(
+ Map<String, ConfigProperty> configProperties) {
+ this.configProperties = configProperties;
+ }
+}
diff --git a/tez-tools/tez-javadoc-tools/src/main/java-17/org/apache/tez/tools/javadoc/model/ConfigProperty.java b/tez-tools/tez-javadoc-tools/src/main/java-17/org/apache/tez/tools/javadoc/model/ConfigProperty.java
new file mode 100644
index 000000000..27208de55
--- /dev/null
+++ b/tez-tools/tez-javadoc-tools/src/main/java-17/org/apache/tez/tools/javadoc/model/ConfigProperty.java
@@ -0,0 +1,115 @@
+/**
+ * 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.tez.tools.javadoc.model;
+
+public class ConfigProperty {
+
+ private String propertyName;
+ private String defaultValue;
+ private String description;
+ private String type = "string";
+ private boolean isPrivate = false;
+ private boolean isUnstable = false;
+ private boolean isEvolving = false;
+ private boolean isValidConfigProp = false;
+ private String inferredType;
+
+ public String getPropertyName() {
+ return propertyName;
+ }
+
+ public void setPropertyName(String propertyName) {
+ this.propertyName = propertyName;
+ }
+
+ public String getDefaultValue() {
+ return defaultValue;
+ }
+
+ public void setDefaultValue(String defaultValue) {
+ this.defaultValue = defaultValue;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public boolean isPrivate() {
+ return isPrivate;
+ }
+
+ public void setPrivate(boolean aPrivate) {
+ isPrivate = aPrivate;
+ }
+
+ public boolean isUnstable() {
+ return isUnstable;
+ }
+
+ public void setUnstable(boolean unstable) {
+ isUnstable = unstable;
+ }
+
+ public boolean isEvolving() {
+ return isEvolving;
+ }
+
+ public void setEvolving(boolean evolving) {
+ isEvolving = evolving;
+ }
+
+ public boolean isValidConfigProp() {
+ return isValidConfigProp;
+ }
+
+ public void setValidConfigProp(boolean validConfigProp) {
+ isValidConfigProp = validConfigProp;
+ }
+
+ public String getInferredType() {
+ return inferredType;
+ }
+
+ public void setInferredType(String inferredType) {
+ this.inferredType = inferredType;
+ }
+
+ @Override
+ public String toString() {
+ return "name=" + getPropertyName()
+ + ", defaultValue=" + getDefaultValue()
+ + ", description=" + getDescription()
+ + ", type=" + getType()
+ + ", inferredType=" + getInferredType()
+ + ", private=" + isPrivate()
+ + ", isConfigProp=" + isValidConfigProp();
+ }
+}
diff --git a/tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/model/Config.java b/tez-tools/tez-javadoc-tools/src/main/java-17/org/apache/tez/tools/javadoc/model/package-info.java
similarity index 65%
copy from tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/model/Config.java
copy to tez-tools/tez-javadoc-tools/src/main/java-17/org/apache/tez/tools/javadoc/model/package-info.java
index 604d48ac5..76acd0525 100644
--- a/tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/model/Config.java
+++ b/tez-tools/tez-javadoc-tools/src/main/java-17/org/apache/tez/tools/javadoc/model/package-info.java
@@ -16,25 +16,7 @@
* limitations under the License.
*/
+@Private
package org.apache.tez.tools.javadoc.model;
-import java.util.Map;
-import java.util.TreeMap;
-
-public class Config {
-
- public final String templateName;
- public final String configName;
- public Map<String, ConfigProperty> configProperties;
-
- public Config(String configName, String templateName) {
- this.configName = configName;
- this.templateName = templateName;
- this.configProperties = new TreeMap<String, ConfigProperty>();
- }
-
- public Config() {
- this(null, null);
- }
-
-}
+import org.apache.hadoop.classification.InterfaceAudience.Private;
\ No newline at end of file
diff --git a/tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/util/HtmlWriter.java b/tez-tools/tez-javadoc-tools/src/main/java-17/org/apache/tez/tools/javadoc/util/HtmlWriter.java
similarity index 73%
copy from tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/util/HtmlWriter.java
copy to tez-tools/tez-javadoc-tools/src/main/java-17/org/apache/tez/tools/javadoc/util/HtmlWriter.java
index 4b531e87e..9c512ee7f 100644
--- a/tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/util/HtmlWriter.java
+++ b/tez-tools/tez-javadoc-tools/src/main/java-17/org/apache/tez/tools/javadoc/util/HtmlWriter.java
@@ -18,17 +18,12 @@
package org.apache.tez.tools.javadoc.util;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStreamWriter;
-import java.io.PrintWriter;
-
-import org.apache.tez.dag.api.TezException;
import org.apache.tez.tools.javadoc.model.Config;
import org.apache.tez.tools.javadoc.model.ConfigProperty;
+import java.io.*;
+import java.nio.charset.StandardCharsets;
+
public class HtmlWriter extends Writer {
private static final String DEFAULT_STYLESHEET = "default-stylesheet.css";
@@ -36,13 +31,13 @@ public class HtmlWriter extends Writer {
public void write(Config config) throws IOException {
PrintWriter out = null;
- if (config.configName == null || config.configName.isEmpty()) {
+ if (config.getConfigName() == null || config.getConfigName().isEmpty()) {
throw new RuntimeException("Config Name is null or empty");
}
try {
- File file = new File(config.configName + ".html");
- out = new PrintWriter(new OutputStreamWriter(new FileOutputStream(file), "UTF-8"));
+ File file = new File(config.getConfigName() + ".html");
+ out = new PrintWriter(new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8));
out.println("<?xml version=\"1.0\" encoding=\"ISO-8859-1\" standalone=\"no\" ?>");
out.println("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"");
@@ -52,8 +47,7 @@ public class HtmlWriter extends Writer {
out.println("<head>");
out.println("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\" />");
- out.println("<title>"+ config.configName +"</title>");
-// out.println("<link rel='stylesheet' type='text/css' href=' " + config.getStyleSheet() + "'/>");
+ out.println("<title>" + config.getConfigName() + "</title>");
out.println("</head>");
out.println("<style>");
@@ -103,7 +97,7 @@ public class HtmlWriter extends Writer {
out.println("<div id=\"wrapper\">");
out.println("<div id=\"container\">");
- out.println("<h1>"+ config.configName +"</h1>");
+ out.println("<h1>" + config.getConfigName() + "</h1>");
out.println("<hr />");
out.println("<table>");
@@ -118,29 +112,33 @@ public class HtmlWriter extends Writer {
out.println("<th class=\"th_evolve_unstable\">" + "Is Evolving?" + "</th>");
out.println("</tr>");
- for (ConfigProperty configProperty : config.configProperties.values()) {
+ for (ConfigProperty configProperty : config.getConfigProperties().values()) {
if (!isValidConfigProperty(configProperty)) {
continue;
}
String altClass = "";
- if (configProperty.isPrivate) {
+ if (configProperty.isPrivate()) {
altClass = "class=\"tr_private\"";
- } else if (configProperty.isEvolving || configProperty.isUnstable) {
+ } else if (configProperty.isEvolving() || configProperty.isUnstable()) {
altClass = "class=\"tr_evolve_unstable\"";
}
out.println("<tr " + altClass + ">");
- out.println("<td>" + configProperty.propertyName + "</td>");
- out.println("<td>" + configProperty.defaultValue + "</td>");
- out.println("<td>" + configProperty.description + "</td>");
- out.println("<td>" + configProperty.type + "</td>");
- // Re-enable after adding values
- // out.println("<td>" + configProperty.validValues + "</td>");
-
- out.println("<td class=\"" + (configProperty.isPrivate? "td_private_true" : "td_private_false") + "\">" + configProperty.isPrivate + "</td>");
- out.println("<td class=\"" + (configProperty.isEvolving? "td_evolve_true" : "td_evolve_false") + "\">" + configProperty.isEvolving + "</td>");
- out.println("<td class=\"" + (configProperty.isUnstable? "td_unstable_true" : "td_unstable_false") + "\">" + configProperty.isUnstable + "</td>");
+ out.println("<td>" + configProperty.getPropertyName() + "</td>");
+ out.println("<td>" + configProperty.getDefaultValue() + "</td>");
+ out.println("<td>" + configProperty.getDescription() + "</td>");
+ out.println("<td>" + configProperty.getType() + "</td>");
+
+ out.println(
+ "<td class=\"" + (configProperty.isPrivate() ? "td_private_true" : "td_private_false") + "\">"
+ + configProperty.isPrivate() + "</td>");
+ out.println(
+ "<td class=\"" + (configProperty.isEvolving() ? "td_evolve_true" : "td_evolve_false") + "\">"
+ + configProperty.isEvolving() + "</td>");
+ out.println(
+ "<td class=\"" + (configProperty.isUnstable() ? "td_unstable_true" : "td_unstable_false") + "\">"
+ + configProperty.isUnstable() + "</td>");
out.println("</tr>");
}
@@ -150,12 +148,10 @@ public class HtmlWriter extends Writer {
out.println("</div>");
out.println("</body>");
out.println("</html>");
-
} finally {
if (out != null) {
out.close();
}
}
}
-
}
diff --git a/tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/util/Writer.java b/tez-tools/tez-javadoc-tools/src/main/java-17/org/apache/tez/tools/javadoc/util/Writer.java
similarity index 87%
copy from tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/util/Writer.java
copy to tez-tools/tez-javadoc-tools/src/main/java-17/org/apache/tez/tools/javadoc/util/Writer.java
index cfb0c9273..523f8cae9 100644
--- a/tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/util/Writer.java
+++ b/tez-tools/tez-javadoc-tools/src/main/java-17/org/apache/tez/tools/javadoc/util/Writer.java
@@ -18,22 +18,19 @@
package org.apache.tez.tools.javadoc.util;
-import java.io.IOException;
-
import org.apache.tez.tools.javadoc.model.Config;
import org.apache.tez.tools.javadoc.model.ConfigProperty;
+import java.io.IOException;
+
public abstract class Writer {
public abstract void write(Config config) throws IOException;
public boolean isValidConfigProperty(ConfigProperty configProperty) {
- if (!configProperty.isValidConfigProp) {
- return false;
- }
- if (configProperty.propertyName == null || configProperty.propertyName.isEmpty()) {
+ if (!configProperty.isValidConfigProp()) {
return false;
}
- return true;
+ return configProperty.getPropertyName() != null && !configProperty.getPropertyName().isEmpty();
}
}
diff --git a/tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/util/XmlWriter.java b/tez-tools/tez-javadoc-tools/src/main/java-17/org/apache/tez/tools/javadoc/util/XmlWriter.java
similarity index 68%
copy from tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/util/XmlWriter.java
copy to tez-tools/tez-javadoc-tools/src/main/java-17/org/apache/tez/tools/javadoc/util/XmlWriter.java
index e9bdeb399..591d82bc9 100644
--- a/tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/util/XmlWriter.java
+++ b/tez-tools/tez-javadoc-tools/src/main/java-17/org/apache/tez/tools/javadoc/util/XmlWriter.java
@@ -25,6 +25,8 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.tez.tools.javadoc.model.Config;
@@ -37,12 +39,12 @@ public class XmlWriter extends Writer {
public void write(Config config) throws IOException {
PrintWriter out = null;
- if (config.configName == null || config.configName.isEmpty()) {
+ if (config.getConfigName() == null || config.getConfigName().isEmpty()) {
throw new RuntimeException("Config Name is null or empty");
}
- String fileName = config.templateName == null ||
- config.templateName.isEmpty() ? config.configName : config.templateName;
+ String fileName = config.getTemplateName() == null ||
+ config.getTemplateName().isEmpty() ? config.getConfigName() : config.getTemplateName();
if (!fileName.endsWith(".xml")) {
fileName += ".xml";
}
@@ -51,7 +53,7 @@ public class XmlWriter extends Writer {
File file = new File(fileName);
writeApacheHeader(file);
- out = new PrintWriter(new OutputStreamWriter(new FileOutputStream(file, true), "UTF-8"));
+ out = new PrintWriter(new OutputStreamWriter(new FileOutputStream(file, true), StandardCharsets.UTF_8));
out.println("<?xml-stylesheet type=\"text/xsl\" href=\"configuration.xsl\"?>");
out.println();
@@ -60,30 +62,30 @@ public class XmlWriter extends Writer {
out.println();
out.println("<configuration>");
- for (ConfigProperty configProperty : config.configProperties.values()) {
+ for (ConfigProperty configProperty : config.getConfigProperties().values()) {
if (!isValidConfigProperty(configProperty)) {
continue;
}
out.println();
out.println(" <property>");
- out.println(" <name>" + configProperty.propertyName + "</name>");
- if (configProperty.defaultValue != null && !configProperty.defaultValue.isEmpty()) {
- out.println(" <defaultValue>" + configProperty.defaultValue + "</defaultValue>");
+ out.println(" <name>" + configProperty.getPropertyName() + "</name>");
+ if (configProperty.getDefaultValue() != null && !configProperty.getDefaultValue().isEmpty()) {
+ out.println(" <defaultValue>" + configProperty.getDefaultValue() + "</defaultValue>");
}
- if (configProperty.description != null && !configProperty.description.isEmpty()) {
- out.println(" <description>" + StringEscapeUtils.escapeXml(configProperty.description)
- + "</description>");
+ if (configProperty.getDescription() != null && !configProperty.getDescription().isEmpty()) {
+ out.println(" <description>"
+ + StringEscapeUtils.escapeXml(configProperty.getDescription()) + "</description>");
}
- if (configProperty.type != null && !configProperty.type.isEmpty()) {
- out.println(" <type>" + configProperty.type + "</type>");
+ if (configProperty.getType() != null && !configProperty.getType().isEmpty()) {
+ out.println(" <type>" + configProperty.getType() + "</type>");
}
- if (configProperty.isUnstable) {
+ if (configProperty.isUnstable()) {
out.println(" <unstable>true</unstable>");
}
- if (configProperty.isEvolving) {
+ if (configProperty.isEvolving()) {
out.println(" <evolving>true</evolving>");
}
- if (configProperty.isPrivate) {
+ if (configProperty.isPrivate()) {
out.println(" <private>true</private>");
}
out.println(" </property>");
@@ -91,7 +93,6 @@ public class XmlWriter extends Writer {
out.println();
out.println("</configuration>");
-
} finally {
if (out != null) {
out.close();
@@ -101,7 +102,7 @@ public class XmlWriter extends Writer {
private void writeApacheHeader(File file) throws IOException {
try (InputStream in = this.getClass().getClassLoader().getResourceAsStream("apache-licence.xml.header");
- OutputStream out = new FileOutputStream(file)) {
+ OutputStream out = Files.newOutputStream(file.toPath())) {
ByteStreams.copy(in, out);
}
}
diff --git a/tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/util/Writer.java b/tez-tools/tez-javadoc-tools/src/main/java-17/org/apache/tez/tools/javadoc/util/package-info.java
similarity index 62%
copy from tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/util/Writer.java
copy to tez-tools/tez-javadoc-tools/src/main/java-17/org/apache/tez/tools/javadoc/util/package-info.java
index cfb0c9273..d45861972 100644
--- a/tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/util/Writer.java
+++ b/tez-tools/tez-javadoc-tools/src/main/java-17/org/apache/tez/tools/javadoc/util/package-info.java
@@ -16,24 +16,7 @@
* limitations under the License.
*/
+@Private
package org.apache.tez.tools.javadoc.util;
-import java.io.IOException;
-
-import org.apache.tez.tools.javadoc.model.Config;
-import org.apache.tez.tools.javadoc.model.ConfigProperty;
-
-public abstract class Writer {
-
- public abstract void write(Config config) throws IOException;
-
- public boolean isValidConfigProperty(ConfigProperty configProperty) {
- if (!configProperty.isValidConfigProp) {
- return false;
- }
- if (configProperty.propertyName == null || configProperty.propertyName.isEmpty()) {
- return false;
- }
- return true;
- }
-}
+import org.apache.hadoop.classification.InterfaceAudience.Private;
\ No newline at end of file
diff --git a/tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/doclet/ConfigStandardDoclet.java b/tez-tools/tez-javadoc-tools/src/main/java-8-16/org/apache/tez/tools/javadoc/doclet/ConfigStandardDoclet.java
similarity index 81%
rename from tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/doclet/ConfigStandardDoclet.java
rename to tez-tools/tez-javadoc-tools/src/main/java-8-16/org/apache/tez/tools/javadoc/doclet/ConfigStandardDoclet.java
index 0713467c7..a67b9dbcd 100644
--- a/tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/doclet/ConfigStandardDoclet.java
+++ b/tez-tools/tez-javadoc-tools/src/main/java-8-16/org/apache/tez/tools/javadoc/doclet/ConfigStandardDoclet.java
@@ -7,7 +7,7 @@
* "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
+ * 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,
@@ -21,6 +21,15 @@ package org.apache.tez.tools.javadoc.doclet;
import java.io.IOException;
import java.util.Map;
+import com.sun.javadoc.AnnotationDesc;
+import com.sun.javadoc.AnnotationDesc.ElementValuePair;
+import com.sun.javadoc.ClassDoc;
+import com.sun.javadoc.DocErrorReporter;
+import com.sun.javadoc.FieldDoc;
+import com.sun.javadoc.LanguageVersion;
+import com.sun.javadoc.RootDoc;
+import com.sun.tools.doclets.standard.Standard;
+
import org.apache.hadoop.classification.InterfaceAudience.Private;
import org.apache.hadoop.classification.InterfaceStability.Evolving;
import org.apache.hadoop.classification.InterfaceStability.Unstable;
@@ -31,21 +40,13 @@ import org.apache.tez.tools.javadoc.model.ConfigProperty;
import org.apache.tez.tools.javadoc.util.HtmlWriter;
import org.apache.tez.tools.javadoc.util.XmlWriter;
-import com.sun.javadoc.AnnotationDesc;
-import com.sun.javadoc.AnnotationDesc.ElementValuePair;
-import com.sun.javadoc.ClassDoc;
-import com.sun.javadoc.DocErrorReporter;
-import com.sun.javadoc.FieldDoc;
-import com.sun.javadoc.LanguageVersion;
-import com.sun.javadoc.RootDoc;
-import com.sun.tools.doclets.standard.Standard;
-
public final class ConfigStandardDoclet {
private static final String DEBUG_SWITCH = "-debug";
private static boolean debugMode = false;
- private ConfigStandardDoclet() {}
+ private ConfigStandardDoclet() {
+ }
public static LanguageVersion languageVersion() {
return LanguageVersion.JAVA_1_5;
@@ -109,7 +110,7 @@ public final class ConfigStandardDoclet {
logMessage("Processing config class: " + doc);
Config config = new Config(doc.name(), templateName);
- Map<String, ConfigProperty> configProperties = config.configProperties;
+ Map<String, ConfigProperty> configProperties = config.getConfigProperties();
FieldDoc[] fields = doc.fields();
for (FieldDoc field : fields) {
@@ -144,16 +145,16 @@ public final class ConfigStandardDoclet {
+ ", name=" + name
+ ", field=" + field.name()
+ ", val=" + field.constantValueExpression());
- configProperty.defaultValue = field.constantValueExpression();
+ configProperty.setDefaultValue(field.constantValueExpression());
} else {
- configProperty.defaultValue = field.constantValue().toString();
+ configProperty.setDefaultValue(field.constantValue().toString());
}
- configProperty.inferredType = field.type().simpleTypeName();
+ configProperty.setInferredType(field.type().simpleTypeName());
- if (name.equals("TEZ_AM_STAGING_DIR") && configProperty.defaultValue != null) {
- String defaultValue = configProperty.defaultValue;
+ if (name.equals("TEZ_AM_STAGING_DIR") && configProperty.getDefaultValue() != null) {
+ String defaultValue = configProperty.getDefaultValue();
defaultValue = defaultValue.replace(System.getProperty("user.name"), "${user.name}");
- configProperty.defaultValue = defaultValue;
+ configProperty.setDefaultValue(defaultValue);
}
continue;
@@ -164,7 +165,7 @@ public final class ConfigStandardDoclet {
configProperties.put(name, new ConfigProperty());
}
ConfigProperty configProperty = configProperties.get(name);
- configProperty.propertyName = field.constantValue().toString();
+ configProperty.setPropertyName(field.constantValue().toString());
AnnotationDesc[] annotationDescs = field.annotations();
@@ -172,53 +173,49 @@ public final class ConfigStandardDoclet {
if (annotationDesc.annotationType().qualifiedTypeName().equals(
Private.class.getCanonicalName())) {
- configProperty.isPrivate = true;
+ configProperty.setPrivate(true);
}
if (annotationDesc.annotationType().qualifiedTypeName().equals(
Unstable.class.getCanonicalName())) {
- configProperty.isUnstable = true;
+ configProperty.setUnstable(true);
}
if (annotationDesc.annotationType().qualifiedTypeName().equals(
Evolving.class.getCanonicalName())) {
- configProperty.isEvolving = true;
+ configProperty.setEvolving(true);
}
if (annotationDesc.annotationType().qualifiedTypeName().equals(
ConfigurationProperty.class.getCanonicalName())) {
- configProperty.isValidConfigProp = true;
+ configProperty.setValidConfigProp(true);
for (ElementValuePair element : annotationDesc.elementValues()) {
if (element.element().name().equals("type")) {
- configProperty.type = stripQuotes(element.value().toString());
+ configProperty.setType(stripQuotes(element.value().toString()));
} else {
logMessage("Unhandled annotation property: " + element.element().name());
}
}
}
- }
-
- configProperty.description = field.commentText();
- }
-
- HtmlWriter writer = new HtmlWriter();
- try {
- writer.write(config);
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
+ HtmlWriter writer = new HtmlWriter();
+ try {
+ writer.write(config);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
- XmlWriter xmlWriter = new XmlWriter();
- try {
- xmlWriter.write(config);
- } catch (IOException e) {
- throw new RuntimeException(e);
+ XmlWriter xmlWriter = new XmlWriter();
+ try {
+ xmlWriter.write(config);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
}
-
}
private static String stripQuotes(String s) {
- if (s.charAt(0) == '"' && s.charAt(s.length()-1) == '"') {
- return s.substring(1, s.length()-1);
+ if (s.charAt(0) == '"' && s.charAt(s.length() - 1) == '"') {
+ return s.substring(1, s.length() - 1);
}
return s;
}
@@ -227,7 +224,7 @@ public final class ConfigStandardDoclet {
return Standard.optionLength(option);
}
- public static boolean validOptions(String options[][], DocErrorReporter reporter) {
+ public static boolean validOptions(String[][] options, DocErrorReporter reporter) {
return true;
}
}
diff --git a/tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/model/Config.java b/tez-tools/tez-javadoc-tools/src/main/java-8-16/org/apache/tez/tools/javadoc/doclet/package-info.java
similarity index 62%
copy from tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/model/Config.java
copy to tez-tools/tez-javadoc-tools/src/main/java-8-16/org/apache/tez/tools/javadoc/doclet/package-info.java
index 604d48ac5..190ae4622 100644
--- a/tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/model/Config.java
+++ b/tez-tools/tez-javadoc-tools/src/main/java-8-16/org/apache/tez/tools/javadoc/doclet/package-info.java
@@ -16,25 +16,7 @@
* limitations under the License.
*/
-package org.apache.tez.tools.javadoc.model;
+@Private
+package org.apache.tez.tools.javadoc.doclet;
-import java.util.Map;
-import java.util.TreeMap;
-
-public class Config {
-
- public final String templateName;
- public final String configName;
- public Map<String, ConfigProperty> configProperties;
-
- public Config(String configName, String templateName) {
- this.configName = configName;
- this.templateName = templateName;
- this.configProperties = new TreeMap<String, ConfigProperty>();
- }
-
- public Config() {
- this(null, null);
- }
-
-}
+import org.apache.hadoop.classification.InterfaceAudience.Private;
\ No newline at end of file
diff --git a/tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/model/Config.java b/tez-tools/tez-javadoc-tools/src/main/java-8-16/org/apache/tez/tools/javadoc/model/Config.java
similarity index 66%
copy from tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/model/Config.java
copy to tez-tools/tez-javadoc-tools/src/main/java-8-16/org/apache/tez/tools/javadoc/model/Config.java
index 604d48ac5..0556a4e37 100644
--- a/tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/model/Config.java
+++ b/tez-tools/tez-javadoc-tools/src/main/java-8-16/org/apache/tez/tools/javadoc/model/Config.java
@@ -23,18 +23,29 @@ import java.util.TreeMap;
public class Config {
- public final String templateName;
- public final String configName;
- public Map<String, ConfigProperty> configProperties;
+ private final String templateName;
+ private final String configName;
+ private Map<String, ConfigProperty> configProperties;
public Config(String configName, String templateName) {
this.configName = configName;
this.templateName = templateName;
- this.configProperties = new TreeMap<String, ConfigProperty>();
+ this.setConfigProperties(new TreeMap<String, ConfigProperty>());
}
- public Config() {
- this(null, null);
+ public String getTemplateName() {
+ return templateName;
}
+ public String getConfigName() {
+ return configName;
+ }
+
+ public Map<String, ConfigProperty> getConfigProperties() {
+ return configProperties;
+ }
+
+ public void setConfigProperties(Map<String, ConfigProperty> configProperties) {
+ this.configProperties = configProperties;
+ }
}
diff --git a/tez-tools/tez-javadoc-tools/src/main/java-8-16/org/apache/tez/tools/javadoc/model/ConfigProperty.java b/tez-tools/tez-javadoc-tools/src/main/java-8-16/org/apache/tez/tools/javadoc/model/ConfigProperty.java
new file mode 100644
index 000000000..27208de55
--- /dev/null
+++ b/tez-tools/tez-javadoc-tools/src/main/java-8-16/org/apache/tez/tools/javadoc/model/ConfigProperty.java
@@ -0,0 +1,115 @@
+/**
+ * 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.tez.tools.javadoc.model;
+
+public class ConfigProperty {
+
+ private String propertyName;
+ private String defaultValue;
+ private String description;
+ private String type = "string";
+ private boolean isPrivate = false;
+ private boolean isUnstable = false;
+ private boolean isEvolving = false;
+ private boolean isValidConfigProp = false;
+ private String inferredType;
+
+ public String getPropertyName() {
+ return propertyName;
+ }
+
+ public void setPropertyName(String propertyName) {
+ this.propertyName = propertyName;
+ }
+
+ public String getDefaultValue() {
+ return defaultValue;
+ }
+
+ public void setDefaultValue(String defaultValue) {
+ this.defaultValue = defaultValue;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public boolean isPrivate() {
+ return isPrivate;
+ }
+
+ public void setPrivate(boolean aPrivate) {
+ isPrivate = aPrivate;
+ }
+
+ public boolean isUnstable() {
+ return isUnstable;
+ }
+
+ public void setUnstable(boolean unstable) {
+ isUnstable = unstable;
+ }
+
+ public boolean isEvolving() {
+ return isEvolving;
+ }
+
+ public void setEvolving(boolean evolving) {
+ isEvolving = evolving;
+ }
+
+ public boolean isValidConfigProp() {
+ return isValidConfigProp;
+ }
+
+ public void setValidConfigProp(boolean validConfigProp) {
+ isValidConfigProp = validConfigProp;
+ }
+
+ public String getInferredType() {
+ return inferredType;
+ }
+
+ public void setInferredType(String inferredType) {
+ this.inferredType = inferredType;
+ }
+
+ @Override
+ public String toString() {
+ return "name=" + getPropertyName()
+ + ", defaultValue=" + getDefaultValue()
+ + ", description=" + getDescription()
+ + ", type=" + getType()
+ + ", inferredType=" + getInferredType()
+ + ", private=" + isPrivate()
+ + ", isConfigProp=" + isValidConfigProp();
+ }
+}
diff --git a/tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/model/Config.java b/tez-tools/tez-javadoc-tools/src/main/java-8-16/org/apache/tez/tools/javadoc/model/package-info.java
similarity index 65%
rename from tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/model/Config.java
rename to tez-tools/tez-javadoc-tools/src/main/java-8-16/org/apache/tez/tools/javadoc/model/package-info.java
index 604d48ac5..76acd0525 100644
--- a/tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/model/Config.java
+++ b/tez-tools/tez-javadoc-tools/src/main/java-8-16/org/apache/tez/tools/javadoc/model/package-info.java
@@ -16,25 +16,7 @@
* limitations under the License.
*/
+@Private
package org.apache.tez.tools.javadoc.model;
-import java.util.Map;
-import java.util.TreeMap;
-
-public class Config {
-
- public final String templateName;
- public final String configName;
- public Map<String, ConfigProperty> configProperties;
-
- public Config(String configName, String templateName) {
- this.configName = configName;
- this.templateName = templateName;
- this.configProperties = new TreeMap<String, ConfigProperty>();
- }
-
- public Config() {
- this(null, null);
- }
-
-}
+import org.apache.hadoop.classification.InterfaceAudience.Private;
\ No newline at end of file
diff --git a/tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/util/HtmlWriter.java b/tez-tools/tez-javadoc-tools/src/main/java-8-16/org/apache/tez/tools/javadoc/util/HtmlWriter.java
similarity index 76%
rename from tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/util/HtmlWriter.java
rename to tez-tools/tez-javadoc-tools/src/main/java-8-16/org/apache/tez/tools/javadoc/util/HtmlWriter.java
index 4b531e87e..548908c8e 100644
--- a/tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/util/HtmlWriter.java
+++ b/tez-tools/tez-javadoc-tools/src/main/java-8-16/org/apache/tez/tools/javadoc/util/HtmlWriter.java
@@ -19,13 +19,11 @@
package org.apache.tez.tools.javadoc.util;
import java.io.File;
-import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
-import org.apache.tez.dag.api.TezException;
import org.apache.tez.tools.javadoc.model.Config;
import org.apache.tez.tools.javadoc.model.ConfigProperty;
@@ -36,12 +34,12 @@ public class HtmlWriter extends Writer {
public void write(Config config) throws IOException {
PrintWriter out = null;
- if (config.configName == null || config.configName.isEmpty()) {
+ if (config.getConfigName() == null || config.getConfigName().isEmpty()) {
throw new RuntimeException("Config Name is null or empty");
}
try {
- File file = new File(config.configName + ".html");
+ File file = new File(config.getConfigName() + ".html");
out = new PrintWriter(new OutputStreamWriter(new FileOutputStream(file), "UTF-8"));
out.println("<?xml version=\"1.0\" encoding=\"ISO-8859-1\" standalone=\"no\" ?>");
@@ -52,8 +50,7 @@ public class HtmlWriter extends Writer {
out.println("<head>");
out.println("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\" />");
- out.println("<title>"+ config.configName +"</title>");
-// out.println("<link rel='stylesheet' type='text/css' href=' " + config.getStyleSheet() + "'/>");
+ out.println("<title>" + config.getConfigName() + "</title>");
out.println("</head>");
out.println("<style>");
@@ -103,7 +100,7 @@ public class HtmlWriter extends Writer {
out.println("<div id=\"wrapper\">");
out.println("<div id=\"container\">");
- out.println("<h1>"+ config.configName +"</h1>");
+ out.println("<h1>" + config.getConfigName() + "</h1>");
out.println("<hr />");
out.println("<table>");
@@ -118,29 +115,33 @@ public class HtmlWriter extends Writer {
out.println("<th class=\"th_evolve_unstable\">" + "Is Evolving?" + "</th>");
out.println("</tr>");
- for (ConfigProperty configProperty : config.configProperties.values()) {
+ for (ConfigProperty configProperty : config.getConfigProperties().values()) {
if (!isValidConfigProperty(configProperty)) {
continue;
}
String altClass = "";
- if (configProperty.isPrivate) {
+ if (configProperty.isPrivate()) {
altClass = "class=\"tr_private\"";
- } else if (configProperty.isEvolving || configProperty.isUnstable) {
+ } else if (configProperty.isEvolving() || configProperty.isUnstable()) {
altClass = "class=\"tr_evolve_unstable\"";
}
out.println("<tr " + altClass + ">");
- out.println("<td>" + configProperty.propertyName + "</td>");
- out.println("<td>" + configProperty.defaultValue + "</td>");
- out.println("<td>" + configProperty.description + "</td>");
- out.println("<td>" + configProperty.type + "</td>");
- // Re-enable after adding values
- // out.println("<td>" + configProperty.validValues + "</td>");
-
- out.println("<td class=\"" + (configProperty.isPrivate? "td_private_true" : "td_private_false") + "\">" + configProperty.isPrivate + "</td>");
- out.println("<td class=\"" + (configProperty.isEvolving? "td_evolve_true" : "td_evolve_false") + "\">" + configProperty.isEvolving + "</td>");
- out.println("<td class=\"" + (configProperty.isUnstable? "td_unstable_true" : "td_unstable_false") + "\">" + configProperty.isUnstable + "</td>");
+ out.println("<td>" + configProperty.getPropertyName() + "</td>");
+ out.println("<td>" + configProperty.getDefaultValue() + "</td>");
+ out.println("<td>" + configProperty.getDescription() + "</td>");
+ out.println("<td>" + configProperty.getType() + "</td>");
+
+ out.println(
+ "<td class=\"" + (configProperty.isPrivate() ? "td_private_true" : "td_private_false")
+ + "\">" + configProperty.isPrivate() + "</td>");
+ out.println(
+ "<td class=\"" + (configProperty.isEvolving() ? "td_evolve_true" : "td_evolve_false") + "\">"
+ + configProperty.isEvolving() + "</td>");
+ out.println(
+ "<td class=\"" + (configProperty.isUnstable() ? "td_unstable_true" : "td_unstable_false") + "\">"
+ + configProperty.isUnstable() + "</td>");
out.println("</tr>");
}
@@ -150,12 +151,10 @@ public class HtmlWriter extends Writer {
out.println("</div>");
out.println("</body>");
out.println("</html>");
-
} finally {
if (out != null) {
out.close();
}
}
}
-
}
diff --git a/tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/util/Writer.java b/tez-tools/tez-javadoc-tools/src/main/java-8-16/org/apache/tez/tools/javadoc/util/Writer.java
similarity index 89%
copy from tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/util/Writer.java
copy to tez-tools/tez-javadoc-tools/src/main/java-8-16/org/apache/tez/tools/javadoc/util/Writer.java
index cfb0c9273..ca8ff80d9 100644
--- a/tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/util/Writer.java
+++ b/tez-tools/tez-javadoc-tools/src/main/java-8-16/org/apache/tez/tools/javadoc/util/Writer.java
@@ -28,10 +28,10 @@ public abstract class Writer {
public abstract void write(Config config) throws IOException;
public boolean isValidConfigProperty(ConfigProperty configProperty) {
- if (!configProperty.isValidConfigProp) {
+ if (!configProperty.isValidConfigProp()) {
return false;
}
- if (configProperty.propertyName == null || configProperty.propertyName.isEmpty()) {
+ if (configProperty.getPropertyName() == null || configProperty.getPropertyName().isEmpty()) {
return false;
}
return true;
diff --git a/tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/util/XmlWriter.java b/tez-tools/tez-javadoc-tools/src/main/java-8-16/org/apache/tez/tools/javadoc/util/XmlWriter.java
similarity index 70%
rename from tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/util/XmlWriter.java
rename to tez-tools/tez-javadoc-tools/src/main/java-8-16/org/apache/tez/tools/javadoc/util/XmlWriter.java
index e9bdeb399..5195c2514 100644
--- a/tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/util/XmlWriter.java
+++ b/tez-tools/tez-javadoc-tools/src/main/java-8-16/org/apache/tez/tools/javadoc/util/XmlWriter.java
@@ -37,12 +37,12 @@ public class XmlWriter extends Writer {
public void write(Config config) throws IOException {
PrintWriter out = null;
- if (config.configName == null || config.configName.isEmpty()) {
+ if (config.getConfigName() == null || config.getConfigName().isEmpty()) {
throw new RuntimeException("Config Name is null or empty");
}
- String fileName = config.templateName == null ||
- config.templateName.isEmpty() ? config.configName : config.templateName;
+ String fileName = config.getTemplateName() == null ||
+ config.getTemplateName().isEmpty() ? config.getConfigName() : config.getTemplateName();
if (!fileName.endsWith(".xml")) {
fileName += ".xml";
}
@@ -60,30 +60,30 @@ public class XmlWriter extends Writer {
out.println();
out.println("<configuration>");
- for (ConfigProperty configProperty : config.configProperties.values()) {
+ for (ConfigProperty configProperty : config.getConfigProperties().values()) {
if (!isValidConfigProperty(configProperty)) {
continue;
}
out.println();
out.println(" <property>");
- out.println(" <name>" + configProperty.propertyName + "</name>");
- if (configProperty.defaultValue != null && !configProperty.defaultValue.isEmpty()) {
- out.println(" <defaultValue>" + configProperty.defaultValue + "</defaultValue>");
+ out.println(" <name>" + configProperty.getPropertyName() + "</name>");
+ if (configProperty.getDefaultValue() != null && !configProperty.getDefaultValue().isEmpty()) {
+ out.println(" <defaultValue>" + configProperty.getDefaultValue() + "</defaultValue>");
}
- if (configProperty.description != null && !configProperty.description.isEmpty()) {
- out.println(" <description>" + StringEscapeUtils.escapeXml(configProperty.description)
- + "</description>");
+ if (configProperty.getDescription() != null && !configProperty.getDescription().isEmpty()) {
+ out.println(" <description>"
+ + StringEscapeUtils.escapeXml(configProperty.getDescription()) + "</description>");
}
- if (configProperty.type != null && !configProperty.type.isEmpty()) {
- out.println(" <type>" + configProperty.type + "</type>");
+ if (configProperty.getType() != null && !configProperty.getType().isEmpty()) {
+ out.println(" <type>" + configProperty.getType() + "</type>");
}
- if (configProperty.isUnstable) {
+ if (configProperty.isUnstable()) {
out.println(" <unstable>true</unstable>");
}
- if (configProperty.isEvolving) {
+ if (configProperty.isEvolving()) {
out.println(" <evolving>true</evolving>");
}
- if (configProperty.isPrivate) {
+ if (configProperty.isPrivate()) {
out.println(" <private>true</private>");
}
out.println(" </property>");
@@ -91,7 +91,6 @@ public class XmlWriter extends Writer {
out.println();
out.println("</configuration>");
-
} finally {
if (out != null) {
out.close();
@@ -101,7 +100,7 @@ public class XmlWriter extends Writer {
private void writeApacheHeader(File file) throws IOException {
try (InputStream in = this.getClass().getClassLoader().getResourceAsStream("apache-licence.xml.header");
- OutputStream out = new FileOutputStream(file)) {
+ OutputStream out = new FileOutputStream(file)) {
ByteStreams.copy(in, out);
}
}
diff --git a/tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/util/Writer.java b/tez-tools/tez-javadoc-tools/src/main/java-8-16/org/apache/tez/tools/javadoc/util/package-info.java
similarity index 62%
rename from tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/util/Writer.java
rename to tez-tools/tez-javadoc-tools/src/main/java-8-16/org/apache/tez/tools/javadoc/util/package-info.java
index cfb0c9273..d45861972 100644
--- a/tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/util/Writer.java
+++ b/tez-tools/tez-javadoc-tools/src/main/java-8-16/org/apache/tez/tools/javadoc/util/package-info.java
@@ -16,24 +16,7 @@
* limitations under the License.
*/
+@Private
package org.apache.tez.tools.javadoc.util;
-import java.io.IOException;
-
-import org.apache.tez.tools.javadoc.model.Config;
-import org.apache.tez.tools.javadoc.model.ConfigProperty;
-
-public abstract class Writer {
-
- public abstract void write(Config config) throws IOException;
-
- public boolean isValidConfigProperty(ConfigProperty configProperty) {
- if (!configProperty.isValidConfigProp) {
- return false;
- }
- if (configProperty.propertyName == null || configProperty.propertyName.isEmpty()) {
- return false;
- }
- return true;
- }
-}
+import org.apache.hadoop.classification.InterfaceAudience.Private;
\ No newline at end of file