/** * 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); } }
/** * 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); } }
/** * 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); } }
/** * 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); } }
/** * 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); } }
/** * 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); } }
/** * 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); } }
/** * 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()); }
/** * 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; }
@Override public OpenRegionResponse openRegion(RpcController controller, OpenRegionRequest request) throws ServiceException { // TODO Auto-generated method stub return null; }