Search in sources :

Example 11 with WALKey

use of org.apache.hadoop.hbase.wal.WALKey in project hbase by apache.

the class TestWALEntryStream method appendToLogPlus.

private void appendToLogPlus(int count) throws IOException {
    final long txid = log.append(info, new WALKey(info.getEncodedNameAsBytes(), tableName, System.currentTimeMillis(), mvcc, scopes), getWALEdits(count), true);
    log.sync(txid);
}
Also used : WALKey(org.apache.hadoop.hbase.wal.WALKey)

Example 12 with WALKey

use of org.apache.hadoop.hbase.wal.WALKey in project hbase by apache.

the class TestWALEntryStream method appendToLog.

private void appendToLog(String key) throws IOException {
    final long txid = log.append(info, new WALKey(info.getEncodedNameAsBytes(), tableName, System.currentTimeMillis(), mvcc, scopes), getWALEdit(key), true);
    log.sync(txid);
}
Also used : WALKey(org.apache.hadoop.hbase.wal.WALKey)

Example 13 with WALKey

use of org.apache.hadoop.hbase.wal.WALKey in project hbase by apache.

the class TestReplicationWALEntryFilters method testSystemTableWALEntryFilter.

@Test
public void testSystemTableWALEntryFilter() {
    SystemTableWALEntryFilter filter = new SystemTableWALEntryFilter();
    // meta
    WALKey key1 = new WALKey(HRegionInfo.FIRST_META_REGIONINFO.getEncodedNameAsBytes(), TableName.META_TABLE_NAME, System.currentTimeMillis());
    Entry metaEntry = new Entry(key1, null);
    assertNull(filter.filter(metaEntry));
    // ns table
    WALKey key2 = new WALKey(new byte[0], TableName.NAMESPACE_TABLE_NAME, System.currentTimeMillis());
    Entry nsEntry = new Entry(key2, null);
    assertNull(filter.filter(nsEntry));
    // user table
    WALKey key3 = new WALKey(new byte[0], TableName.valueOf("foo"), System.currentTimeMillis());
    Entry userEntry = new Entry(key3, null);
    assertEquals(userEntry, filter.filter(userEntry));
}
Also used : WALKey(org.apache.hadoop.hbase.wal.WALKey) Entry(org.apache.hadoop.hbase.wal.WAL.Entry) Test(org.junit.Test)

Example 14 with WALKey

use of org.apache.hadoop.hbase.wal.WALKey in project hbase by apache.

the class TestReplicationSource method testLogMoving.

/**
   * Sanity check that we can move logs around while we are reading
   * from them. Should this test fail, ReplicationSource would have a hard
   * time reading logs that are being archived.
   * @throws Exception
   */
@Test
public void testLogMoving() throws Exception {
    Path logPath = new Path(logDir, "log");
    if (!FS.exists(logDir))
        FS.mkdirs(logDir);
    if (!FS.exists(oldLogDir))
        FS.mkdirs(oldLogDir);
    WALProvider.Writer writer = WALFactory.createWALWriter(FS, logPath, TEST_UTIL.getConfiguration());
    for (int i = 0; i < 3; i++) {
        byte[] b = Bytes.toBytes(Integer.toString(i));
        KeyValue kv = new KeyValue(b, b, b);
        WALEdit edit = new WALEdit();
        edit.add(kv);
        WALKey key = new WALKey(b, TableName.valueOf(b), 0, 0, HConstants.DEFAULT_CLUSTER_ID);
        writer.append(new WAL.Entry(key, edit));
        writer.sync();
    }
    writer.close();
    WAL.Reader reader = WALFactory.createReader(FS, logPath, TEST_UTIL.getConfiguration());
    WAL.Entry entry = reader.next();
    assertNotNull(entry);
    Path oldLogPath = new Path(oldLogDir, "log");
    FS.rename(logPath, oldLogPath);
    entry = reader.next();
    assertNotNull(entry);
    entry = reader.next();
    entry = reader.next();
    assertNull(entry);
    reader.close();
}
Also used : Path(org.apache.hadoop.fs.Path) WALKey(org.apache.hadoop.hbase.wal.WALKey) KeyValue(org.apache.hadoop.hbase.KeyValue) WAL(org.apache.hadoop.hbase.wal.WAL) WALEdit(org.apache.hadoop.hbase.regionserver.wal.WALEdit) WALProvider(org.apache.hadoop.hbase.wal.WALProvider) HBaseInterClusterReplicationEndpoint(org.apache.hadoop.hbase.replication.regionserver.HBaseInterClusterReplicationEndpoint) Test(org.junit.Test)

