You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by ey...@apache.org on 2019/03/07 01:03:02 UTC
[hadoop] branch branch-2.8 updated: YARN-7266. Fixed deadlock in
Timeline Server thread initialization. Contributed by Prabhu Joseph
This is an automated email from the ASF dual-hosted git repository.
eyang pushed a commit to branch branch-2.8
in repository https://gitbox.apache.org/repos/asf/hadoop.git
The following commit(s) were added to refs/heads/branch-2.8 by this push:
new 0422590 YARN-7266. Fixed deadlock in Timeline Server thread initialization. Contributed by Prabhu Joseph
0422590 is described below
commit 0422590291e94f48f7734408ef5fd753fd69a6c9
Author: Eric Yang <ey...@apache.org>
AuthorDate: Wed Mar 6 20:01:56 2019 -0500
YARN-7266. Fixed deadlock in Timeline Server thread initialization.
Contributed by Prabhu Joseph
---
.../hadoop-yarn/hadoop-yarn-api/pom.xml | 6 +++
.../yarn/api/records/timeline/jaxb.properties | 13 +++++
.../webapp/ContextFactory.java | 62 ++++++++++++++++++++++
.../webapp/TestAHSWebServices.java | 12 +++++
4 files changed, 93 insertions(+)
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/pom.xml b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/pom.xml
index 8aa712f..114905e 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/pom.xml
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/pom.xml
@@ -88,6 +88,12 @@
</includes>
<filtering>false</filtering>
</resource>
+ <resource>
+ <directory>src/main/resources</directory>
+ <includes>
+ <include>**/jaxb.properties</include>
+ </includes>
+ </resource>
</resources>
<plugins>
<plugin>
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/resources/org/apache/hadoop/yarn/api/records/timeline/jaxb.properties b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/resources/org/apache/hadoop/yarn/api/records/timeline/jaxb.properties
new file mode 100644
index 0000000..8e545b3
--- /dev/null
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/resources/org/apache/hadoop/yarn/api/records/timeline/jaxb.properties
@@ -0,0 +1,13 @@
+# Licensed 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.
+
+javax.xml.bind.context.factory=org.apache.hadoop.yarn.server.applicationhistoryservice.webapp.ContextFactory
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/ContextFactory.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/ContextFactory.java
new file mode 100644
index 0000000..67668a9
--- /dev/null
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/ContextFactory.java
@@ -0,0 +1,62 @@
+/**
+ * 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.yarn.server.applicationhistoryservice.webapp;
+
+import java.util.Map;
+import java.lang.reflect.Method;
+import javax.xml.bind.JAXBContext;
+
+/**
+ * ContextFactory to reuse JAXBContextImpl for DAO Classes.
+ */
+public final class ContextFactory {
+
+ private static JAXBContext jaxbContext;
+
+ private ContextFactory() {
+ }
+
+ // Called from WebComponent.service
+ public static JAXBContext createContext(Class[] classes,
+ Map<String, Object> properties) throws Exception {
+ synchronized (ContextFactory.class) {
+ if (jaxbContext == null) {
+ Class spFactory = Class.forName(
+ "com.sun.xml.internal.bind.v2.ContextFactory");
+ Method m = spFactory.getMethod("createContext", Class[].class,
+ Map.class);
+ jaxbContext = (JAXBContext) m.invoke((Object) null, classes,
+ properties);
+ }
+ }
+ return jaxbContext;
+ }
+
+ // Called from WebComponent.init
+ public static JAXBContext createContext(String contextPath, ClassLoader
+ classLoader, Map<String, Object> properties) throws Exception {
+ Class spFactory = Class.forName(
+ "com.sun.xml.internal.bind.v2.ContextFactory");
+ Method m = spFactory.getMethod("createContext", String.class,
+ ClassLoader.class, Map.class);
+ return (JAXBContext) m.invoke(null, contextPath, classLoader,
+ properties);
+ }
+
+}
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/TestAHSWebServices.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/TestAHSWebServices.java
index 20dfe45..c246a42 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/TestAHSWebServices.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/TestAHSWebServices.java
@@ -23,11 +23,13 @@ import static org.junit.Assert.fail;
import java.util.Arrays;
import java.util.Collection;
+import java.util.Collections;
import java.util.Properties;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.ws.rs.core.MediaType;
+import javax.xml.bind.JAXBContext;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.security.authentication.server.AuthenticationFilter;
@@ -471,4 +473,14 @@ public class TestAHSWebServices extends JerseyTestBase {
assertEquals(ContainerState.COMPLETE.toString(),
container.getString("containerState"));
}
+
+ @Test
+ public void testContextFactory() throws Exception {
+ JAXBContext jaxbContext1 = ContextFactory.createContext(
+ new Class[]{}, Collections.EMPTY_MAP);
+ JAXBContext jaxbContext2 = ContextFactory.createContext(
+ new Class[]{}, Collections.EMPTY_MAP);
+ assertEquals(jaxbContext1, jaxbContext2);
+ }
+
}
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org