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


Java RegionOpeningState类代码示例

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


RegionOpeningState类属于org.apache.hadoop.hbase.regionserver包,在下文中一共展示了RegionOpeningState类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: sendRegionOpen

import org.apache.hadoop.hbase.regionserver.RegionOpeningState; //导入依赖的package包/类
/**
 * Sends an OPEN RPC to the specified server to open the specified region.
 * <p>
 * Open should not fail but can if server just crashed.
 * <p>
 * @param server server to open a region
 * @param region region to open
 * @param versionOfOfflineNode that needs to be present in the offline node
 * when RS tries to change the state from OFFLINE to other states.
 * @param favoredNodes
 */
public RegionOpeningState sendRegionOpen(final ServerName server,
    HRegionInfo region, int versionOfOfflineNode, List<ServerName> favoredNodes)
throws IOException {
  AdminService.BlockingInterface admin = getRsAdmin(server);
  if (admin == null) {
    LOG.warn("Attempting to send OPEN RPC to server " + server.toString() +
      " failed because no RPC connection found to this server");
    return RegionOpeningState.FAILED_OPENING;
  }
  OpenRegionRequest request = RequestConverter.buildOpenRegionRequest(server, 
    region, versionOfOfflineNode, favoredNodes, 
    (RecoveryMode.LOG_REPLAY == this.services.getMasterFileSystem().getLogRecoveryMode()));
  try {
    OpenRegionResponse response = admin.openRegion(null, request);
    return ResponseConverter.getRegionOpeningState(response);
  } catch (ServiceException se) {
    throw ProtobufUtil.getRemoteException(se);
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:31,代码来源:ServerManager.java

示例2: sendRegionOpen

import org.apache.hadoop.hbase.regionserver.RegionOpeningState; //导入依赖的package包/类
/**
 * Sends an OPEN RPC to the specified server to open the specified region.
 * <p>
 * Open should not fail but can if server just crashed.
 * <p>
 * @param server server to open a region
 * @param region region to open
 * @param versionOfOfflineNode that needs to be present in the offline node
 * when RS tries to change the state from OFFLINE to other states.
 * @param favoredNodes
 */
public RegionOpeningState sendRegionOpen(final ServerName server,
    HRegionInfo region, int versionOfOfflineNode, List<ServerName> favoredNodes)
throws IOException {
  AdminService.BlockingInterface admin = getRsAdmin(server);
  if (admin == null) {
    LOG.warn("Attempting to send OPEN RPC to server " + server.toString() +
      " failed because no RPC connection found to this server");
    return RegionOpeningState.FAILED_OPENING;
  }
  OpenRegionRequest request =
    RequestConverter.buildOpenRegionRequest(server, region, versionOfOfflineNode, favoredNodes);
  try {
    OpenRegionResponse response = admin.openRegion(null, request);
    return ResponseConverter.getRegionOpeningState(response);
  } catch (ServiceException se) {
    throw ProtobufUtil.getRemoteException(se);
  }
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:30,代码来源:ServerManager.java

示例3: sendRegionOpen

import org.apache.hadoop.hbase.regionserver.RegionOpeningState; //导入依赖的package包/类
/**
 * Sends an OPEN RPC to the specified server to open the specified region.
 * <p>
 * Open should not fail but can if server just crashed.
 * <p>
 * @param server server to open a region
 * @param region region to open
 * @param versionOfOfflineNode that needs to be present in the offline node
 * when RS tries to change the state from OFFLINE to other states.
 * @param favoredNodes
 */
public RegionOpeningState sendRegionOpen(final ServerName server,
    HRegionInfo region, int versionOfOfflineNode, List<ServerName> favoredNodes)
throws IOException {
  AdminService.BlockingInterface admin = getRsAdmin(server);
  if (admin == null) {
    LOG.warn("Attempting to send OPEN RPC to server " + server.toString() +
      " failed because no RPC connection found to this server");
    return RegionOpeningState.FAILED_OPENING;
  }
  OpenRegionRequest request =
    RequestConverter.buildOpenRegionRequest(region, versionOfOfflineNode, favoredNodes);
  try {
    OpenRegionResponse response = admin.openRegion(null, request);
    return ResponseConverter.getRegionOpeningState(response);
  } catch (ServiceException se) {
    throw ProtobufUtil.getRemoteException(se);
  }
}
 
开发者ID:cloud-software-foundation,项目名称:c5,代码行数:30,代码来源:ServerManager.java

示例4: sendRegionOpen

import org.apache.hadoop.hbase.regionserver.RegionOpeningState; //导入依赖的package包/类
/**
 * Sends an OPEN RPC to the specified server to open the specified region.
 * <p>
 * Open should not fail but can if server just crashed.
 * <p>
 * @param server server to open a region
 * @param region region to open
 * @param versionOfOfflineNode that needs to be present in the offline node
 * when RS tries to change the state from OFFLINE to other states.
 */
public RegionOpeningState sendRegionOpen(final ServerName server,
    HRegionInfo region, int versionOfOfflineNode)
throws IOException {
  AdminProtocol admin = getServerConnection(server);
  if (admin == null) {
    LOG.warn("Attempting to send OPEN RPC to server " + server.toString() +
      " failed because no RPC connection found to this server");
    return RegionOpeningState.FAILED_OPENING;
  }
  OpenRegionRequest request =
    RequestConverter.buildOpenRegionRequest(region, versionOfOfflineNode);
  try {
    OpenRegionResponse response = admin.openRegion(null, request);
    return ResponseConverter.getRegionOpeningState(response);
  } catch (ServiceException se) {
    throw ProtobufUtil.getRemoteException(se);
  }
}
 
开发者ID:daidong,项目名称:DominoHBase,代码行数:29,代码来源:ServerManager.java

示例5: if

import org.apache.hadoop.hbase.regionserver.RegionOpeningState; //导入依赖的package包/类
/**
 * Get the region opening state from a OpenRegionResponse
 *
 * @param proto the OpenRegionResponse
 * @return the region opening state
 */
public static RegionOpeningState getRegionOpeningState
    (final OpenRegionResponse proto) {
  if (proto == null || proto.getOpeningStateCount() != 1) return null;
  return RegionOpeningState.valueOf(
    proto.getOpeningState(0).name());
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:13,代码来源:ResponseConverter.java

示例6: getRegionOpeningStateList

import org.apache.hadoop.hbase.regionserver.RegionOpeningState; //导入依赖的package包/类
/**
 * Get a list of region opening state from a OpenRegionResponse
 * 
 * @param proto the OpenRegionResponse
 * @return the list of region opening state
 */
public static List<RegionOpeningState> getRegionOpeningStateList(
    final OpenRegionResponse proto) {
  if (proto == null) return null;
  List<RegionOpeningState> regionOpeningStates = new ArrayList<RegionOpeningState>();
  for (int i = 0; i < proto.getOpeningStateCount(); i++) {
    regionOpeningStates.add(RegionOpeningState.valueOf(
        proto.getOpeningState(i).name()));
  }
  return regionOpeningStates;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:17,代码来源:ResponseConverter.java

示例7: sendRegionOpen

import org.apache.hadoop.hbase.regionserver.RegionOpeningState; //导入依赖的package包/类
/**
 * Sends an OPEN RPC to the specified server to open the specified region.
 * <p>
 * Open should not fail but can if server just crashed.
 * <p>
 * @param server server to open a region
 * @param region region to open
 * @param versionOfOfflineNode that needs to be present in the offline node
 * when RS tries to change the state from OFFLINE to other states.
 */
public RegionOpeningState sendRegionOpen(final ServerName server,
    HRegionInfo region, int versionOfOfflineNode)
throws IOException {
  HRegionInterface hri = getServerConnection(server);
  if (hri == null) {
    LOG.warn("Attempting to send OPEN RPC to server " + server.toString() +
      " failed because no RPC connection found to this server");
    return RegionOpeningState.FAILED_OPENING;
  }
  return (versionOfOfflineNode == -1) ? hri.openRegion(region) : hri
      .openRegion(region, versionOfOfflineNode);
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:23,代码来源:ServerManager.java

示例8: before

import org.apache.hadoop.hbase.regionserver.RegionOpeningState; //导入依赖的package包/类
@Before
public void before() throws ZooKeeperConnectionException, IOException {
  // TODO: Make generic versions of what we do below and put up in a mocking
  // utility class or move up into HBaseTestingUtility.

  // Mock a Server.  Have it return a legit Configuration and ZooKeeperWatcher.
  // If abort is called, be sure to fail the test (don't just swallow it
  // silently as is mockito default).
  this.server = Mockito.mock(Server.class);
  Mockito.when(server.getConfiguration()).thenReturn(HTU.getConfiguration());
  this.watcher =
    new ZooKeeperWatcher(HTU.getConfiguration(), "mockedServer", this.server, true);
  Mockito.when(server.getZooKeeper()).thenReturn(this.watcher);
  Mockito.doThrow(new RuntimeException("Aborted")).
    when(server).abort(Mockito.anyString(), (Throwable)Mockito.anyObject());

  // Mock a ServerManager.  Say server SERVERNAME_{A,B} are online.  Also
  // make it so if close or open, we return 'success'.
  this.serverManager = Mockito.mock(ServerManager.class);
  Mockito.when(this.serverManager.isServerOnline(SERVERNAME_A)).thenReturn(true);
  Mockito.when(this.serverManager.isServerOnline(SERVERNAME_B)).thenReturn(true);
  final Map<ServerName, HServerLoad> onlineServers = new HashMap<ServerName, HServerLoad>();
  onlineServers.put(SERVERNAME_B, new HServerLoad());
  onlineServers.put(SERVERNAME_A, new HServerLoad());
  Mockito.when(this.serverManager.getOnlineServersList()).thenReturn(
      new ArrayList<ServerName>(onlineServers.keySet()));
  Mockito.when(this.serverManager.getOnlineServers()).thenReturn(onlineServers);
  Mockito.when(this.serverManager.sendRegionClose(SERVERNAME_A, REGIONINFO, -1)).
    thenReturn(true);
  Mockito.when(this.serverManager.sendRegionClose(SERVERNAME_B, REGIONINFO, -1)).
    thenReturn(true);
  // Ditto on open.
  Mockito.when(this.serverManager.sendRegionOpen(SERVERNAME_A, REGIONINFO, -1)).
    thenReturn(RegionOpeningState.OPENED);
  Mockito.when(this.serverManager.sendRegionOpen(SERVERNAME_B, REGIONINFO, -1)).
  thenReturn(RegionOpeningState.OPENED);
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:38,代码来源:TestAssignmentManager.java

示例9: retrySendRegionOpen

import org.apache.hadoop.hbase.regionserver.RegionOpeningState; //导入依赖的package包/类
/**
 * At master failover, for pending_open region, make sure
 * sendRegionOpen RPC call is sent to the target regionserver
 */
private void retrySendRegionOpen(final RegionState regionState) {
  this.executorService.submit(
    new EventHandler(server, EventType.M_MASTER_RECOVERY) {
      @Override
      public void process() throws IOException {
        HRegionInfo hri = regionState.getRegion();
        ServerName serverName = regionState.getServerName();
        ReentrantLock lock = locker.acquireLock(hri.getEncodedName());
        try {
          for (int i = 1; i <= maximumAttempts; i++) {
            if (!serverManager.isServerOnline(serverName)
                || server.isStopped() || server.isAborted()) {
              return; // No need any more
            }
            try {
              if (!regionState.equals(regionStates.getRegionState(hri))) {
                return; // Region is not in the expected state any more
              }
              List<ServerName> favoredNodes = ServerName.EMPTY_SERVER_LIST;
              if (shouldAssignRegionsWithFavoredNodes) {
                favoredNodes = ((FavoredNodeLoadBalancer)balancer).getFavoredNodes(hri);
              }
              RegionOpeningState regionOpenState = serverManager.sendRegionOpen(
                serverName, hri, -1, favoredNodes);

              if (regionOpenState == RegionOpeningState.FAILED_OPENING) {
                // Failed opening this region, this means the target server didn't get
                // the original region open RPC, so re-assign it with a new plan
                LOG.debug("Got failed_opening in retry sendRegionOpen for "
                  + regionState + ", re-assign it");
                invokeAssign(hri, true);
              }
              return; // Done.
            } catch (Throwable t) {
              if (t instanceof RemoteException) {
                t = ((RemoteException) t).unwrapRemoteException();
              }
              // In case SocketTimeoutException/FailedServerException, retry
              if (t instanceof java.net.SocketTimeoutException
                  || t instanceof FailedServerException) {
                Threads.sleep(100);
                continue;
              }
              // For other exceptions, re-assign it
              LOG.debug("Got exception in retry sendRegionOpen for "
                + regionState + ", re-assign it", t);
              invokeAssign(hri);
              return; // Done.
            }
          }
        } finally {
          lock.unlock();
        }
      }
    });
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:61,代码来源:AssignmentManager.java

示例10: before

import org.apache.hadoop.hbase.regionserver.RegionOpeningState; //导入依赖的package包/类
@Before
public void before() throws ZooKeeperConnectionException, IOException {
  // TODO: Make generic versions of what we do below and put up in a mocking
  // utility class or move up into HBaseTestingUtility.

  // Mock a Server.  Have it return a legit Configuration and ZooKeeperWatcher.
  // If abort is called, be sure to fail the test (don't just swallow it
  // silently as is mockito default).
  this.server = Mockito.mock(Server.class);
  Mockito.when(server.getServerName()).thenReturn(ServerName.valueOf("master,1,1"));
  Mockito.when(server.getConfiguration()).thenReturn(HTU.getConfiguration());
  this.watcher =
    new ZooKeeperWatcher(HTU.getConfiguration(), "mockedServer", this.server, true);
  Mockito.when(server.getZooKeeper()).thenReturn(this.watcher);
  Mockito.doThrow(new RuntimeException("Aborted")).
    when(server).abort(Mockito.anyString(), (Throwable)Mockito.anyObject());

  cp = new ZkCoordinatedStateManager();
  cp.initialize(this.server);
  cp.start();

  mtl = Mockito.mock(MetaTableLocator.class);

  Mockito.when(server.getCoordinatedStateManager()).thenReturn(cp);
  Mockito.when(server.getMetaTableLocator()).thenReturn(mtl);

  // Get a connection w/ mocked up common methods.
  this.connection =
    (ClusterConnection)HConnectionTestingUtility.getMockedConnection(HTU.getConfiguration());

  // Make it so we can get a catalogtracker from servermanager.. .needed
  // down in guts of server shutdown handler.
  Mockito.when(server.getConnection()).thenReturn(connection);

  // Mock a ServerManager.  Say server SERVERNAME_{A,B} are online.  Also
  // make it so if close or open, we return 'success'.
  this.serverManager = Mockito.mock(ServerManager.class);
  Mockito.when(this.serverManager.isServerOnline(SERVERNAME_A)).thenReturn(true);
  Mockito.when(this.serverManager.isServerOnline(SERVERNAME_B)).thenReturn(true);
  Mockito.when(this.serverManager.getDeadServers()).thenReturn(new DeadServer());
  final Map<ServerName, ServerLoad> onlineServers = new HashMap<ServerName, ServerLoad>();
  onlineServers.put(SERVERNAME_B, ServerLoad.EMPTY_SERVERLOAD);
  onlineServers.put(SERVERNAME_A, ServerLoad.EMPTY_SERVERLOAD);
  Mockito.when(this.serverManager.getOnlineServersList()).thenReturn(
      new ArrayList<ServerName>(onlineServers.keySet()));
  Mockito.when(this.serverManager.getOnlineServers()).thenReturn(onlineServers);

  List<ServerName> avServers = new ArrayList<ServerName>();
  avServers.addAll(onlineServers.keySet());
  Mockito.when(this.serverManager.createDestinationServersList()).thenReturn(avServers);
  Mockito.when(this.serverManager.createDestinationServersList(null)).thenReturn(avServers);

  Mockito.when(this.serverManager.sendRegionClose(SERVERNAME_A, REGIONINFO, -1)).
    thenReturn(true);
  Mockito.when(this.serverManager.sendRegionClose(SERVERNAME_B, REGIONINFO, -1)).
    thenReturn(true);
  // Ditto on open.
  Mockito.when(this.serverManager.sendRegionOpen(SERVERNAME_A, REGIONINFO, -1, null)).
    thenReturn(RegionOpeningState.OPENED);
  Mockito.when(this.serverManager.sendRegionOpen(SERVERNAME_B, REGIONINFO, -1, null)).
    thenReturn(RegionOpeningState.OPENED);
  this.master = Mockito.mock(HMaster.class);

  Mockito.when(this.master.getServerManager()).thenReturn(serverManager);
}
 
开发者ID:grokcoder,项目名称:pbase,代码行数:66,代码来源:TestAssignmentManager.java


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