tajo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From blrun...@apache.org
Subject tajo git commit: TAJO-1204: Remove unused ServerName class. (DaeMyung Kang via jaehwa)
Date Tue, 25 Nov 2014 02:27:58 GMT
Repository: tajo
Updated Branches:
  refs/heads/e9d856676336d550f680de980a250ce073399af6 [created] e9d856676


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/e9d85667
Tree: http://git-wip-us.apache.org/repos/asf/tajo/tree/e9d85667
Diff: http://git-wip-us.apache.org/repos/asf/tajo/diff/e9d85667

Branch: refs/heads/e9d856676336d550f680de980a250ce073399af6
Commit: e9d856676336d550f680de980a250ce073399af6
Parents: 80afe99
Author: JaeHwa Jung <blrunner@apache.org>
Authored: Tue Nov 25 11:27:12 2014 +0900
Committer: JaeHwa Jung <blrunner@apache.org>
Committed: Tue Nov 25 11:27:12 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/e9d85667/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index d5c7f1c..1fb3ece 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-1195: Remove unused CachedDNSResolver Class. (DaeMyung Kang via jaehwa)
 
     TAJO-1184: Upgrade netty-buffer to 4.0.24.Final. (jinho)

http://git-wip-us.apache.org/repos/asf/tajo/blob/e9d85667/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/e9d85667/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");
-  }
-}


Mime
View raw message