Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 9DDB7200CF8 for ; Thu, 31 Aug 2017 07:39:15 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 9C1D816A988; Thu, 31 Aug 2017 05:39:15 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id E3FA216A966 for ; Thu, 31 Aug 2017 07:39:14 +0200 (CEST) Received: (qmail 28053 invoked by uid 500); 31 Aug 2017 05:39:05 -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 23509 invoked by uid 99); 31 Aug 2017 05:39:01 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 31 Aug 2017 05:39:01 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 67649F55D3; Thu, 31 Aug 2017 05:39:00 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: jianhe@apache.org To: common-commits@hadoop.apache.org Date: Thu, 31 Aug 2017 05:39:28 -0000 Message-Id: <424d89c71b784b49807dc1863c8e9cf7@git.apache.org> In-Reply-To: <34674d450e9f4843916aca534c8811f8@git.apache.org> References: <34674d450e9f4843916aca534c8811f8@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [32/74] [abbrv] hadoop git commit: YARN-7050. Post cleanup after YARN-6903, removal of org.apache.slider package. Contributed by Jian He archived-at: Thu, 31 Aug 2017 05:39:15 -0000 http://git-wip-us.apache.org/repos/asf/hadoop/blob/2b3aff2f/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/client/ClientUtils.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/client/ClientUtils.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/client/ClientUtils.java deleted file mode 100644 index b28257f..0000000 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/client/ClientUtils.java +++ /dev/null @@ -1,111 +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.slider.client; - -import org.apache.commons.lang.StringUtils; -import org.apache.hadoop.conf.Configuration; -import org.apache.hadoop.fs.PathNotFoundException; -import org.apache.hadoop.registry.client.api.RegistryOperations; -import org.apache.hadoop.registry.client.binding.RegistryPathUtils; -import org.apache.hadoop.registry.client.exceptions.NoRecordException; -import org.apache.hadoop.registry.client.types.ServiceRecord; -import org.apache.hadoop.yarn.service.conf.SliderKeys; -import org.apache.slider.core.exceptions.BadCommandArgumentsException; -import org.apache.slider.core.exceptions.NotFoundException; -import org.apache.slider.core.exceptions.SliderException; -import org.apache.slider.core.registry.docstore.ConfigFormat; -import org.apache.slider.core.registry.docstore.PublishedConfigSet; -import org.apache.slider.core.registry.docstore.PublishedConfiguration; -import org.apache.slider.core.registry.docstore.PublishedConfigurationOutputter; -import org.apache.slider.core.registry.retrieve.RegistryRetriever; - -import java.io.File; -import java.io.IOException; - -import static org.apache.hadoop.registry.client.binding.RegistryUtils.currentUser; -import static org.apache.hadoop.registry.client.binding.RegistryUtils.servicePath; - -public class ClientUtils { - public static ServiceRecord lookupServiceRecord(RegistryOperations rops, - String user, String name) throws IOException, SliderException { - return lookupServiceRecord(rops, user, null, name); - } - - public static ServiceRecord lookupServiceRecord(RegistryOperations rops, - String user, String type, String name) throws IOException, - SliderException { - if (StringUtils.isEmpty(user)) { - user = currentUser(); - } else { - user = RegistryPathUtils.encodeForRegistry(user); - } - if (StringUtils.isEmpty(type)) { - type = SliderKeys.APP_TYPE; - } - - String path = servicePath(user, type, name); - return resolve(rops, path); - } - - public static ServiceRecord resolve(RegistryOperations rops, String path) - throws IOException, SliderException { - try { - return rops.resolve(path); - } catch (PathNotFoundException | NoRecordException e) { - throw new NotFoundException(e.getPath().toString(), e); - } - } - - public static PublishedConfiguration getConfigFromRegistry( - RegistryOperations rops, Configuration configuration, - String configName, String appName, String user, boolean external) - throws IOException, SliderException { - ServiceRecord instance = lookupServiceRecord(rops, user, appName); - - RegistryRetriever retriever = new RegistryRetriever(configuration, instance); - PublishedConfigSet configurations = retriever.getConfigurations(external); - - PublishedConfiguration published = retriever.retrieveConfiguration( - configurations, configName, external); - return published; - } - - public static String saveOrReturnConfig(PublishedConfiguration published, - String format, File destPath, String fileName) - throws BadCommandArgumentsException, IOException { - ConfigFormat configFormat = ConfigFormat.resolve(format); - if (configFormat == null) { - throw new BadCommandArgumentsException( - "Unknown/Unsupported format %s ", format); - } - PublishedConfigurationOutputter outputter = - PublishedConfigurationOutputter.createOutputter(configFormat, - published); - boolean print = destPath == null; - if (!print) { - if (destPath.isDirectory()) { - // creating it under a directory - destPath = new File(destPath, fileName); - } - outputter.save(destPath); - return null; - } else { - return outputter.asString(); - } - } -} --------------------------------------------------------------------- To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org For additional commands, e-mail: common-commits-help@hadoop.apache.org