From commits-return-67353-archive-asf-public=cust-asf.ponee.io@hbase.apache.org Tue Feb 6 16:14:01 2018 Return-Path: X-Original-To: archive-asf-public@eu.ponee.io Delivered-To: archive-asf-public@eu.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by mx-eu-01.ponee.io (Postfix) with ESMTP id 6F2D61807A5 for ; Tue, 6 Feb 2018 16:14:00 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 5DD5A160C45; Tue, 6 Feb 2018 15:14:00 +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 D621A160C3A for ; Tue, 6 Feb 2018 16:13:58 +0100 (CET) Received: (qmail 41278 invoked by uid 500); 6 Feb 2018 15:13:55 -0000 Mailing-List: contact commits-help@hbase.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@hbase.apache.org Delivered-To: mailing list commits@hbase.apache.org Received: (qmail 40832 invoked by uid 99); 6 Feb 2018 15:13:54 -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; Tue, 06 Feb 2018 15:13:54 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 461B7F2188; Tue, 6 Feb 2018 15:13:52 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: git-site-role@apache.org To: commits@hbase.apache.org Date: Tue, 06 Feb 2018 15:13:54 -0000 Message-Id: <57dba28ee4084c06a91030e7a1c49079@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [04/26] hbase-site git commit: Published site at . http://git-wip-us.apache.org/repos/asf/hbase-site/blob/ac54a6a8/testdevapidocs/src-html/org/apache/hadoop/hbase/TestFullLogReconstruction.html ---------------------------------------------------------------------- diff --git a/testdevapidocs/src-html/org/apache/hadoop/hbase/TestFullLogReconstruction.html b/testdevapidocs/src-html/org/apache/hadoop/hbase/TestFullLogReconstruction.html index 1d55ae7..b669c23 100644 --- a/testdevapidocs/src-html/org/apache/hadoop/hbase/TestFullLogReconstruction.html +++ b/testdevapidocs/src-html/org/apache/hadoop/hbase/TestFullLogReconstruction.html @@ -30,10 +30,10 @@ 022import org.apache.hadoop.conf.Configuration; 023import org.apache.hadoop.hbase.Waiter.ExplainingPredicate; 024import org.apache.hadoop.hbase.client.Table; -025import org.apache.hadoop.hbase.regionserver.HRegionServer; -026import org.apache.hadoop.hbase.testclassification.LargeTests; -027import org.apache.hadoop.hbase.testclassification.MiscTests; -028import org.apache.hadoop.hbase.util.Bytes; +025import org.apache.hadoop.hbase.testclassification.LargeTests; +026import org.apache.hadoop.hbase.testclassification.MiscTests; +027import org.apache.hadoop.hbase.util.Bytes; +028import org.apache.hadoop.hbase.util.JVMClusterUtil.RegionServerThread; 029import org.junit.AfterClass; 030import org.junit.BeforeClass; 031import org.junit.ClassRule; @@ -89,27 +89,28 @@ 081 for (int i = 0; i < 4; i++) { 082 TEST_UTIL.loadTable(table, FAMILY); 083 } -084 HRegionServer rs = TEST_UTIL.expireRegionServerSession(0); -085 // make sure that the RS is fully down before reading, so that we will read the data from other -086 // RSes. -087 TEST_UTIL.waitFor(30000, new ExplainingPredicate<Exception>() { -088 -089 @Override -090 public boolean evaluate() throws Exception { -091 return !rs.isAlive(); -092 } -093 -094 @Override -095 public String explainFailure() throws Exception { -096 return rs + " is still alive"; -097 } -098 }); -099 -100 int newCount = TEST_UTIL.countRows(table); -101 assertEquals(count, newCount); -102 table.close(); -103 } -104} +084 RegionServerThread rsThread = TEST_UTIL.getHBaseCluster().getRegionServerThreads().get(0); +085 TEST_UTIL.expireRegionServerSession(0); +086 // make sure that the RS is fully down before reading, so that we will read the data from other +087 // RSes. +088 TEST_UTIL.waitFor(30000, new ExplainingPredicate<Exception>() { +089 +090 @Override +091 public boolean evaluate() throws Exception { +092 return !rsThread.isAlive(); +093 } +094 +095 @Override +096 public String explainFailure() throws Exception { +097 return rsThread.getRegionServer() + " is still alive"; +098 } +099 }); +100 +101 int newCount = TEST_UTIL.countRows(table); +102 assertEquals(count, newCount); +103 table.close(); +104 } +105} http://git-wip-us.apache.org/repos/asf/hbase-site/blob/ac54a6a8/testdevapidocs/src-html/org/apache/hadoop/hbase/TestRegionLoad.html ---------------------------------------------------------------------- diff --git a/testdevapidocs/src-html/org/apache/hadoop/hbase/TestRegionLoad.html b/testdevapidocs/src-html/org/apache/hadoop/hbase/TestRegionLoad.html index ae35f56..1542672 100644 --- a/testdevapidocs/src-html/org/apache/hadoop/hbase/TestRegionLoad.html +++ b/testdevapidocs/src-html/org/apache/hadoop/hbase/TestRegionLoad.html @@ -6,7 +6,7 @@
-
001/**
+
001/*
 002 * Licensed to the Apache Software Foundation (ASF) under one
 003 * or more contributor license agreements.  See the NOTICE file
 004 * distributed with this work for additional information
@@ -72,114 +72,118 @@
 064
 065  @BeforeClass
 066  public static void beforeClass() throws Exception {
-067    UTIL.startMiniCluster(4);
-068    admin = UTIL.getAdmin();
-069    admin.setBalancerRunning(false, true);
-070    createTables();
-071  }
-072
-073  @AfterClass
-074  public static void afterClass() throws Exception {
-075    UTIL.shutdownMiniCluster();
-076  }
-077
-078  private static void createTables() throws IOException, InterruptedException {
-079    byte[][] FAMILIES = new byte [][] {Bytes.toBytes("f")};
-080    for (TableName tableName : tables) {
-081      Table table =
-082          UTIL.createTable(tableName, FAMILIES, HBaseTestingUtility.KEYS_FOR_HBA_CREATE_TABLE);
-083      UTIL.waitTableAvailable(tableName);
-084      UTIL.loadTable(table, FAMILIES[0]);
-085    }
-086  }
-087
-088  @Test
-089  public void testRegionLoad() throws Exception {
+067    // Make servers report eagerly. This test is about looking at the cluster status reported.
+068    // Make it so we don't have to wait around too long to see change.
+069    UTIL.getConfiguration().setInt("hbase.regionserver.msginterval", 500);
+070    UTIL.startMiniCluster(4);
+071    admin = UTIL.getAdmin();
+072    admin.setBalancerRunning(false, true);
+073    createTables();
+074  }
+075
+076  @AfterClass
+077  public static void afterClass() throws Exception {
+078    UTIL.shutdownMiniCluster();
+079  }
+080
+081  private static void createTables() throws IOException, InterruptedException {
+082    byte[][] FAMILIES = new byte [][] {Bytes.toBytes("f")};
+083    for (TableName tableName : tables) {
+084      Table table =
+085          UTIL.createTable(tableName, FAMILIES, HBaseTestingUtility.KEYS_FOR_HBA_CREATE_TABLE);
+086      UTIL.waitTableAvailable(tableName);
+087      UTIL.loadTable(table, FAMILIES[0]);
+088    }
+089  }
 090
-091    // Check if regions match with the regionLoad from the server
-092    for (ServerName serverName : admin
-093        .getClusterMetrics(EnumSet.of(Option.LIVE_SERVERS)).getLiveServerMetrics().keySet()) {
-094      List<HRegionInfo> regions = admin.getOnlineRegions(serverName);
-095      LOG.info("serverName=" + serverName + ", regions=" +
-096          regions.stream().map(r -> r.getRegionNameAsString()).collect(Collectors.toList()));
-097      Collection<RegionLoad> regionLoads = admin.getRegionMetrics(serverName)
-098        .stream().map(r -> new RegionLoad(r)).collect(Collectors.toList());
-099      LOG.info("serverName=" + serverName + ", regionLoads=" +
-100          regionLoads.stream().map(r -> Bytes.toString(r.getRegionName())).
-101              collect(Collectors.toList()));
-102      checkRegionsAndRegionLoads(regions, regionLoads);
-103    }
-104
-105    // Check if regionLoad matches the table's regions and nothing is missed
-106    for (TableName table : new TableName[]{TABLE_1, TABLE_2, TABLE_3}) {
-107      List<HRegionInfo> tableRegions = admin.getTableRegions(table);
-108
-109      List<RegionLoad> regionLoads = Lists.newArrayList();
-110      for (ServerName serverName : admin
-111          .getClusterMetrics(EnumSet.of(Option.LIVE_SERVERS)).getLiveServerMetrics().keySet()) {
-112        regionLoads.addAll(admin.getRegionMetrics(serverName, table)
-113          .stream().map(r -> new RegionLoad(r)).collect(Collectors.toList()));
-114      }
-115      checkRegionsAndRegionLoads(tableRegions, regionLoads);
-116    }
-117
-118    // Just wait here. If this fixes the test, come back and do a better job.
-119    // Thought is that cluster status is stale.
-120    Threads.sleep(10000);
+091  @Test
+092  public void testRegionLoad() throws Exception {
+093
+094    // Check if regions match with the regionLoad from the server
+095    for (ServerName serverName : admin
+096        .getClusterMetrics(EnumSet.of(Option.LIVE_SERVERS)).getLiveServerMetrics().keySet()) {
+097      List<HRegionInfo> regions = admin.getOnlineRegions(serverName);
+098      LOG.info("serverName=" + serverName + ", regions=" +
+099          regions.stream().map(r -> r.getRegionNameAsString()).collect(Collectors.toList()));
+100      Collection<RegionLoad> regionLoads = admin.getRegionMetrics(serverName)
+101        .stream().map(r -> new RegionLoad(r)).collect(Collectors.toList());
+102      LOG.info("serverName=" + serverName + ", regionLoads=" +
+103          regionLoads.stream().map(r -> Bytes.toString(r.getRegionName())).
+104              collect(Collectors.toList()));
+105      checkRegionsAndRegionLoads(regions, regionLoads);
+106    }
+107
+108    // Check if regionLoad matches the table's regions and nothing is missed
+109    for (TableName table : new TableName[]{TABLE_1, TABLE_2, TABLE_3}) {
+110      List<HRegionInfo> tableRegions = admin.getTableRegions(table);
+111
+112      List<RegionLoad> regionLoads = Lists.newArrayList();
+113      for (ServerName serverName : admin
+114          .getClusterMetrics(EnumSet.of(Option.LIVE_SERVERS)).getLiveServerMetrics().keySet()) {
+115        regionLoads.addAll(admin.getRegionMetrics(serverName, table)
+116          .stream().map(r -> new RegionLoad(r)).collect(Collectors.toList()));
+117      }
+118      checkRegionsAndRegionLoads(tableRegions, regionLoads);
+119    }
+120    int pause = UTIL.getConfiguration().getInt("hbase.regionserver.msginterval", 3000);
 121
-122    // Check RegionLoad matches the regionLoad from ClusterStatus
-123    ClusterStatus clusterStatus
-124      = new ClusterStatus(admin.getClusterMetrics(EnumSet.of(Option.LIVE_SERVERS)));
-125    for (ServerName serverName : clusterStatus.getServers()) {
-126      ServerLoad serverLoad = clusterStatus.getLoad(serverName);
-127      Map<byte[], RegionLoad> regionLoads = admin.getRegionMetrics(serverName).stream()
-128        .collect(Collectors.toMap(e -> e.getRegionName(), e -> new RegionLoad(e),
-129          (v1, v2) -> {
-130            throw new RuntimeException("impossible!!");
-131          }, () -> new TreeMap<>(Bytes.BYTES_COMPARATOR)));
-132      LOG.info("serverName=" + serverName + ", getRegionLoads=" +
-133          serverLoad.getRegionsLoad().keySet().stream().map(r -> Bytes.toString(r)).
-134              collect(Collectors.toList()));
-135      LOG.info("serverName=" + serverName + ", regionLoads=" +
-136          regionLoads.keySet().stream().map(r -> Bytes.toString(r)).
-137              collect(Collectors.toList()));
-138      compareRegionLoads(serverLoad.getRegionsLoad(), regionLoads);
-139    }
-140  }
-141
-142  private void compareRegionLoads(Map<byte[], RegionLoad> regionLoadCluster,
-143      Map<byte[], RegionLoad> regionLoads) {
-144
-145    assertEquals("No of regionLoads from clusterStatus and regionloads from RS doesn't match",
-146        regionLoadCluster.size(), regionLoads.size());
-147
-148    // The contents of region load from cluster and server should match
-149    for (byte[] regionName : regionLoadCluster.keySet()) {
-150      regionLoads.remove(regionName);
-151    }
-152    assertEquals("regionLoads from SN should be empty", 0, regionLoads.size());
-153  }
-154
-155  private void checkRegionsAndRegionLoads(Collection<HRegionInfo> regions,
-156      Collection<RegionLoad> regionLoads) {
-157
-158    for (RegionLoad load : regionLoads) {
-159      assertNotNull(load.regionLoadPB);
-160    }
+122    // Just wait here. If this fixes the test, come back and do a better job.
+123    // Would have to redo the below so can wait on cluster status changing.
+124    Threads.sleep(2 * pause);
+125
+126    // Check RegionLoad matches the regionLoad from ClusterStatus
+127    ClusterStatus clusterStatus
+128      = new ClusterStatus(admin.getClusterMetrics(EnumSet.of(Option.LIVE_SERVERS)));
+129    for (ServerName serverName : clusterStatus.getServers()) {
+130      ServerLoad serverLoad = clusterStatus.getLoad(serverName);
+131      Map<byte[], RegionLoad> regionLoads = admin.getRegionMetrics(serverName).stream()
+132        .collect(Collectors.toMap(e -> e.getRegionName(), e -> new RegionLoad(e),
+133          (v1, v2) -> {
+134            throw new RuntimeException("impossible!!");
+135          }, () -> new TreeMap<>(Bytes.BYTES_COMPARATOR)));
+136      LOG.info("serverName=" + serverName + ", getRegionLoads=" +
+137          serverLoad.getRegionsLoad().keySet().stream().map(r -> Bytes.toString(r)).
+138              collect(Collectors.toList()));
+139      LOG.info("serverName=" + serverName + ", regionLoads=" +
+140          regionLoads.keySet().stream().map(r -> Bytes.toString(r)).
+141              collect(Collectors.toList()));
+142      compareRegionLoads(serverLoad.getRegionsLoad(), regionLoads);
+143    }
+144  }
+145
+146  private void compareRegionLoads(Map<byte[], RegionLoad> regionLoadCluster,
+147      Map<byte[], RegionLoad> regionLoads) {
+148
+149    assertEquals("No of regionLoads from clusterStatus and regionloads from RS doesn't match",
+150        regionLoadCluster.size(), regionLoads.size());
+151
+152    // The contents of region load from cluster and server should match
+153    for (byte[] regionName : regionLoadCluster.keySet()) {
+154      regionLoads.remove(regionName);
+155    }
+156    assertEquals("regionLoads from SN should be empty", 0, regionLoads.size());
+157  }
+158
+159  private void checkRegionsAndRegionLoads(Collection<HRegionInfo> regions,
+160      Collection<RegionLoad> regionLoads) {
 161
-162    assertEquals("No of regions and regionloads doesn't match",
-163        regions.size(), regionLoads.size());
-164
-165    Map<byte[], RegionLoad> regionLoadMap = Maps.newTreeMap(Bytes.BYTES_COMPARATOR);
-166    for (RegionLoad regionLoad : regionLoads) {
-167      regionLoadMap.put(regionLoad.getName(), regionLoad);
-168    }
-169    for (HRegionInfo info : regions) {
-170      assertTrue("Region not in regionLoadMap region:" + info.getRegionNameAsString() +
-171          " regionMap: " + regionLoadMap, regionLoadMap.containsKey(info.getRegionName()));
+162    for (RegionLoad load : regionLoads) {
+163      assertNotNull(load.regionLoadPB);
+164    }
+165
+166    assertEquals("No of regions and regionloads doesn't match",
+167        regions.size(), regionLoads.size());
+168
+169    Map<byte[], RegionLoad> regionLoadMap = Maps.newTreeMap(Bytes.BYTES_COMPARATOR);
+170    for (RegionLoad regionLoad : regionLoads) {
+171      regionLoadMap.put(regionLoad.getName(), regionLoad);
 172    }
-173  }
-174}
+173    for (HRegionInfo info : regions) {
+174      assertTrue("Region not in regionLoadMap region:" + info.getRegionNameAsString() +
+175          " regionMap: " + regionLoadMap, regionLoadMap.containsKey(info.getRegionName()));
+176    }
+177  }
+178}
 
 
 

http://git-wip-us.apache.org/repos/asf/hbase-site/blob/ac54a6a8/testdevapidocs/src-html/org/apache/hadoop/hbase/TestServerName.html
----------------------------------------------------------------------
diff --git a/testdevapidocs/src-html/org/apache/hadoop/hbase/TestServerName.html b/testdevapidocs/src-html/org/apache/hadoop/hbase/TestServerName.html
index deec5e2..a258375 100644
--- a/testdevapidocs/src-html/org/apache/hadoop/hbase/TestServerName.html
+++ b/testdevapidocs/src-html/org/apache/hadoop/hbase/TestServerName.html
@@ -30,100 +30,113 @@
 022import static org.junit.Assert.assertNotSame;
 023import static org.junit.Assert.assertTrue;
 024
-025import java.util.regex.Pattern;
-026import org.apache.hadoop.hbase.testclassification.MiscTests;
-027import org.apache.hadoop.hbase.testclassification.SmallTests;
-028import org.apache.hadoop.hbase.util.Addressing;
-029import org.apache.hadoop.hbase.util.Bytes;
-030import org.junit.ClassRule;
-031import org.junit.Test;
-032import org.junit.experimental.categories.Category;
-033
-034@Category({MiscTests.class, SmallTests.class})
-035public class TestServerName {
-036
-037  @ClassRule
-038  public static final HBaseClassTestRule CLASS_RULE =
-039      HBaseClassTestRule.forClass(TestServerName.class);
-040
-041  @Test
-042  public void testGetHostNameMinusDomain() {
-043    assertEquals("2607:f0d0:1002:51::4",
-044      ServerName.getHostNameMinusDomain("2607:f0d0:1002:51::4"));
-045    assertEquals("2607:f0d0:1002:0051:0000:0000:0000:0004",
-046        ServerName.getHostNameMinusDomain("2607:f0d0:1002:0051:0000:0000:0000:0004"));
-047    assertEquals("1.1.1.1", ServerName.getHostNameMinusDomain("1.1.1.1"));
-048    assertEquals("x", ServerName.getHostNameMinusDomain("x"));
-049    assertEquals("x", ServerName.getHostNameMinusDomain("x.y.z"));
-050    assertEquals("asf000", ServerName.getHostNameMinusDomain("asf000.sp2.ygridcore.net"));
-051    ServerName sn = ServerName.valueOf("asf000.sp2.ygridcore.net", 1, 1);
-052    assertEquals("asf000.sp2.ygridcore.net,1,1", sn.toString());
-053  }
-054
-055  @Test
-056  public void testShortString() {
-057    ServerName sn = ServerName.valueOf("asf000.sp2.ygridcore.net", 1, 1);
-058    assertEquals("asf000:1", sn.toShortString());
-059    sn = ServerName.valueOf("2607:f0d0:1002:0051:0000:0000:0000:0004", 1, 1);
-060    assertEquals("2607:f0d0:1002:0051:0000:0000:0000:0004:1", sn.toShortString());
-061    sn = ServerName.valueOf("1.1.1.1", 1, 1);
-062    assertEquals("1.1.1.1:1", sn.toShortString());
-063  }
-064
-065  @Test
-066  public void testRegexPatterns() {
-067    assertTrue(Pattern.matches(Addressing.VALID_PORT_REGEX, "123"));
-068    assertFalse(Pattern.matches(Addressing.VALID_PORT_REGEX, ""));
-069    assertTrue(ServerName.SERVERNAME_PATTERN.matcher("www1.example.org,1234,567").matches());
-070    ServerName.parseServerName("a.b.c,58102,1319771740322");
-071    ServerName.parseServerName("192.168.1.199,58102,1319771740322");
-072    ServerName.parseServerName("a.b.c:58102");
-073    ServerName.parseServerName("192.168.1.199:58102");
-074  }
-075
-076  @Test public void testParseOfBytes() {
-077    final String snStr = "www.example.org,1234,5678";
-078    ServerName sn = ServerName.valueOf(snStr);
-079    byte [] versionedBytes = sn.getVersionedBytes();
-080    assertEquals(sn.toString(), ServerName.parseVersionedServerName(versionedBytes).toString());
-081    final String hostnamePortStr = sn.getHostAndPort();
-082    byte [] bytes = Bytes.toBytes(hostnamePortStr);
-083    String expecting =
-084      hostnamePortStr.replace(":", ServerName.SERVERNAME_SEPARATOR) +
-085      ServerName.SERVERNAME_SEPARATOR + ServerName.NON_STARTCODE;
-086    assertEquals(expecting, ServerName.parseVersionedServerName(bytes).toString());
+025import java.util.HashSet;
+026import java.util.Set;
+027import java.util.regex.Pattern;
+028import org.apache.hadoop.hbase.testclassification.MiscTests;
+029import org.apache.hadoop.hbase.testclassification.SmallTests;
+030import org.apache.hadoop.hbase.util.Addressing;
+031import org.apache.hadoop.hbase.util.Bytes;
+032import org.junit.ClassRule;
+033import org.junit.Test;
+034import org.junit.experimental.categories.Category;
+035
+036@Category({MiscTests.class, SmallTests.class})
+037public class TestServerName {
+038
+039  @ClassRule
+040  public static final HBaseClassTestRule CLASS_RULE =
+041      HBaseClassTestRule.forClass(TestServerName.class);
+042
+043  @Test
+044  public void testHash() {
+045    ServerName sn1 = ServerName.parseServerName("asf903.gq1.ygridcore.net,52690,1517835491385");
+046    ServerName sn2 = ServerName.parseServerName("asf903.gq1.ygridcore.net,42231,1517835491329");
+047    Set<ServerName> sns = new HashSet<ServerName>();
+048    sns.add(sn2);
+049    sns.add(sn1);
+050    sns.add(sn1);
+051    assertEquals(2, sns.size());
+052  }
+053
+054  @Test
+055  public void testGetHostNameMinusDomain() {
+056    assertEquals("2607:f0d0:1002:51::4",
+057      ServerName.getHostNameMinusDomain("2607:f0d0:1002:51::4"));
+058    assertEquals("2607:f0d0:1002:0051:0000:0000:0000:0004",
+059        ServerName.getHostNameMinusDomain("2607:f0d0:1002:0051:0000:0000:0000:0004"));
+060    assertEquals("1.1.1.1", ServerName.getHostNameMinusDomain("1.1.1.1"));
+061    assertEquals("x", ServerName.getHostNameMinusDomain("x"));
+062    assertEquals("x", ServerName.getHostNameMinusDomain("x.y.z"));
+063    assertEquals("asf000", ServerName.getHostNameMinusDomain("asf000.sp2.ygridcore.net"));
+064    ServerName sn = ServerName.valueOf("asf000.sp2.ygridcore.net", 1, 1);
+065    assertEquals("asf000.sp2.ygridcore.net,1,1", sn.toString());
+066  }
+067
+068  @Test
+069  public void testShortString() {
+070    ServerName sn = ServerName.valueOf("asf000.sp2.ygridcore.net", 1, 1);
+071    assertEquals("asf000:1", sn.toShortString());
+072    sn = ServerName.valueOf("2607:f0d0:1002:0051:0000:0000:0000:0004", 1, 1);
+073    assertEquals("2607:f0d0:1002:0051:0000:0000:0000:0004:1", sn.toShortString());
+074    sn = ServerName.valueOf("1.1.1.1", 1, 1);
+075    assertEquals("1.1.1.1:1", sn.toShortString());
+076  }
+077
+078  @Test
+079  public void testRegexPatterns() {
+080    assertTrue(Pattern.matches(Addressing.VALID_PORT_REGEX, "123"));
+081    assertFalse(Pattern.matches(Addressing.VALID_PORT_REGEX, ""));
+082    assertTrue(ServerName.SERVERNAME_PATTERN.matcher("www1.example.org,1234,567").matches());
+083    ServerName.parseServerName("a.b.c,58102,1319771740322");
+084    ServerName.parseServerName("192.168.1.199,58102,1319771740322");
+085    ServerName.parseServerName("a.b.c:58102");
+086    ServerName.parseServerName("192.168.1.199:58102");
 087  }
 088
-089  @Test
-090  public void testServerName() {
-091    ServerName sn = ServerName.valueOf("www.example.org", 1234, 5678);
-092    ServerName sn2 = ServerName.valueOf("www.example.org", 1234, 5678);
-093    ServerName sn3 = ServerName.valueOf("www.example.org", 1234, 56789);
-094    assertTrue(sn.equals(sn2));
-095    assertFalse(sn.equals(sn3));
-096    assertEquals(sn.hashCode(), sn2.hashCode());
-097    assertNotSame(sn.hashCode(), sn3.hashCode());
-098    assertEquals(sn.toString(),
-099      ServerName.valueOf("www.example.org", 1234, 5678).toString());
-100    assertEquals(sn.toString(),
-101      ServerName.valueOf("www.example.org:1234", 5678).toString());
-102    assertEquals("www.example.org" + ServerName.SERVERNAME_SEPARATOR + "1234"
-103        + ServerName.SERVERNAME_SEPARATOR + "5678", sn.toString());
-104  }
-105
-106  @Test
-107  public void testHostNameCaseSensitivity() {
-108    ServerName lower = ServerName.valueOf("www.example.org", 1234, 5678);
-109    ServerName upper = ServerName.valueOf("www.EXAMPLE.org", 1234, 5678);
-110    assertEquals(0, lower.compareTo(upper));
-111    assertEquals(0, upper.compareTo(lower));
-112    assertEquals(lower.hashCode(), upper.hashCode());
-113    assertTrue(lower.equals(upper));
-114    assertTrue(upper.equals(lower));
-115    assertTrue(ServerName.isSameAddress(lower, upper));
-116  }
-117}
+089  @Test public void testParseOfBytes() {
+090    final String snStr = "www.example.org,1234,5678";
+091    ServerName sn = ServerName.valueOf(snStr);
+092    byte [] versionedBytes = sn.getVersionedBytes();
+093    assertEquals(sn.toString(), ServerName.parseVersionedServerName(versionedBytes).toString());
+094    final String hostnamePortStr = sn.getHostAndPort();
+095    byte [] bytes = Bytes.toBytes(hostnamePortStr);
+096    String expecting =
+097      hostnamePortStr.replace(":", ServerName.SERVERNAME_SEPARATOR) +
+098      ServerName.SERVERNAME_SEPARATOR + ServerName.NON_STARTCODE;
+099    assertEquals(expecting, ServerName.parseVersionedServerName(bytes).toString());
+100  }
+101
+102  @Test
+103  public void testServerName() {
+104    ServerName sn = ServerName.valueOf("www.example.org", 1234, 5678);
+105    ServerName sn2 = ServerName.valueOf("www.example.org", 1234, 5678);
+106    ServerName sn3 = ServerName.valueOf("www.example.org", 1234, 56789);
+107    assertTrue(sn.equals(sn2));
+108    assertFalse(sn.equals(sn3));
+109    assertEquals(sn.hashCode(), sn2.hashCode());
+110    assertNotSame(sn.hashCode(), sn3.hashCode());
+111    assertEquals(sn.toString(),
+112      ServerName.valueOf("www.example.org", 1234, 5678).toString());
+113    assertEquals(sn.toString(),
+114      ServerName.valueOf("www.example.org:1234", 5678).toString());
+115    assertEquals("www.example.org" + ServerName.SERVERNAME_SEPARATOR + "1234"
+116        + ServerName.SERVERNAME_SEPARATOR + "5678", sn.toString());
+117  }
 118
+119  @Test
+120  public void testHostNameCaseSensitivity() {
+121    ServerName lower = ServerName.valueOf("www.example.org", 1234, 5678);
+122    ServerName upper = ServerName.valueOf("www.EXAMPLE.org", 1234, 5678);
+123    assertEquals(0, lower.compareTo(upper));
+124    assertEquals(0, upper.compareTo(lower));
+125    assertEquals(lower.hashCode(), upper.hashCode());
+126    assertTrue(lower.equals(upper));
+127    assertTrue(upper.equals(lower));
+128    assertTrue(ServerName.isSameAddress(lower, upper));
+129  }
+130}
+131