Example 15 with WALKey

use of org.apache.hadoop.hbase.wal.WALKey in project hbase by apache.

the class TestReplicationSmallTests method testReplicationInReplay.

/**
   *  Test for HBase-15259 WALEdits under replay will also be replicated
   * */
@Test
public void testReplicationInReplay() throws Exception {
    final TableName tableName = htable1.getName();
    HRegion region = utility1.getMiniHBaseCluster().getRegions(tableName).get(0);
    HRegionInfo hri = region.getRegionInfo();
    NavigableMap<byte[], Integer> scopes = new TreeMap<>(Bytes.BYTES_COMPARATOR);
    for (byte[] fam : htable1.getTableDescriptor().getFamiliesKeys()) {
        scopes.put(fam, 1);
    }
    final MultiVersionConcurrencyControl mvcc = new MultiVersionConcurrencyControl();
    int index = utility1.getMiniHBaseCluster().getServerWith(hri.getRegionName());
    WAL wal = utility1.getMiniHBaseCluster().getRegionServer(index).getWAL(region.getRegionInfo());
    final byte[] rowName = Bytes.toBytes("testReplicationInReplay");
    final byte[] qualifier = Bytes.toBytes("q");
    final byte[] value = Bytes.toBytes("v");
    WALEdit edit = new WALEdit(true);
    long now = EnvironmentEdgeManager.currentTime();
    edit.add(new KeyValue(rowName, famName, qualifier, now, value));
    WALKey walKey = new WALKey(hri.getEncodedNameAsBytes(), tableName, now, mvcc, scopes);
    wal.append(hri, walKey, edit, true);
    wal.sync();
    Get get = new Get(rowName);
    for (int i = 0; i < NB_RETRIES; i++) {
        if (i == NB_RETRIES - 1) {
            break;
        }
        Result res = htable2.get(get);
        if (res.size() >= 1) {
            fail("Not supposed to be replicated for " + Bytes.toString(res.getRow()));
        } else {
            LOG.info("Row not replicated, let's wait a bit more...");
            Thread.sleep(SLEEP_TIME);
        }
    }
}
Also used : WAL(org.apache.hadoop.hbase.wal.WAL) KeyValue(org.apache.hadoop.hbase.KeyValue) MultiVersionConcurrencyControl(org.apache.hadoop.hbase.regionserver.MultiVersionConcurrencyControl) TreeMap(java.util.TreeMap) Result(org.apache.hadoop.hbase.client.Result) HRegionInfo(org.apache.hadoop.hbase.HRegionInfo) WALKey(org.apache.hadoop.hbase.wal.WALKey) TableName(org.apache.hadoop.hbase.TableName) HRegion(org.apache.hadoop.hbase.regionserver.HRegion) WALEdit(org.apache.hadoop.hbase.regionserver.wal.WALEdit) Get(org.apache.hadoop.hbase.client.Get) Test(org.junit.Test)

Aggregations

WALKey (org.apache.hadoop.hbase.wal.WALKey)51 WALEdit (org.apache.hadoop.hbase.regionserver.wal.WALEdit)29 Test (org.junit.Test)26 WAL (org.apache.hadoop.hbase.wal.WAL)22 TreeMap (java.util.TreeMap)17 HRegionInfo (org.apache.hadoop.hbase.HRegionInfo)17 KeyValue (org.apache.hadoop.hbase.KeyValue)16 HTableDescriptor (org.apache.hadoop.hbase.HTableDescriptor)15 IOException (java.io.IOException)14 Path (org.apache.hadoop.fs.Path)14 TableName (org.apache.hadoop.hbase.TableName)12 ArrayList (java.util.ArrayList)10 Cell (org.apache.hadoop.hbase.Cell)10 HColumnDescriptor (org.apache.hadoop.hbase.HColumnDescriptor)10 FileSystem (org.apache.hadoop.fs.FileSystem)9 Get (org.apache.hadoop.hbase.client.Get)9 Result (org.apache.hadoop.hbase.client.Result)9 MultiVersionConcurrencyControl (org.apache.hadoop.hbase.regionserver.MultiVersionConcurrencyControl)8 WALFactory (org.apache.hadoop.hbase.wal.WALFactory)8 Put (org.apache.hadoop.hbase.client.Put)7