You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tajo.apache.org by hj...@apache.org on 2014/12/05 09:21:10 UTC
[06/29] tajo git commit: TAJO-1204: Remove unused ServerName class.
(DaeMyung Kang via jaehwa)
TAJO-1204: Remove unused ServerName class. (DaeMyung Kang via jaehwa)
Project: http://git-wip-us.apache.org/repos/asf/tajo/repo
Commit: http://git-wip-us.apache.org/repos/asf/tajo/commit/f3291621
Tree: http://git-wip-us.apache.org/repos/asf/tajo/tree/f3291621
Diff: http://git-wip-us.apache.org/repos/asf/tajo/diff/f3291621
Branch: refs/heads/hbase_storage
Commit: f3291621c31bbc24aff47dbc363ddfe2a1a9b21c
Parents: 72dd29c
Author: JaeHwa Jung <bl...@apache.org>
Authored: Thu Nov 27 22:28:06 2014 +0900
Committer: JaeHwa Jung <bl...@apache.org>
Committed: Thu Nov 27 22:28:06 2014 +0900
----------------------------------------------------------------------
CHANGES | 2 +
.../apache/tajo/master/cluster/ServerName.java | 123 -------------------
.../org/apache/tajo/cluster/TestServerName.java | 102 ---------------
3 files changed, 2 insertions(+), 225 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tajo/blob/f3291621/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 6f38f65..9b15898 100644
--- a/CHANGES
+++ b/CHANGES
@@ -13,6 +13,8 @@ Release 0.9.1 - unreleased
IMPROVEMENT
+ TAJO-1204: Remove unused ServerName class. (DaeMyung Kang via jaehwa)
+
TAJO-1053: ADD PARTITIONS for HCatalogStore. (jaehwa)
TAJO-1195: Remove unused CachedDNSResolver Class. (DaeMyung Kang via jaehwa)
http://git-wip-us.apache.org/repos/asf/tajo/blob/f3291621/tajo-core/src/main/java/org/apache/tajo/master/cluster/ServerName.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/master/cluster/ServerName.java b/tajo-core/src/main/java/org/apache/tajo/master/cluster/ServerName.java
deleted file mode 100644
index 028af65..0000000
--- a/tajo-core/src/main/java/org/apache/tajo/master/cluster/ServerName.java
+++ /dev/null
@@ -1,123 +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.tajo.master.cluster;
-
-public class ServerName implements Comparable<ServerName> {
- /**
- * This character is used as separator between server hostname and port.
- */
- public static final String SERVERNAME_SEPARATOR = ":";
-
- private final String serverName;
- private final String hostname;
- private final int port;
-
-
- public ServerName(final String hostname, final int port) {
- this.hostname = hostname;
- this.port = port;
- this.serverName = getServerName(hostname, port);
- }
-
- public ServerName(final String serverName) {
- this(parseHostname(serverName), parsePort(serverName));
- }
-
- public static ServerName create(final String serverName) {
- return new ServerName(serverName);
- }
-
- public static ServerName createWithDefaultPort(final String serverName,
- final int defaultPort) {
- if (serverName == null || serverName.length() <= 0) {
- throw new IllegalArgumentException("Passed hostname is null or empty ("
- + serverName + ")");
- }
- int index = serverName.indexOf(SERVERNAME_SEPARATOR);
- if (index == -1) {
- return new ServerName(parseHostname(serverName), defaultPort);
- } else {
- return new ServerName(parseHostname(serverName), parsePort(serverName));
- }
- }
-
- public static String parseHostname(final String serverName) {
- if (serverName == null || serverName.length() <= 0) {
- throw new IllegalArgumentException("Passed hostname is null or empty ("
- + serverName + ")");
- }
- int index = serverName.indexOf(SERVERNAME_SEPARATOR);
- if (index == -1) { // if a port is missing, the index will be set to -1.
- throw new IllegalArgumentException("Passed port is missing ("
- + serverName + ")");
- }
- return serverName.substring(0, index);
- }
-
- public static int parsePort(final String serverName) {
- String [] split = serverName.split(SERVERNAME_SEPARATOR);
- return Integer.parseInt(split[1]);
- }
-
- @Override
- public String toString() {
- return getServerName();
- }
-
- public String getServerName() {
- return serverName;
- }
-
- public String getHostname() {
- return hostname;
- }
-
- public int getPort() {
- return port;
- }
-
- public static String getServerName(String hostName, int port) {
- final StringBuilder name = new StringBuilder(hostName.length() + 4);
- name.append(hostName);
- name.append(SERVERNAME_SEPARATOR);
- name.append(port);
- return name.toString();
- }
-
- @Override
- public int compareTo(ServerName other) {
- int compare = this.getHostname().toLowerCase().
- compareTo(other.getHostname().toLowerCase());
- if (compare != 0) return compare;
- return this.getPort() - other.getPort();
- }
-
- @Override
- public int hashCode() {
- return getServerName().hashCode();
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null) return false;
- if (!(o instanceof ServerName)) return false;
- return this.compareTo((ServerName)o) == 0;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tajo/blob/f3291621/tajo-core/src/test/java/org/apache/tajo/cluster/TestServerName.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/test/java/org/apache/tajo/cluster/TestServerName.java b/tajo-core/src/test/java/org/apache/tajo/cluster/TestServerName.java
deleted file mode 100644
index 513187d..0000000
--- a/tajo-core/src/test/java/org/apache/tajo/cluster/TestServerName.java
+++ /dev/null
@@ -1,102 +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.tajo.cluster;
-
-import org.junit.Test;
-import org.apache.tajo.master.cluster.ServerName;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-public class TestServerName {
-
- @Test
- public void testServerNameStringInt() {
- ServerName server = new ServerName("ex1.com",50030);
- assertEquals("ex1.com", server.getHostname());
- assertEquals(50030, server.getPort());
- }
-
- @Test
- public void testServerNameString() {
- ServerName server = new ServerName("ex1.com:50030");
- assertEquals("ex1.com", server.getHostname());
- assertEquals(50030, server.getPort());
- }
-
- @Test
- public void testParseHostname() {
- assertEquals("ex1.com",ServerName.parseHostname("ex1.com:50030"));
- }
-
- @Test
- public void testParsePort() {
- assertEquals(50030,ServerName.parsePort("ex1.com:50030"));
- }
-
- @Test
- public void testToString() {
- ServerName server = new ServerName("ex1.com",50030);
- assertEquals("ex1.com:50030", server.toString());
- }
-
- @Test
- public void testGetServerName() {
- ServerName server = new ServerName("ex1.com",50030);
- assertEquals("ex1.com:50030", server.getServerName());
- }
-
- @Test
- public void testGetHostname() {
- ServerName server = new ServerName("ex1.com",50030);
- assertEquals("ex1.com", server.getHostname());
- }
-
- @Test
- public void testGetPort() {
- ServerName server = new ServerName("ex1.com",50030);
- assertEquals(50030, server.getPort());
- }
-
- @Test
- public void testGetServerNameStringInt() {
- assertEquals("ex2.com:50030",ServerName.getServerName("ex2.com", 50030));
- }
-
- @Test
- public void testCompareTo() {
- ServerName s1 = new ServerName("ex1.com:50030");
- ServerName s2 = new ServerName("ex1.com:60030");
-
- assertTrue(s1.compareTo(s2) < 0);
- assertTrue(s2.compareTo(s1) > 0);
-
- ServerName s3 = new ServerName("ex1.com:50030");
- assertTrue(s1.compareTo(s3) == 0);
-
- ServerName s4 = new ServerName("ex2.com:50030");
- assertTrue(s1.compareTo(s4) < 0);
- assertTrue(s4.compareTo(s1) > 0);
- }
-
- @Test (expected = IllegalArgumentException.class)
- public void testException() {
- new ServerName("ex1.com");
- }
-}