Return-Path: Delivered-To: apmail-hadoop-common-commits-archive@www.apache.org Received: (qmail 45476 invoked from network); 4 Mar 2011 04:35:38 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 4 Mar 2011 04:35:38 -0000 Received: (qmail 56681 invoked by uid 500); 4 Mar 2011 04:35:38 -0000 Delivered-To: apmail-hadoop-common-commits-archive@hadoop.apache.org Received: (qmail 56647 invoked by uid 500); 4 Mar 2011 04:35:38 -0000 Mailing-List: contact common-commits-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: common-dev@hadoop.apache.org Delivered-To: mailing list common-commits@hadoop.apache.org Received: (qmail 56637 invoked by uid 99); 4 Mar 2011 04:35:38 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 04 Mar 2011 04:35:38 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 04 Mar 2011 04:35:35 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 16D99238899C; Fri, 4 Mar 2011 04:35:14 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1077605 - in /hadoop/common/branches/branch-0.20-security-patches: conf/hadoop-metrics2.properties conf/hadoop-metrics2.properties.example src/core/org/apache/hadoop/metrics2/util/Servers.java Date: Fri, 04 Mar 2011 04:35:14 -0000 To: common-commits@hadoop.apache.org From: omalley@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110304043514.16D99238899C@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: omalley Date: Fri Mar 4 04:35:13 2011 New Revision: 1077605 URL: http://svn.apache.org/viewvc?rev=1077605&view=rev Log: commit 1fbf3d3ece076ca041ae99e84dedbc97bdaf7600 Author: Luke Lu Date: Tue Jul 27 15:50:42 2010 -0700 Fix unit test failure caused by an example config file. The last minute added file was causing MetricsConfig.testMissingFiles to fail. Also add back a util class that's need for Simon and Ganglia. Added: hadoop/common/branches/branch-0.20-security-patches/conf/hadoop-metrics2.properties.example hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/util/Servers.java Removed: hadoop/common/branches/branch-0.20-security-patches/conf/hadoop-metrics2.properties Added: hadoop/common/branches/branch-0.20-security-patches/conf/hadoop-metrics2.properties.example URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-patches/conf/hadoop-metrics2.properties.example?rev=1077605&view=auto ============================================================================== --- hadoop/common/branches/branch-0.20-security-patches/conf/hadoop-metrics2.properties.example (added) +++ hadoop/common/branches/branch-0.20-security-patches/conf/hadoop-metrics2.properties.example Fri Mar 4 04:35:13 2011 @@ -0,0 +1,3 @@ +#[prefix].[source|sink|jmx].[instance].[options] +#namenode.sink.file0.class=org.apache.hadoop.metrics2.sink.FileSink +#namenode.sink.file0.filename=nn.out Added: hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/util/Servers.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/util/Servers.java?rev=1077605&view=auto ============================================================================== --- hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/util/Servers.java (added) +++ hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/util/Servers.java Fri Mar 4 04:35:13 2011 @@ -0,0 +1,68 @@ +/* + * Util.java + * + * 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.metrics2.util; + +import java.net.InetSocketAddress; +import java.util.ArrayList; +import java.util.List; + +/** + * Helpers to handle server addresses + */ +public class Servers { + + /** + * This class is not intended to be instantiated + */ + private Servers() {} + + /** + * Parses a space and/or comma separated sequence of server specifications + * of the form hostname or hostname:port. If + * the specs string is null, defaults to localhost:defaultPort. + * + * @param specs server specs (see description) + * @param defaultPort the default port if not specified + * @return a list of InetSocketAddress objects. + */ + public static List parse(String specs, int defaultPort) { + List result = new ArrayList(1); + if (specs == null) { + result.add(new InetSocketAddress("localhost", defaultPort)); + } + else { + String[] specStrings = specs.split("[ ,]+"); + for (String specString : specStrings) { + int colon = specString.indexOf(':'); + if (colon < 0 || colon == specString.length() - 1) { + result.add(new InetSocketAddress(specString, defaultPort)); + } else { + String hostname = specString.substring(0, colon); + int port = Integer.parseInt(specString.substring(colon+1)); + result.add(new InetSocketAddress(hostname, port)); + } + } + } + return result; + } + +}