@Override public void run() throws IOException { this.scanner.close(); } }
@Override public void run() { for (RegionScanner scanner : scanners) { try { scanner.close(); } catch (IOException e) { LOG.error("Exception while closing the scanner " + scanner, e); } } } }
private void closeAllScanners() { // Close any outstanding scanners. Means they'll get an UnknownScanner // exception next time they come in. for (Map.Entry<String, RegionScannerHolder> e : scanners.entrySet()) { try { e.getValue().s.close(); } catch (IOException ioe) { LOG.warn("Closing scanner " + e.getKey(), ioe); } } }
@Override public void close() throws IOException { delegate.close(); }
@Override public void close() throws IOException { delegate.close(); }
@Override public void close() { try { regionScanner.close(); } catch (IOException e) { throw new RuntimeException(e); } }
protected List<List<Cell>> getExistingLabelsWithAuths() throws IOException { Scan scan = new Scan(); RegionScanner scanner = labelsRegion.getScanner(scan); List<List<Cell>> existingLabels = new ArrayList<>(); try { while (true) { List<Cell> cells = new ArrayList<>(); scanner.next(cells); if (cells.isEmpty()) { break; } existingLabels.add(cells); } } finally { scanner.close(); } return existingLabels; }
@Override public void close() { if (this.scanner != null) { try { this.scanner.close(); this.scanner = null; } catch (IOException ex) { LOG.warn("Exception while closing scanner", ex); } } if (this.region != null) { try { this.region.closeRegionOperation(); this.region.close(true); this.region = null; } catch (IOException ex) { LOG.warn("Exception while closing region", ex); } } }
scanner.close();
scanner.close();
scanners.remove(scannerName); try { rsh.s.close(); } catch (IOException e) { LOG.warn("Getting exception closing " + scannerName, e);
private void initiateScan(HRegion region) throws IOException { Scan scan = new Scan(); scan.setCaching(1); RegionScanner resScanner = null; try { resScanner = region.getScanner(scan); List<Cell> results = new ArrayList<>(); boolean next = resScanner.next(results); try { counter.incrementAndGet(); latch.await(); } catch (InterruptedException e) { } while (next) { next = resScanner.next(results); } } finally { scanCompletedCounter.incrementAndGet(); resScanner.close(); } } }
private void runScanner(Table hTable, int expectedSize, Filter filter) throws IOException { String cf = "f"; Scan scan = new Scan(); scan.addFamily(cf.getBytes()); scan.setFilter(filter); List<HRegion> regions = TEST_UTIL.getHBaseCluster().getRegions(table.getBytes()); HRegion first = regions.get(0); first.getScanner(scan); RegionScanner scanner = first.getScanner(scan); List<Cell> results = new ArrayList<>(); // Result result; long timeBeforeScan = System.currentTimeMillis(); int found = 0; while (scanner.next(results)) { found += results.size(); results.clear(); } found += results.size(); long scanTime = System.currentTimeMillis() - timeBeforeScan; scanner.close(); LOG.info("\nscan time = " + scanTime + "ms"); LOG.info("found " + found + " results\n"); assertEquals(expectedSize, found); }
private void closeScanner(HRegion region, RegionScanner scanner, String scannerName, RpcCallContext context) throws IOException { if (region.getCoprocessorHost() != null) { if (region.getCoprocessorHost().preScannerClose(scanner)) { // bypass the actual close. return; } } RegionScannerHolder rsh = scanners.remove(scannerName); if (rsh != null) { if (context != null) { context.setCallBack(rsh.closeCallBack); } else { rsh.s.close(); } if (region.getCoprocessorHost() != null) { region.getCoprocessorHost().postScannerClose(scanner); } closedScanners.put(scannerName, scannerName); } }
} finally { try { s.close(); if (region != null && region.getCoprocessorHost() != null) { region.getCoprocessorHost().postScannerClose(s);
public List<Cell> get(Get get, boolean withCoprocessor, long nonceGroup, long nonce) throws IOException { List<Cell> results = new ArrayList<>(); long before = EnvironmentEdgeManager.currentTime(); // pre-get CP hook if (withCoprocessor && (coprocessorHost != null)) { if (coprocessorHost.preGet(get, results)) { metricsUpdateForGet(results, before); return results; } } Scan scan = new Scan(get); if (scan.getLoadColumnFamiliesOnDemandValue() == null) { scan.setLoadColumnFamiliesOnDemand(isLoadingCfsOnDemandDefault()); } RegionScanner scanner = null; try { scanner = getScanner(scan, null, nonceGroup, nonce); scanner.next(results); } finally { if (scanner != null) scanner.close(); } // post-get CP hook if (withCoprocessor && (coprocessorHost != null)) { coprocessorHost.postGet(get, results); } metricsUpdateForGet(results, before); return results; }
@Test public void testToShowNPEOnRegionScannerReseek() throws Exception { byte[] family = Bytes.toBytes("family"); this.region = initHRegion(tableName, method, CONF, family); Put put = new Put(Bytes.toBytes("r1")); put.addColumn(family, Bytes.toBytes("q1"), Bytes.toBytes("v1")); region.put(put); put = new Put(Bytes.toBytes("r2")); put.addColumn(family, Bytes.toBytes("q1"), Bytes.toBytes("v1")); region.put(put); region.flush(true); Scan scan = new Scan(); scan.setMaxVersions(3); // open the first scanner RegionScanner scanner1 = region.getScanner(scan); System.out.println("Smallest read point:" + region.getSmallestReadPoint()); region.compact(true); scanner1.reseek(Bytes.toBytes("r2")); List<Cell> results = new ArrayList<>(); scanner1.next(results); Cell keyValue = results.get(0); Assert.assertTrue(Bytes.compareTo(CellUtil.cloneRow(keyValue), Bytes.toBytes("r2")) == 0); scanner1.close(); }
while (rs.next(r)) rs.close(); if (r.size() != 1) { LOG.debug(Objects.toString(r));
assertEquals("row2", Bytes.toString(CellUtil.cloneRow(res.get(0)))); scanner.close();