Java 类org.apache.hadoop.hbase.regionserver.RegionOpeningState 实例源码

项目:ditb    文件:ServerManager.java   
/**
 * 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);
  }
}
项目:ditb    文件:ServerManager.java   
/**
 * 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 regionOpenInfos info of a list of regions to open
 * @return a list of region opening states
 */
public List<RegionOpeningState> sendRegionOpen(ServerName server,
    List<Triple<HRegionInfo, Integer, List<ServerName>>> regionOpenInfos)
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 null;
  }

  OpenRegionRequest request = RequestConverter.buildOpenRegionRequest(server, regionOpenInfos,
    (RecoveryMode.LOG_REPLAY == this.services.getMasterFileSystem().getLogRecoveryMode()));
  try {
    OpenRegionResponse response = admin.openRegion(null, request);
    return ResponseConverter.getRegionOpeningStateList(response);
  } catch (ServiceException se) {
    throw ProtobufUtil.getRemoteException(se);
  }
}
项目:pbase    文件:ServerManager.java   
/**
 * 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);
  }
}
项目:pbase    文件:ServerManager.java   
/**
 * 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 regionOpenInfos info of a list of regions to open
 * @return a list of region opening states
 */
public List<RegionOpeningState> sendRegionOpen(ServerName server,
    List<Triple<HRegionInfo, Integer, List<ServerName>>> regionOpenInfos)
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 null;
  }

  OpenRegionRequest request = RequestConverter.buildOpenRegionRequest(server, regionOpenInfos,
    (RecoveryMode.LOG_REPLAY == this.services.getMasterFileSystem().getLogRecoveryMode()));
  try {
    OpenRegionResponse response = admin.openRegion(null, request);
    return ResponseConverter.getRegionOpeningStateList(response);
  } catch (ServiceException se) {
    throw ProtobufUtil.getRemoteException(se);
  }
}
项目:HIndex    文件:ServerManager.java   
/**
 * 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);
  }
}
项目:HIndex    文件:ServerManager.java   
/**
 * 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 regionOpenInfos info of a list of regions to open
 * @return a list of region opening states
 */
public List<RegionOpeningState> sendRegionOpen(ServerName server,
    List<Triple<HRegionInfo, Integer, List<ServerName>>> regionOpenInfos)
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 null;
  }

  OpenRegionRequest request =
    RequestConverter.buildOpenRegionRequest(regionOpenInfos);
  try {
    OpenRegionResponse response = admin.openRegion(null, request);
    return ResponseConverter.getRegionOpeningStateList(response);
  } catch (ServiceException se) {
    throw ProtobufUtil.getRemoteException(se);
  }
}
项目:PyroDB    文件:ServerManager.java   
/**
 * 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);
  }
}
项目:PyroDB    文件:ServerManager.java   
/**
 * 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 regionOpenInfos info of a list of regions to open
 * @return a list of region opening states
 */
public List<RegionOpeningState> sendRegionOpen(ServerName server,
    List<Triple<HRegionInfo, Integer, List<ServerName>>> regionOpenInfos)
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 null;
  }

  OpenRegionRequest request =
    RequestConverter.buildOpenRegionRequest(regionOpenInfos);
  try {
    OpenRegionResponse response = admin.openRegion(null, request);
    return ResponseConverter.getRegionOpeningStateList(response);
  } catch (ServiceException se) {
    throw ProtobufUtil.getRemoteException(se);
  }
}
项目:c5    文件:ServerManager.java   
/**
 * 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);
  }
}
项目:c5    文件:ServerManager.java   
/**
 * 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 regionOpenInfos info of a list of regions to open
 * @return a list of region opening states
 */
public List<RegionOpeningState> sendRegionOpen(ServerName server,
    List<Triple<HRegionInfo, Integer, List<ServerName>>> regionOpenInfos)
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 null;
  }

  OpenRegionRequest request =
    RequestConverter.buildOpenRegionRequest(regionOpenInfos);
  try {
    OpenRegionResponse response = admin.openRegion(null, request);
    return ResponseConverter.getRegionOpeningStateList(response);
  } catch (ServiceException se) {
    throw ProtobufUtil.getRemoteException(se);
  }
}
项目:DominoHBase    文件:ServerManager.java   
/**
 * 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);
  }
}
项目:DominoHBase    文件:ServerManager.java   
/**
 * 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 regionOpenInfos info of a list of regions to open
 * @return a list of region opening states
 */
public List<RegionOpeningState> sendRegionOpen(ServerName server,
    List<Pair<HRegionInfo, Integer>> regionOpenInfos)
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 null;
  }

  OpenRegionRequest request =
    RequestConverter.buildOpenRegionRequest(regionOpenInfos);
  try {
    OpenRegionResponse response = admin.openRegion(null, request);
    return ResponseConverter.getRegionOpeningStateList(response);
  } catch (ServiceException se) {
    throw ProtobufUtil.getRemoteException(se);
  }
}
项目:ditb    文件:ResponseConverter.java   
/**
 * 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());
}
项目:ditb    文件:ResponseConverter.java   
/**
 * 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;
}
项目:LCIndex-HBase-0.94.16    文件:ServerManager.java   
/**
 * 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);
}
项目:LCIndex-HBase-0.94.16    文件:TestAssignmentManager.java   
@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);
}
项目:pbase    文件:ResponseConverter.java   
/**
 * 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());
}
项目:pbase    文件:ResponseConverter.java   
/**
 * 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;
}
项目:HIndex    文件:ResponseConverter.java   
/**
 * 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());
}
项目:HIndex    文件:ResponseConverter.java   
/**
 * 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;
}
项目:IRIndex    文件:ServerManager.java   
/**
 * 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);
}
项目:IRIndex    文件:TestAssignmentManager.java   
@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);
}
项目:RStore    文件:ServerManager.java   
/**
 * 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);
}
项目:PyroDB    文件:ResponseConverter.java   
/**
 * 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());
}
项目:PyroDB    文件:ResponseConverter.java   
/**
 * 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;
}
项目:c5    文件:ResponseConverter.java   
/**
 * 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());
}
项目:c5    文件:ResponseConverter.java   
/**
 * 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;
}
项目:HBase-Research    文件:ServerManager.java   
/**
 * 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);
}
项目:HBase-Research    文件:TestAssignmentManager.java   
@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);
}
项目:hbase-0.94.8-qod    文件:ServerManager.java   
/**
 * 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);
}
项目:hbase-0.94.8-qod    文件:TestAssignmentManager.java   
@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);
}
项目:hbase-0.94.8-qod    文件:ServerManager.java   
/**
 * 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);
}
项目:hbase-0.94.8-qod    文件:TestAssignmentManager.java   
@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);
}
项目:DominoHBase    文件:ResponseConverter.java   
/**
 * 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());
}
项目:DominoHBase    文件:ResponseConverter.java   
/**
 * 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;
}
项目:hindex    文件:ServerManager.java   
/**
 * 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);
}
项目:hindex    文件:TestAssignmentManager.java   
@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);
}
项目:ditb    文件:AssignmentManager.java   
/**
 * 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();
        }
      }
    });
}
项目:pbase    文件:AssignmentManager.java   
/**
 * 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();
        }
      }
    });
}
项目:pbase    文件:TestAssignmentManager.java   
@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);
}