RegionServerStoppedOnScannerOpenConnection(Configuration conf, ExecutorService pool, User user) throws IOException { super(conf, pool, user); // Mock up my stub so open scanner returns a scanner id and then on next, we throw // exceptions for three times and then after that, we return no more to scan. this.stub = Mockito.mock(ClientService.BlockingInterface.class); long sid = 12345L; try { Mockito.when(stub.scan((RpcController)Mockito.any(), (ClientProtos.ScanRequest)Mockito.any())). thenReturn(ClientProtos.ScanResponse.newBuilder().setScannerId(sid).build()). thenThrow(new ServiceException(new RegionServerStoppedException("From Mockito"))). thenReturn(ClientProtos.ScanResponse.newBuilder().setScannerId(sid). setMoreResults(false).build()); } catch (ServiceException e) { throw new IOException(e); } }
builder.addCellsPerResult(((Result)result).size()); Mockito.when(implementation.scan((RpcController) Mockito.any(), (ScanRequest) Mockito.any())) .thenThrow(new ServiceException("Server not running (1 of 3)")) .thenThrow(new ServiceException("Server not running (2 of 3)")) scan((RpcController)Mockito.any(), (ScanRequest)Mockito.any()); } finally { if (connection != null && !connection.isClosed()) connection.close();
this.scanMetrics != null, renew, scan.getLimit()); try { ScanResponse response = getStub().scan(getRpcController(), request); nextCallSeq++; return response;
builder.addCellsPerResult(((Result)result).size()); Mockito.when(implementation.scan((RpcController) Mockito.any(), (ScanRequest) Mockito.any())) .thenThrow(new ServiceException("Server not running (1 of 3)")) .thenThrow(new ServiceException("Server not running (2 of 3)")) scan((RpcController)Mockito.any(), (ScanRequest)Mockito.any()); } finally { if (connection != null && !connection.isClosed()) connection.close();
this.scanMetrics != null, renew, scan.getLimit()); try { ScanResponse response = getStub().scan(getRpcController(), request); nextCallSeq++; return response;
ScanRequest req = RequestConverter.buildScanRequest(HRI.getRegionName(), scan, 0, false); HBaseRpcController hrc = new HBaseRpcControllerImpl(); ScanResponse resp = STUB.scan(hrc, req); assertTrue(resp.getMoreResults()); assertTrue(resp.getMoreResultsInRegion()); req = RequestConverter.buildScanRequest(scannerId, 1, false, nextCallSeq++, false, false, -1); hrc.reset(); resp = STUB.scan(hrc, req); assertTrue(resp.getMoreResults()); assertTrue(resp.getMoreResultsInRegion()); resp = STUB.scan(hrc, req); assertTrue(resp.getMoreResults()); assertTrue(resp.getMoreResultsInRegion()); req = RequestConverter.buildScanRequest(scannerId, 1, false, nextCallSeq++, false, false, -1); hrc.reset(); resp = STUB.scan(hrc, req); assertTrue(resp.getMoreResults()); assertEquals(i != COUNT - 1, resp.getMoreResultsInRegion()); resp = STUB.scan(null, req);
private void close() { if (this.scannerId == -1L) { return; } try { incRPCCallsMetrics(scanMetrics, isRegionServerRemote); ScanRequest request = RequestConverter.buildScanRequest(this.scannerId, 0, true, this.scanMetrics != null); try { getStub().scan(getRpcController(), request); } catch (Exception e) { throw ProtobufUtil.handleRemoteException(e); } } catch (IOException e) { TableName table = getTableName(); String tableDetails = (table == null) ? "" : (" on table: " + table.getNameAsString()); LOG.warn("Ignore, probably already closed. Current scan: " + getScan().toString() + tableDetails, e); } this.scannerId = -1L; }
@Test public void test() throws ServiceException, IOException { Scan scan = new Scan(); ScanRequest req = RequestConverter.buildScanRequest(HRI.getRegionName(), scan, 1, false); ScanResponse resp = STUB.scan(null, req); assertTrue(resp.hasScannerId()); long scannerId = resp.getScannerId(); int nextCallSeq = 0; // test next for (int i = 0; i < COUNT / 2; i++) { req = RequestConverter.buildScanRequest(scannerId, 1, false, nextCallSeq++, false, false, -1); resp = STUB.scan(null, req); assertTrue(resp.hasScannerId()); assertEquals(scannerId, resp.getScannerId()); } // test renew req = RequestConverter.buildScanRequest(scannerId, 0, false, nextCallSeq++, false, true, -1); resp = STUB.scan(null, req); assertTrue(resp.hasScannerId()); assertEquals(scannerId, resp.getScannerId()); // test close req = RequestConverter.buildScanRequest(scannerId, 0, true, false); resp = STUB.scan(null, req); assertTrue(resp.hasScannerId()); assertEquals(scannerId, resp.getScannerId()); } }
private ScanResponse openScanner() throws IOException { incRPCCallsMetrics(scanMetrics, isRegionServerRemote); ScanRequest request = RequestConverter.buildScanRequest( getLocation().getRegionInfo().getRegionName(), this.scan, this.caching, false); try { ScanResponse response = getStub().scan(getRpcController(), request); long id = response.getScannerId(); if (logScannerActivity) { LOG.info("Open scanner=" + id + " for scan=" + scan.toString() + " on region " + getLocation().toString()); } if (response.hasMvccReadPoint()) { this.scan.setMvccReadPoint(response.getMvccReadPoint()); } this.scannerId = id; return response; } catch (Exception e) { throw ProtobufUtil.handleRemoteException(e); } }
protected ClientProtos.ScanResponse doScan(ClientProtos.ScanRequest request) throws org.apache.hbase.thirdparty.com.google.protobuf.ServiceException { return getStub().scan(getRpcController(), request); }
this.scanMetrics != null, renew, scan.getLimit()); try { ScanResponse response = getStub().scan(getRpcController(), request); nextCallSeq++; return response;
private void close() { if (this.scannerId == -1L) { return; } try { incRPCCallsMetrics(scanMetrics, isRegionServerRemote); ScanRequest request = RequestConverter.buildScanRequest(this.scannerId, 0, true, this.scanMetrics != null); try { getStub().scan(getRpcController(), request); } catch (Exception e) { throw ProtobufUtil.handleRemoteException(e); } } catch (IOException e) { TableName table = getTableName(); String tableDetails = (table == null) ? "" : (" on table: " + table.getNameAsString()); LOG.warn("Ignore, probably already closed. Current scan: " + getScan().toString() + tableDetails, e); } this.scannerId = -1L; }
RegionServerStoppedOnScannerOpenConnection(Configuration conf, ExecutorService pool, User user) throws IOException { super(conf, pool, user); // Mock up my stub so open scanner returns a scanner id and then on next, we throw // exceptions for three times and then after that, we return no more to scan. this.stub = Mockito.mock(ClientService.BlockingInterface.class); long sid = 12345L; try { Mockito.when(stub.scan((RpcController)Mockito.any(), (ClientProtos.ScanRequest)Mockito.any())). thenReturn(ClientProtos.ScanResponse.newBuilder().setScannerId(sid).build()). thenThrow(new ServiceException(new RegionServerStoppedException("From Mockito"))). thenReturn(ClientProtos.ScanResponse.newBuilder().setScannerId(sid). setMoreResults(false).build()); } catch (ServiceException e) { throw new IOException(e); } }
private ScanResponse openScanner() throws IOException { incRPCCallsMetrics(scanMetrics, isRegionServerRemote); ScanRequest request = RequestConverter.buildScanRequest( getLocation().getRegionInfo().getRegionName(), this.scan, this.caching, false); try { ScanResponse response = getStub().scan(getRpcController(), request); long id = response.getScannerId(); if (logScannerActivity) { LOG.info("Open scanner=" + id + " for scan=" + scan.toString() + " on region " + getLocation().toString()); } if (response.hasMvccReadPoint()) { this.scan.setMvccReadPoint(response.getMvccReadPoint()); } this.scannerId = id; return response; } catch (Exception e) { throw ProtobufUtil.handleRemoteException(e); } }
protected ClientProtos.ScanResponse doScan(ClientProtos.ScanRequest request) throws org.apache.hbase.thirdparty.com.google.protobuf.ServiceException { return getStub().scan(getRpcController(), request); }
ScanRequest req = RequestConverter.buildScanRequest(HRI.getRegionName(), scan, 0, false); HBaseRpcController hrc = new HBaseRpcControllerImpl(); ScanResponse resp = STUB.scan(hrc, req); assertTrue(resp.getMoreResults()); assertTrue(resp.getMoreResultsInRegion()); req = RequestConverter.buildScanRequest(scannerId, 1, false, nextCallSeq++, false, false, -1); hrc.reset(); resp = STUB.scan(hrc, req); assertTrue(resp.getMoreResults()); assertTrue(resp.getMoreResultsInRegion()); resp = STUB.scan(hrc, req); assertTrue(resp.getMoreResults()); assertTrue(resp.getMoreResultsInRegion()); req = RequestConverter.buildScanRequest(scannerId, 1, false, nextCallSeq++, false, false, -1); hrc.reset(); resp = STUB.scan(hrc, req); assertTrue(resp.getMoreResults()); assertEquals(i != COUNT - 1, resp.getMoreResultsInRegion()); resp = STUB.scan(null, req);
@Test public void test() throws ServiceException, IOException { Scan scan = new Scan(); ScanRequest req = RequestConverter.buildScanRequest(HRI.getRegionName(), scan, 1, false); ScanResponse resp = STUB.scan(null, req); assertTrue(resp.hasScannerId()); long scannerId = resp.getScannerId(); int nextCallSeq = 0; // test next for (int i = 0; i < COUNT / 2; i++) { req = RequestConverter.buildScanRequest(scannerId, 1, false, nextCallSeq++, false, false, -1); resp = STUB.scan(null, req); assertTrue(resp.hasScannerId()); assertEquals(scannerId, resp.getScannerId()); } // test renew req = RequestConverter.buildScanRequest(scannerId, 0, false, nextCallSeq++, false, true, -1); resp = STUB.scan(null, req); assertTrue(resp.hasScannerId()); assertEquals(scannerId, resp.getScannerId()); // test close req = RequestConverter.buildScanRequest(scannerId, 0, true, false); resp = STUB.scan(null, req); assertTrue(resp.hasScannerId()); assertEquals(scannerId, resp.getScannerId()); } }
private void close() { if (this.scannerId == -1L) { return; } try { incRPCCallsMetrics(scanMetrics, isRegionServerRemote); ScanRequest request = RequestConverter.buildScanRequest(this.scannerId, 0, true, this.scanMetrics != null); try { getStub().scan(getRpcController(), request); } catch (Exception e) { throw ProtobufUtil.handleRemoteException(e); } } catch (IOException e) { TableName table = getTableName(); String tableDetails = (table == null) ? "" : (" on table: " + table.getNameAsString()); LOG.warn("Ignore, probably already closed. Current scan: " + getScan().toString() + tableDetails, e); } this.scannerId = -1L; }
private ScanResponse openScanner() throws IOException { incRPCCallsMetrics(scanMetrics, isRegionServerRemote); ScanRequest request = RequestConverter.buildScanRequest( getLocation().getRegionInfo().getRegionName(), this.scan, this.caching, false); try { ScanResponse response = getStub().scan(getRpcController(), request); long id = response.getScannerId(); if (logScannerActivity) { LOG.info("Open scanner=" + id + " for scan=" + scan.toString() + " on region " + getLocation().toString()); } if (response.hasMvccReadPoint()) { this.scan.setMvccReadPoint(response.getMvccReadPoint()); } this.scannerId = id; return response; } catch (Exception e) { throw ProtobufUtil.handleRemoteException(e); } }
protected ClientProtos.ScanResponse doScan(ClientProtos.ScanRequest request) throws org.apache.hbase.thirdparty.com.google.protobuf.ServiceException { return getStub().scan(getRpcController(), request); }