当前位置: 首页>>代码示例>>Java>>正文


Java ServerName.isSameHostnameAndPort方法代码示例

本文整理汇总了Java中org.apache.hadoop.hbase.ServerName.isSameHostnameAndPort方法的典型用法代码示例。如果您正苦于以下问题:Java ServerName.isSameHostnameAndPort方法的具体用法?Java ServerName.isSameHostnameAndPort怎么用?Java ServerName.isSameHostnameAndPort使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.hadoop.hbase.ServerName的用法示例。


在下文中一共展示了ServerName.isSameHostnameAndPort方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getFavoredServerPosition

import org.apache.hadoop.hbase.ServerName; //导入方法依赖的package包/类
/**
 * Return the position of the server in the favoredNodes list. Assumes the
 * favoredNodes list is of size 3.
 * @param favoredNodes
 * @param server
 * @return position
 */
public static Position getFavoredServerPosition(
    List<ServerName> favoredNodes, ServerName server) {
  if (favoredNodes == null || server == null ||
      favoredNodes.size() != FavoredNodeAssignmentHelper.FAVORED_NODES_NUM) {
    return null;
  }
  for (Position p : Position.values()) {
    if (ServerName.isSameHostnameAndPort(favoredNodes.get(p.ordinal()),server)) {
      return p;
    }
  }
  return null;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:21,代码来源:FavoredNodesPlan.java

示例2: availableServersContains

import org.apache.hadoop.hbase.ServerName; //导入方法依赖的package包/类
private ServerName availableServersContains(List<ServerName> servers, ServerName favoredNode) {
  for (ServerName server : servers) {
    if (ServerName.isSameHostnameAndPort(favoredNode, server)) {
      return server;
    }
  }
  return null;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:9,代码来源:FavoredNodeLoadBalancer.java

示例3: findServerWithSameHostnamePortWithLock

import org.apache.hadoop.hbase.ServerName; //导入方法依赖的package包/类
/**
 * Assumes onlineServers is locked.
 * @return ServerName with matching hostname and port.
 */
private ServerName findServerWithSameHostnamePortWithLock(
    final ServerName serverName) {
  for (ServerName sn: this.onlineServers.keySet()) {
    if (ServerName.isSameHostnameAndPort(serverName, sn)) return sn;
  }
  return null;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:12,代码来源:ServerManager.java

示例4: cleanPreviousInstance

import org.apache.hadoop.hbase.ServerName; //导入方法依赖的package包/类
/**
 * A dead server that comes back alive has a different start code. The new start code should be
 *  greater than the old one, but we don't take this into account in this method.
 *
 * @param newServerName Servername as either <code>host:port</code> or
 *                      <code>host,port,startcode</code>.
 * @return true if this server was dead before and coming back alive again
 */
public synchronized boolean cleanPreviousInstance(final ServerName newServerName) {
  Iterator<ServerName> it = deadServers.keySet().iterator();
  while (it.hasNext()) {
    ServerName sn = it.next();
    if (ServerName.isSameHostnameAndPort(sn, newServerName)) {
      it.remove();
      return true;
    }
  }

  return false;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:21,代码来源:DeadServer.java

示例5: cleanAllPreviousInstances

import org.apache.hadoop.hbase.ServerName; //导入方法依赖的package包/类
public synchronized void cleanAllPreviousInstances(final ServerName newServerName) {
  Iterator<ServerName> it = deadServers.keySet().iterator();
  while (it.hasNext()) {
    ServerName sn = it.next();
    if (ServerName.isSameHostnameAndPort(sn, newServerName)) {
      it.remove();
    }
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:10,代码来源:DeadServer.java

示例6: addToMovedRegions

import org.apache.hadoop.hbase.ServerName; //导入方法依赖的package包/类
protected void addToMovedRegions(String encodedName, ServerName destination, long closeSeqNum) {
  if (ServerName.isSameHostnameAndPort(destination, this.getServerName())) {
    LOG.warn("Not adding moved region record: " + encodedName + " to self.");
    return;
  }
  LOG.info("Adding moved region record: " + encodedName + " to " + destination + " as of "
      + closeSeqNum);
  movedRegions.put(encodedName, new MovedRegionInfo(destination, closeSeqNum));
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:10,代码来源:HRegionServer.java

示例7: removeMatchingServers

import org.apache.hadoop.hbase.ServerName; //导入方法依赖的package包/类
private List<ServerName> removeMatchingServers(ServerName serverWithoutStartCode,
    List<ServerName> servers) {
  List<ServerName> serversToRemove = new ArrayList<ServerName>();
  for (ServerName s : servers) {
    if (ServerName.isSameHostnameAndPort(s, serverWithoutStartCode)) {
      serversToRemove.add(s);
    }
  }
  servers.removeAll(serversToRemove);
  return serversToRemove;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:12,代码来源:TestRegionPlacement2.java

示例8: testAssignOfflinedRegionBySSH

import org.apache.hadoop.hbase.ServerName; //导入方法依赖的package包/类
/**
 * Test offlined region is assigned by SSH
 */
@Test (timeout=60000)
public void testAssignOfflinedRegionBySSH() throws Exception {
  String table = "testAssignOfflinedRegionBySSH";
  MiniHBaseCluster cluster = TEST_UTIL.getHBaseCluster();
  MyMaster master = null;
  try {
    HTableDescriptor desc = new HTableDescriptor(TableName.valueOf(table));
    desc.addFamily(new HColumnDescriptor(FAMILY));
    admin.createTable(desc);

    Table meta = new HTable(conf, TableName.META_TABLE_NAME);
    HRegionInfo hri = new HRegionInfo(
      desc.getTableName(), Bytes.toBytes("A"), Bytes.toBytes("Z"));
    MetaTableAccessor.addRegionToMeta(meta, hri);

    // Assign the region
    master = (MyMaster)cluster.getMaster();
    master.assignRegion(hri);

    AssignmentManager am = master.getAssignmentManager();
    RegionStates regionStates = am.getRegionStates();
    ServerName metaServer = regionStates.getRegionServerOfRegion(
      HRegionInfo.FIRST_META_REGIONINFO);
    ServerName oldServerName = null;
    while (true) {
      assertTrue(am.waitForAssignment(hri));
      RegionState state = regionStates.getRegionState(hri);
      oldServerName = state.getServerName();
      if (!ServerName.isSameHostnameAndPort(oldServerName, metaServer)) {
        // Mark the hosting server aborted, but don't actually kill it.
        // It doesn't have meta on it.
        MyRegionServer.abortedServer = oldServerName;
        break;
      }
      int i = cluster.getServerWithMeta();
      HRegionServer rs = cluster.getRegionServer(i == 0 ? 1 : 0);
      oldServerName = rs.getServerName();
      master.move(hri.getEncodedNameAsBytes(),
        Bytes.toBytes(oldServerName.getServerName()));
    }

    // Make sure the region is assigned on the dead server
    assertTrue(regionStates.isRegionOnline(hri));
    assertEquals(oldServerName, regionStates.getRegionServerOfRegion(hri));

    // Kill the hosting server, which doesn't have meta on it.
    cluster.killRegionServer(oldServerName);
    cluster.waitForRegionServerToStop(oldServerName, -1);

    ServerManager serverManager = master.getServerManager();
    while (!serverManager.isServerDead(oldServerName)
        || serverManager.getDeadServers().areDeadServersInProgress()) {
      Thread.sleep(100);
    }

    // Let's check if it's assigned after it's out of transition.
    // no need to assign it manually, SSH should do it
    am.waitOnRegionToClearRegionsInTransition(hri);
    assertTrue(am.waitForAssignment(hri));

    ServerName serverName = master.getAssignmentManager().
      getRegionStates().getRegionServerOfRegion(hri);
    TEST_UTIL.assertRegionOnlyOnServer(hri, serverName, 200);
  } finally {
    MyRegionServer.abortedServer = null;
    TEST_UTIL.deleteTable(Bytes.toBytes(table));
    cluster.startRegionServer();
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:73,代码来源:TestAssignmentManagerOnCluster.java

示例9: testAssignDisabledRegionBySSH

import org.apache.hadoop.hbase.ServerName; //导入方法依赖的package包/类
/**
 * Test disabled region is ignored by SSH
 */
@Test (timeout=60000)
public void testAssignDisabledRegionBySSH() throws Exception {
  String table = "testAssignDisabledRegionBySSH";
  MiniHBaseCluster cluster = TEST_UTIL.getHBaseCluster();
  MyMaster master = null;
  try {
    HTableDescriptor desc = new HTableDescriptor(TableName.valueOf(table));
    desc.addFamily(new HColumnDescriptor(FAMILY));
    admin.createTable(desc);

    Table meta = new HTable(conf, TableName.META_TABLE_NAME);
    HRegionInfo hri = new HRegionInfo(
      desc.getTableName(), Bytes.toBytes("A"), Bytes.toBytes("Z"));
    MetaTableAccessor.addRegionToMeta(meta, hri);

    // Assign the region
    master = (MyMaster)cluster.getMaster();
    master.assignRegion(hri);

    AssignmentManager am = master.getAssignmentManager();
    RegionStates regionStates = am.getRegionStates();
    ServerName metaServer = regionStates.getRegionServerOfRegion(
      HRegionInfo.FIRST_META_REGIONINFO);
    ServerName oldServerName = null;
    while (true) {
      assertTrue(am.waitForAssignment(hri));
      RegionState state = regionStates.getRegionState(hri);
      oldServerName = state.getServerName();
      if (!ServerName.isSameHostnameAndPort(oldServerName, metaServer)) {
        // Mark the hosting server aborted, but don't actually kill it.
        // It doesn't have meta on it.
        MyRegionServer.abortedServer = oldServerName;
        break;
      }
      int i = cluster.getServerWithMeta();
      HRegionServer rs = cluster.getRegionServer(i == 0 ? 1 : 0);
      oldServerName = rs.getServerName();
      master.move(hri.getEncodedNameAsBytes(),
        Bytes.toBytes(oldServerName.getServerName()));
    }

    // Make sure the region is assigned on the dead server
    assertTrue(regionStates.isRegionOnline(hri));
    assertEquals(oldServerName, regionStates.getRegionServerOfRegion(hri));

    // Disable the table now.
    master.disableTable(hri.getTable(), HConstants.NO_NONCE, HConstants.NO_NONCE);

    // Kill the hosting server, which doesn't have meta on it.
    cluster.killRegionServer(oldServerName);
    cluster.waitForRegionServerToStop(oldServerName, -1);

    ServerManager serverManager = master.getServerManager();
    while (!serverManager.isServerDead(oldServerName)
        || serverManager.getDeadServers().areDeadServersInProgress()) {
      Thread.sleep(100);
    }

    // Wait till no more RIT, the region should be offline.
    am.waitUntilNoRegionsInTransition(60000);
    assertTrue(regionStates.isRegionOffline(hri));
  } finally {
    MyRegionServer.abortedServer = null;
    TEST_UTIL.deleteTable(Bytes.toBytes(table));
    cluster.startRegionServer();
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:71,代码来源:TestAssignmentManagerOnCluster.java


注:本文中的org.apache.hadoop.hbase.ServerName.isSameHostnameAndPort方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。