Java Code Examples for org.apache.hadoop.hbase.wal.WAL#close()
The following examples show how to use
org.apache.hadoop.hbase.wal.WAL#close() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestWALObserver.java From hbase with Apache License 2.0 | 5 votes |
/** * Coprocessors shouldn't get notice of empty waledits. */ @Test public void testEmptyWALEditAreNotSeen() throws Exception { RegionInfo hri = createBasicHRegionInfo(Bytes.toString(TEST_TABLE)); TableDescriptor htd = createBasic3FamilyHTD(Bytes.toString(TEST_TABLE)); MultiVersionConcurrencyControl mvcc = new MultiVersionConcurrencyControl(); NavigableMap<byte[], Integer> scopes = new TreeMap<>(Bytes.BYTES_COMPARATOR); for(byte[] fam : htd.getColumnFamilyNames()) { scopes.put(fam, 0); } WAL log = wals.getWAL(null); try { SampleRegionWALCoprocessor cp = getCoprocessor(log, SampleRegionWALCoprocessor.class); cp.setTestValues(TEST_TABLE, null, null, null, null, null, null, null); assertFalse(cp.isPreWALWriteCalled()); assertFalse(cp.isPostWALWriteCalled()); final long now = EnvironmentEdgeManager.currentTime(); long txid = log.appendData(hri, new WALKeyImpl(hri.getEncodedNameAsBytes(), hri.getTable(), now, mvcc, scopes), new WALEdit()); log.sync(txid); assertFalse("Empty WALEdit should skip coprocessor evaluation.", cp.isPreWALWriteCalled()); assertFalse("Empty WALEdit should skip coprocessor evaluation.", cp.isPostWALWriteCalled()); } finally { log.close(); } }
Example 2
Source File: TestWALActionsListener.java From hbase with Apache License 2.0 | 5 votes |
/** * Add a bunch of dummy data and roll the logs every two insert. We * should end up with 10 rolled files (plus the roll called in * the constructor). Also test adding a listener while it's running. */ @Test public void testActionListener() throws Exception { DummyWALActionsListener observer = new DummyWALActionsListener(); final WALFactory wals = new WALFactory(conf, "testActionListener"); wals.getWALProvider().addWALActionsListener(observer); DummyWALActionsListener laterobserver = new DummyWALActionsListener(); RegionInfo hri = RegionInfoBuilder.newBuilder(TableName.valueOf(SOME_BYTES)) .setStartKey(SOME_BYTES).setEndKey(SOME_BYTES).build(); final WAL wal = wals.getWAL(hri); MultiVersionConcurrencyControl mvcc = new MultiVersionConcurrencyControl(); for (int i = 0; i < 20; i++) { byte[] b = Bytes.toBytes(i + ""); KeyValue kv = new KeyValue(b, b, b); WALEdit edit = new WALEdit(); edit.add(kv); NavigableMap<byte[], Integer> scopes = new TreeMap<>(Bytes.BYTES_COMPARATOR); scopes.put(b, 0); long txid = wal.appendData(hri, new WALKeyImpl(hri.getEncodedNameAsBytes(), TableName.valueOf(b), 0, mvcc, scopes), edit); wal.sync(txid); if (i == 10) { wal.registerWALActionsListener(laterobserver); } if (i % 2 == 0) { wal.rollWriter(); } } wal.close(); assertEquals(11, observer.preLogRollCounter); assertEquals(11, observer.postLogRollCounter); assertEquals(5, laterobserver.preLogRollCounter); assertEquals(5, laterobserver.postLogRollCounter); assertEquals(1, observer.closedCount); }
Example 3
Source File: TestAtomicOperation.java From hbase with Apache License 2.0 | 5 votes |
@After public void teardown() throws IOException { if (region != null) { CacheConfig cacheConfig = region.getStores().get(0).getCacheConfig(); region.close(); WAL wal = region.getWAL(); if (wal != null) { wal.close(); } cacheConfig.getBlockCache().ifPresent(BlockCache::shutdown); region = null; } }
Example 4
Source File: TestCompaction.java From hbase with Apache License 2.0 | 4 votes |
@After public void tearDown() throws Exception { WAL wal = r.getWAL(); this.r.close(); wal.close(); }
Example 5
Source File: TestMinorCompaction.java From hbase with Apache License 2.0 | 4 votes |
@After public void tearDown() throws Exception { WAL wal = ((HRegion)r).getWAL(); ((HRegion)r).close(); wal.close(); }
Example 6
Source File: TestMajorCompaction.java From hbase with Apache License 2.0 | 4 votes |
@After public void tearDown() throws Exception { WAL wal = ((HRegion) r).getWAL(); ((HRegion) r).close(); wal.close(); }
Example 7
Source File: TestFilter.java From hbase with Apache License 2.0 | 4 votes |
@Test public void testFilterListWithPrefixFilter() throws IOException { byte[] family = Bytes.toBytes("f1"); byte[] qualifier = Bytes.toBytes("q1"); TableDescriptorBuilder.ModifyableTableDescriptor tableDescriptor = new TableDescriptorBuilder.ModifyableTableDescriptor( TableName.valueOf(name.getMethodName())); tableDescriptor.setColumnFamily( new ColumnFamilyDescriptorBuilder.ModifyableColumnFamilyDescriptor(family)); RegionInfo info = RegionInfoBuilder.newBuilder(tableDescriptor.getTableName()).build(); HRegion testRegion = HBaseTestingUtility.createRegionAndWAL(info, TEST_UTIL.getDataTestDir(), TEST_UTIL.getConfiguration(), tableDescriptor); for(int i=0; i<5; i++) { Put p = new Put(Bytes.toBytes((char)('a'+i) + "row")); p.setDurability(Durability.SKIP_WAL); p.addColumn(family, qualifier, Bytes.toBytes(String.valueOf(111 + i))); testRegion.put(p); } testRegion.flush(true); // rows starting with "b" PrefixFilter pf = new PrefixFilter(new byte[] {'b'}) ; // rows with value of column 'q1' set to '113' SingleColumnValueFilter scvf = new SingleColumnValueFilter( family, qualifier, CompareOperator.EQUAL, Bytes.toBytes("113")); // combine these two with OR in a FilterList FilterList filterList = new FilterList(Operator.MUST_PASS_ONE, pf, scvf); Scan s1 = new Scan(); s1.setFilter(filterList); InternalScanner scanner = testRegion.getScanner(s1); List<Cell> results = new ArrayList<>(); int resultCount = 0; while (scanner.next(results)) { resultCount++; byte[] row = CellUtil.cloneRow(results.get(0)); LOG.debug("Found row: " + Bytes.toStringBinary(row)); assertTrue(Bytes.equals(row, Bytes.toBytes("brow")) || Bytes.equals(row, Bytes.toBytes("crow"))); results.clear(); } assertEquals(2, resultCount); scanner.close(); WAL wal = ((HRegion)testRegion).getWAL(); ((HRegion)testRegion).close(); wal.close(); }
Example 8
Source File: TestInvocationRecordFilter.java From hbase with Apache License 2.0 | 4 votes |
@After public void tearDown() throws Exception { WAL wal = ((HRegion)region).getWAL(); ((HRegion)region).close(); wal.close(); }