@Override public void close() { if (this.scanners != null) { for (KeyValueScanner scanner : scanners) { scanner.close(); } } } }
@Override public void close() { for (KeyValueScanner scanner : this.scannersForDelayedClose) { scanner.close(); } this.scannersForDelayedClose.clear(); if (this.current != null) { this.current.close(); } if (this.heap != null) { // Order of closing the scanners shouldn't matter here, so simply iterate and close them. for (KeyValueScanner scanner : heap) { scanner.close(); } } }
private static void clearAndClose(List<KeyValueScanner> scanners) { for (KeyValueScanner s : scanners) { s.close(); } scanners.clear(); }
@Override public void close() { delegate.close(); }
@Override public void close() { if (closed) { return; } // Ensuring that all the segment scanners are closed if (heap != null) { heap.close(); // It is safe to do close as no new calls will be made to this scanner. heap = null; } else { for (KeyValueScanner scanner : scanners) { scanner.close(); } } closed = true; }
@Override public void shipped() throws IOException { for (KeyValueScanner scanner : this.scannersForDelayedClose) { scanner.close(); // There wont be further fetch of Cells from these scanners. Just close. } this.scannersForDelayedClose.clear(); if (this.current != null) { this.current.shipped(); } if (this.heap != null) { for (KeyValueScanner scanner : this.heap) { scanner.shipped(); } } } }
private IOException handleException(List<KeyValueScanner> instantiatedScanners, Throwable t) { // remove scaner read point before throw the exception scannerReadPoints.remove(this); if (storeHeap != null) { storeHeap.close(); storeHeap = null; if (joinedHeap != null) { joinedHeap.close(); joinedHeap = null; } } else { // close all already instantiated scanners before throwing the exception for (KeyValueScanner scanner : instantiatedScanners) { scanner.close(); } } return t instanceof IOException ? (IOException) t : new IOException(t); }
scanners.add(kvs); } else { kvs.close();
if (scanner != null) { try { scanner.close(); } catch (Exception ce) { LOG.warn("close KeyValueScanner error", ce);
throw new IllegalStateException(ie); } finally { segmentScanner.close();
@Test public void testCountOfCellsAfterFlatteningByScan() throws IOException { String[] keys1 = { "A", "B", "C" }; // A, B, C addRowsByKeysWith50Cols(memstore, keys1); // this should only flatten as there are no duplicates ((CompactingMemStore) memstore).flushInMemory(); while (((CompactingMemStore) memstore).isMemStoreFlushingInMemory()) { Threads.sleep(10); } List<KeyValueScanner> scanners = memstore.getScanners(Long.MAX_VALUE); // seek int count = 0; for(int i = 0; i < scanners.size(); i++) { scanners.get(i).seek(KeyValue.LOWESTKEY); while (scanners.get(i).next() != null) { count++; } } assertEquals("the count should be ", 150, count); for(int i = 0; i < scanners.size(); i++) { scanners.get(i).close(); } }
throw new IllegalStateException(ie); } finally { segmentScanner.close();
assertTrue(ioe.getMessage().contains("Could not iterate")); scanner.close();
@Test public void testPuttingBackChunksAfterFlushing() throws IOException { byte[] row = Bytes.toBytes("testrow"); byte[] fam = Bytes.toBytes("testfamily"); byte[] qf1 = Bytes.toBytes("testqualifier1"); byte[] qf2 = Bytes.toBytes("testqualifier2"); byte[] qf3 = Bytes.toBytes("testqualifier3"); byte[] qf4 = Bytes.toBytes("testqualifier4"); byte[] qf5 = Bytes.toBytes("testqualifier5"); byte[] val = Bytes.toBytes("testval"); // Setting up memstore memstore.add(new KeyValue(row, fam, qf1, val), null); memstore.add(new KeyValue(row, fam, qf2, val), null); memstore.add(new KeyValue(row, fam, qf3, val), null); // Creating a snapshot MemStoreSnapshot snapshot = memstore.snapshot(); assertEquals(3, memstore.getSnapshot().getCellsCount()); // Adding value to "new" memstore assertEquals(0, memstore.getActive().getCellsCount()); memstore.add(new KeyValue(row, fam, qf4, val), null); memstore.add(new KeyValue(row, fam, qf5, val), null); assertEquals(2, memstore.getActive().getCellsCount()); // close the scanners for(KeyValueScanner scanner : snapshot.getScanners()) { scanner.close(); } memstore.clearSnapshot(snapshot.getId()); int chunkCount = chunkCreator.getPoolSize(); assertTrue(chunkCount > 0); }
scanner.close();
scanner.close();
scanner.close(); reader.close(cacheConf.shouldEvictOnClose());