From common-commits-return-93546-archive-asf-public=cust-asf.ponee.io@hadoop.apache.org Tue Mar 5 17:21:19 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 78094180648 for ; Tue, 5 Mar 2019 18:21:18 +0100 (CET) Received: (qmail 64011 invoked by uid 500); 5 Mar 2019 17:21:17 -0000 Mailing-List: contact common-commits-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list common-commits@hadoop.apache.org Received: (qmail 64002 invoked by uid 99); 5 Mar 2019 17:21:17 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 05 Mar 2019 17:21:17 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id BA036877D8; Tue, 5 Mar 2019 17:21:16 +0000 (UTC) Date: Tue, 05 Mar 2019 17:21:16 +0000 To: "common-commits@hadoop.apache.org" Subject: [hadoop] branch branch-2.9 updated: YARN-7266. Fixed deadlock in Timeline Server thread initialization. Contributed by Prabhu Joseph MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Message-ID: <155180647660.21256.11213448520309087884@gitbox.apache.org> From: eyang@apache.org X-Git-Host: gitbox.apache.org X-Git-Repo: hadoop X-Git-Refname: refs/heads/branch-2.9 X-Git-Reftype: branch X-Git-Oldrev: 58f490a34ea3de9d8d8ad8e5c35e13e992d2e9b0 X-Git-Newrev: fc76e98d8d4b4235fef1c1b687c880bec1b8dabb X-Git-Rev: fc76e98d8d4b4235fef1c1b687c880bec1b8dabb X-Git-NotificationType: ref_changed_plus_diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated This is an automated email from the ASF dual-hosted git repository. eyang pushed a commit to branch branch-2.9 in repository https://gitbox.apache.org/repos/asf/hadoop.git The following commit(s) were added to refs/heads/branch-2.9 by this push: new fc76e98 YARN-7266. Fixed deadlock in Timeline Server thread initialization. Contributed by Prabhu Joseph fc76e98 is described below commit fc76e98d8d4b4235fef1c1b687c880bec1b8dabb Author: Eric Yang AuthorDate: Tue Mar 5 12:17:01 2019 -0500 YARN-7266. Fixed deadlock in Timeline Server thread initialization. Contributed by Prabhu Joseph (cherry picked from commit 7b42e0e32ac7dfb60f25fa656a9bef69c2a62501) --- .../hadoop-yarn/hadoop-yarn-api/pom.xml | 6 +++ .../yarn/api/records/timeline/jaxb.properties | 13 +++++ .../webapp/ContextFactory.java | 62 ++++++++++++++++++++++ .../webapp/TestAHSWebServices.java | 11 ++++ 4 files changed, 92 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 aa8ebe6..7d0e1f0 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/pom.xml +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/pom.xml @@ -92,6 +92,12 @@ false + + src/main/resources + + **/jaxb.properties + + 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 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 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 1dd0dad..bb99d1d 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 @@ -27,12 +27,14 @@ import java.net.URI; import java.net.URL; import java.util.Arrays; import java.util.Collection; +import java.util.Collections; import java.util.List; import java.util.Properties; import javax.servlet.FilterConfig; import javax.servlet.ServletException; import javax.servlet.http.HttpServletResponse; +import javax.xml.bind.JAXBContext; import javax.ws.rs.core.MediaType; import org.apache.commons.lang.StringUtils; import org.apache.hadoop.conf.Configuration; @@ -941,6 +943,15 @@ public class TestAHSWebServices extends JerseyTestBase { String.valueOf(content.length())); } + @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); + } + private static String getRedirectURL(String url) { String redirectUrl = null; try { --------------------------------------------------------------------- To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org For additional commands, e-mail: common-commits-help@hadoop.apache.org