Java Code Examples for org.apache.hadoop.hbase.protobuf.generated.HBaseProtos

The following examples show how to use org.apache.hadoop.hbase.protobuf.generated.HBaseProtos. These examples are extracted from open source projects. 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 Project: presto-hbase-connector   Source File: HBaseMetadata.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * create snapshot
 *
 * @param snapshotName snapshot name
 * @param admin        admin
 * @param schemaName   schema name
 * @param tableName    table name
 * @throws IOException io exception
 */
public static void createSnapshot(String snapshotName,
                                  Admin admin,
                                  String schemaName,
                                  String tableName) throws IOException {
    long start = System.currentTimeMillis();
    String fullTableName;
    if (Constant.HBASE_NAMESPACE_DEFAULT.equals(schemaName)
            || "".equals(schemaName)) {
        fullTableName = tableName;
    } else {
        fullTableName = schemaName + ":" + tableName;
    }
    HBaseProtos.SnapshotDescription snapshot = HBaseProtos.SnapshotDescription.newBuilder()
            .setName(snapshotName)
            .setTable(fullTableName)
            .setType(HBaseProtos.SnapshotDescription.Type.FLUSH)
            // .setType(HBaseProtos.SnapshotDescription.Type.DISABLED)
            .build();
    admin.snapshot(snapshot);
    log.info("createSnapshot: create snapshot " + snapshotName
            + " used " + (System.currentTimeMillis() - start) + " mill seconds.");
}
 
Example 2
Source Project: presto-hbase-connector   Source File: Utils.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * get region infos
 *
 * @param zookeeperQuorum     zookeeper quorum
 * @param zookeeperClientPort zookeeper client port
 * @param hBaseRootDir        HBase root dir
 * @param snapshotName        snapshot name
 * @return region info list
 * @throws IOException IOException
 */
public static List<HRegionInfo> getRegionInfos(String zookeeperQuorum, String zookeeperClientPort,
                                               String hBaseRootDir, String snapshotName) throws IOException {
    try {
        Configuration conf = Utils.getHadoopConf(zookeeperQuorum, zookeeperClientPort);
        Path root = new Path(hBaseRootDir);
        FileSystem fs = FileSystem.get(conf);
        Path snapshotDir = SnapshotDescriptionUtils.getCompletedSnapshotDir(snapshotName, root);
        HBaseProtos.SnapshotDescription snapshotDesc = SnapshotDescriptionUtils.readSnapshotInfo(fs, snapshotDir);
        SnapshotManifest manifest = SnapshotManifest.open(conf, fs, snapshotDir, snapshotDesc);
        return Utils.getRegionInfosFromManifest(manifest);
    } catch (IOException ex) {
        logger.error("get region info error: " + ex.getMessage(), ex);
        throw ex;
    }
}
 
Example 3
Source Project: hbase-tools   Source File: SnapshotOptionAfterScriptTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testAfterSuccess() throws Exception {
    List<HBaseProtos.SnapshotDescription> snapshotDescriptions;

    // all tables, keep unlimited
    String[] argsParam = {"localhost", ".*", "--test",
        "--" + Args.OPTION_AFTER_SUCCESS + "=" + AlertSenderTest.ALERT_SCRIPT};
    SnapshotArgs args = new SnapshotArgs(argsParam);
    Snapshot app = new Snapshot(admin, args);

    int sendCountBefore = AlertSender.getSendCount();

    // create snapshot
    app.run();
    snapshotDescriptions = listSnapshots(tableName + ".*");
    assertEquals(1, snapshotDescriptions.size());

    Assert.assertEquals(sendCountBefore + 1, AlertSender.getSendCount());
}
 
Example 4
Source Project: hbase-tools   Source File: SnapshotOptionTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testExclude() throws Exception {
    List<HBaseProtos.SnapshotDescription> snapshotDescriptions;
    String[] argsParam;
    SnapshotArgs args;
    Snapshot app;

    // create table
    String tableName2 = createAdditionalTable(tableName + "2");

    // with table list
    argsParam = new String[]{"localhost", ".*", "--exclude=" + tableName, "--test"};
    args = new SnapshotArgs(argsParam);
    app = new Snapshot(admin, args);

    // create snapshot
    app.run();
    snapshotDescriptions = listSnapshots(tableName + ".*");
    assertEquals(1, snapshotDescriptions.size());
    assertEquals(tableName2, snapshotDescriptions.get(0).getTable());
}
 
Example 5
Source Project: hbase-tools   Source File: SnapshotOptionTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testClearWatchLeak() throws Exception {
    List<HBaseProtos.SnapshotDescription> snapshotDescriptions;
    String[] argsParam;
    SnapshotArgs args;
    Snapshot app;

    // with option
    argsParam = new String[]{"localhost", ".*", "--test", "--clear-watch-leak"};
    args = new SnapshotArgs(argsParam);
    app = new Snapshot(admin, args);

    // create snapshot
    app.run();
    snapshotDescriptions = listSnapshots(tableName + ".*");
    assertEquals(1, snapshotDescriptions.size());
}
 
Example 6
Source Project: hbase-tools   Source File: SnapshotOptionTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testExcludeRegexList() throws Exception {
    List<HBaseProtos.SnapshotDescription> snapshotDescriptions;
    String[] argsParam;
    SnapshotArgs args;
    Snapshot app;

    // create table
    String tableName2 = createAdditionalTable(tableName + "2");
    createAdditionalTable(tableName + "21");

    // with table list
    argsParam = new String[]{"localhost", ".*", "--exclude=" + tableName2 + ".*", "--test"};
    args = new SnapshotArgs(argsParam);
    app = new Snapshot(admin, args);

    // create snapshot
    app.run();
    snapshotDescriptions = listSnapshots(tableName + ".*");
    assertEquals(1, snapshotDescriptions.size());
    assertEquals(tableName, snapshotDescriptions.get(0).getTable());
}
 
Example 7
Source Project: hbase-tools   Source File: SnapshotTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testDuplicatedName() throws Exception {
    List<HBaseProtos.SnapshotDescription> snapshotDescriptions;
    String[] argsParam;
    SnapshotArgs args;
    Snapshot app;

    argsParam = new String[]{"localhost", ".*", "--test"};
    args = new SnapshotArgs(argsParam);
    app = new Snapshot(admin, args);

    String snapshotName = app.getPrefix(tableName) + "test";
    // create snapshot first
    app.snapshot(null, tableName, snapshotName);
    snapshotDescriptions = listSnapshots(tableName + ".*");
    assertEquals(1, snapshotDescriptions.size());

    // create snapshot again
    app.snapshot(null, tableName, snapshotName);
    snapshotDescriptions = listSnapshots(tableName + ".*");
    assertEquals(1, snapshotDescriptions.size());
}
 
Example 8
Source Project: hbase-tools   Source File: SnapshotTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testNamespace() throws Exception {
    List<HBaseProtos.SnapshotDescription> snapshotDescriptions;
    String[] argsParam;
    SnapshotArgs args;
    Snapshot app;
    String fullTableName = null;

    try {
        // create table with namespace
        fullTableName = TEST_NAMESPACE + ":" + TestBase.tableName;
        createTable(fullTableName);

        // table with namespace
        argsParam = new String[]{"localhost", fullTableName};
        args = new SnapshotArgs(argsParam);
        app = new Snapshot(admin, args);

        // create snapshot
        app.run();
        snapshotDescriptions = admin.listSnapshots(app.getPrefix(fullTableName) + ".*");
        assertEquals(1, snapshotDescriptions.size());
    } finally {
        dropTable(fullTableName);
    }
}
 
Example 9
Source Project: hbase-tools   Source File: SnapshotOptionAfterScriptTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testAfterSuccess() throws Exception {
    List<HBaseProtos.SnapshotDescription> snapshotDescriptions;

    // all tables, keep unlimited
    String[] argsParam = {"localhost", ".*", "--test",
        "--" + Args.OPTION_AFTER_SUCCESS + "=" + AlertSenderTest.ALERT_SCRIPT};
    SnapshotArgs args = new SnapshotArgs(argsParam);
    Snapshot app = new Snapshot(admin, args);

    int sendCountBefore = AlertSender.getSendCount();

    // create snapshot
    app.run();
    snapshotDescriptions = listSnapshots(tableName + ".*");
    assertEquals(1, snapshotDescriptions.size());

    Assert.assertEquals(sendCountBefore + 1, AlertSender.getSendCount());
}
 
Example 10
Source Project: hbase-tools   Source File: SnapshotOptionTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testExclude() throws Exception {
    List<HBaseProtos.SnapshotDescription> snapshotDescriptions;
    String[] argsParam;
    SnapshotArgs args;
    Snapshot app;

    // create table
    String tableName2 = createAdditionalTable(tableName + "2");

    // with table list
    argsParam = new String[]{"localhost", ".*", "--exclude=" + tableName, "--test"};
    args = new SnapshotArgs(argsParam);
    app = new Snapshot(admin, args);

    // create snapshot
    app.run();
    snapshotDescriptions = listSnapshots(tableName + ".*");
    assertEquals(1, snapshotDescriptions.size());
    assertEquals(tableName2, snapshotDescriptions.get(0).getTable());
}
 
Example 11
Source Project: hbase-tools   Source File: SnapshotOptionTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testClearWatchLeak() throws Exception {
    List<HBaseProtos.SnapshotDescription> snapshotDescriptions;
    String[] argsParam;
    SnapshotArgs args;
    Snapshot app;

    // with option
    argsParam = new String[]{"localhost", ".*", "--test", "--clear-watch-leak"};
    args = new SnapshotArgs(argsParam);
    app = new Snapshot(admin, args);

    // create snapshot
    app.run();
    snapshotDescriptions = listSnapshots(tableName + ".*");
    assertEquals(1, snapshotDescriptions.size());
}
 
Example 12
Source Project: hbase-tools   Source File: SnapshotOptionTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testExcludeRegexList() throws Exception {
    List<HBaseProtos.SnapshotDescription> snapshotDescriptions;
    String[] argsParam;
    SnapshotArgs args;
    Snapshot app;

    // create table
    String tableName2 = createAdditionalTable(tableName + "2");
    createAdditionalTable(tableName + "21");

    // with table list
    argsParam = new String[]{"localhost", ".*", "--exclude=" + tableName2 + ".*", "--test"};
    args = new SnapshotArgs(argsParam);
    app = new Snapshot(admin, args);

    // create snapshot
    app.run();
    snapshotDescriptions = listSnapshots(tableName + ".*");
    assertEquals(1, snapshotDescriptions.size());
    assertEquals(tableName, snapshotDescriptions.get(0).getTable());
}
 
Example 13
Source Project: hbase-tools   Source File: SnapshotTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testDuplicatedName() throws Exception {
    List<HBaseProtos.SnapshotDescription> snapshotDescriptions;
    String[] argsParam;
    SnapshotArgs args;
    Snapshot app;

    argsParam = new String[]{"localhost", ".*", "--test"};
    args = new SnapshotArgs(argsParam);
    app = new Snapshot(admin, args);

    String snapshotName = app.getPrefix(tableName) + "test";
    // create snapshot first
    app.snapshot(null, tableName, snapshotName);
    snapshotDescriptions = listSnapshots(tableName + ".*");
    assertEquals(1, snapshotDescriptions.size());

    // create snapshot again
    app.snapshot(null, tableName, snapshotName);
    snapshotDescriptions = listSnapshots(tableName + ".*");
    assertEquals(1, snapshotDescriptions.size());
}
 
Example 14
Source Project: hbase-tools   Source File: SnapshotTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testNamespace() throws Exception {
    List<HBaseProtos.SnapshotDescription> snapshotDescriptions;
    String[] argsParam;
    SnapshotArgs args;
    Snapshot app;
    String fullTableName = null;

    try {
        // create table with namespace
        fullTableName = TEST_NAMESPACE + ":" + TestBase.tableName;
        createTable(fullTableName);

        // table with namespace
        argsParam = new String[]{"localhost", fullTableName};
        args = new SnapshotArgs(argsParam);
        app = new Snapshot(admin, args);

        // create snapshot
        app.run();
        snapshotDescriptions = admin.listSnapshots(app.getPrefix(fullTableName) + ".*");
        assertEquals(1, snapshotDescriptions.size());
    } finally {
        dropTable(fullTableName);
    }
}
 
Example 15
Source Project: hbase-tools   Source File: SnapshotOptionAfterScriptTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testAfterSuccess() throws Exception {
    List<HBaseProtos.SnapshotDescription> snapshotDescriptions;

    // all tables, keep unlimited
    String[] argsParam = {"localhost", ".*", "--test",
        "--" + Args.OPTION_AFTER_SUCCESS + "=" + AlertSenderTest.ALERT_SCRIPT};
    SnapshotArgs args = new SnapshotArgs(argsParam);
    Snapshot app = new Snapshot(admin, args);

    int sendCountBefore = AlertSender.getSendCount();

    // create snapshot
    app.run();
    snapshotDescriptions = listSnapshots(tableName + ".*");
    assertEquals(1, snapshotDescriptions.size());

    Assert.assertEquals(sendCountBefore + 1, AlertSender.getSendCount());
}
 
Example 16
Source Project: hbase-tools   Source File: SnapshotOptionTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testExclude() throws Exception {
    List<HBaseProtos.SnapshotDescription> snapshotDescriptions;
    String[] argsParam;
    SnapshotArgs args;
    Snapshot app;

    // create table
    String tableName2 = createAdditionalTable(tableName + "2");

    // with table list
    argsParam = new String[]{"localhost", ".*", "--exclude=" + tableName, "--test"};
    args = new SnapshotArgs(argsParam);
    app = new Snapshot(admin, args);

    // create snapshot
    app.run();
    snapshotDescriptions = listSnapshots(tableName + ".*");
    assertEquals(1, snapshotDescriptions.size());
    assertEquals(tableName2, snapshotDescriptions.get(0).getTable());
}
 
Example 17
Source Project: hbase-tools   Source File: SnapshotOptionTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testClearWatchLeak() throws Exception {
    List<HBaseProtos.SnapshotDescription> snapshotDescriptions;
    String[] argsParam;
    SnapshotArgs args;
    Snapshot app;

    // with option
    argsParam = new String[]{"localhost", ".*", "--test", "--clear-watch-leak"};
    args = new SnapshotArgs(argsParam);
    app = new Snapshot(admin, args);

    // create snapshot
    app.run();
    snapshotDescriptions = listSnapshots(tableName + ".*");
    assertEquals(1, snapshotDescriptions.size());
}
 
Example 18
Source Project: hbase-tools   Source File: SnapshotOptionTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testExcludeRegexList() throws Exception {
    List<HBaseProtos.SnapshotDescription> snapshotDescriptions;
    String[] argsParam;
    SnapshotArgs args;
    Snapshot app;

    // create table
    String tableName2 = createAdditionalTable(tableName + "2");
    createAdditionalTable(tableName + "21");

    // with table list
    argsParam = new String[]{"localhost", ".*", "--exclude=" + tableName2 + ".*", "--test"};
    args = new SnapshotArgs(argsParam);
    app = new Snapshot(admin, args);

    // create snapshot
    app.run();
    snapshotDescriptions = listSnapshots(tableName + ".*");
    assertEquals(1, snapshotDescriptions.size());
    assertEquals(tableName, snapshotDescriptions.get(0).getTable());
}
 
Example 19
Source Project: hbase-tools   Source File: SnapshotTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testDuplicatedName() throws Exception {
    List<HBaseProtos.SnapshotDescription> snapshotDescriptions;
    String[] argsParam;
    SnapshotArgs args;
    Snapshot app;

    argsParam = new String[]{"localhost", ".*", "--test"};
    args = new SnapshotArgs(argsParam);
    app = new Snapshot(admin, args);

    String snapshotName = app.getPrefix(tableName) + "test";
    // create snapshot first
    app.snapshot(null, tableName, snapshotName);
    snapshotDescriptions = listSnapshots(tableName + ".*");
    assertEquals(1, snapshotDescriptions.size());

    // create snapshot again
    app.snapshot(null, tableName, snapshotName);
    snapshotDescriptions = listSnapshots(tableName + ".*");
    assertEquals(1, snapshotDescriptions.size());
}
 
Example 20
Source Project: hbase-tools   Source File: SnapshotTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testNamespace() throws Exception {
    List<HBaseProtos.SnapshotDescription> snapshotDescriptions;
    String[] argsParam;
    SnapshotArgs args;
    Snapshot app;
    String fullTableName = null;

    try {
        // create table with namespace
        fullTableName = TEST_NAMESPACE + ":" + TestBase.tableName;
        createTable(fullTableName);

        // table with namespace
        argsParam = new String[]{"localhost", fullTableName};
        args = new SnapshotArgs(argsParam);
        app = new Snapshot(admin, args);

        // create snapshot
        app.run();
        snapshotDescriptions = admin.listSnapshots(app.getPrefix(fullTableName) + ".*");
        assertEquals(1, snapshotDescriptions.size());
    } finally {
        dropTable(fullTableName);
    }
}
 
Example 21
Source Project: hbase-tools   Source File: SnapshotArgs.java    License: Apache License 2.0 5 votes vote down vote up
public HBaseProtos.SnapshotDescription.Type flushType(String tableName) {
    if (tableFlushMap.get(tableName) == null) {
        return SnapshotAdapter.getType(optionSet);
    } else {
        return SnapshotAdapter.getType(tableName, tableFlushMap);
    }
}
 
Example 22
Source Project: hbase-tools   Source File: SnapshotAdapter.java    License: Apache License 2.0 5 votes vote down vote up
public static HBaseProtos.SnapshotDescription.Type getType(String tableName, Map<String, Boolean> tableFlushMap) {
    if (tableFlushMap.get(tableName)) {
        return HBaseProtos.SnapshotDescription.Type.SKIPFLUSH;
    } else {
        return HBaseProtos.SnapshotDescription.Type.FLUSH;
    }
}
 
Example 23
Source Project: hbase-tools   Source File: SnapshotAdapter.java    License: Apache License 2.0 5 votes vote down vote up
public static HBaseProtos.SnapshotDescription.Type getType(OptionSet optionSet) {
    if (optionSet.has(Args.OPTION_SKIP_FLUSH)) {
        return HBaseProtos.SnapshotDescription.Type.SKIPFLUSH;
    } else {
        return HBaseProtos.SnapshotDescription.Type.FLUSH;
    }
}
 
Example 24
Source Project: hbase-tools   Source File: TestBase.java    License: Apache License 2.0 5 votes vote down vote up
protected void deleteSnapshots(String tableName) throws Exception {
    for (HBaseProtos.SnapshotDescription snapshotDescription : admin.listSnapshots(".*" + tableName + ".*")) {
        if (snapshotDescription.getTable().equals(tableName) || snapshotDescription.getTable().equals(TEST_NAMESPACE + ":" + tableName)) {
            admin.deleteSnapshots(snapshotDescription.getName());
        }
    }
}
 
Example 25
Source Project: hbase-tools   Source File: SnapshotArgs.java    License: Apache License 2.0 5 votes vote down vote up
public HBaseProtos.SnapshotDescription.Type flushType(String tableName) {
    if (tableFlushMap.get(tableName) == null) {
        return SnapshotAdapter.getType(optionSet);
    } else {
        return SnapshotAdapter.getType(tableName, tableFlushMap);
    }
}
 
Example 26
Source Project: hbase-tools   Source File: SnapshotTableArgTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testRegexList() throws Exception {
    // create tables
    String tableName2 = createAdditionalTable(tableName + "2");
    String tableName3 = createAdditionalTable(tableName + "3");

    List<HBaseProtos.SnapshotDescription> snapshotDescriptions;

    // all tables, keep unlimited
    String[] argsParam = {"localhost", tableName + ".*," + tableName2 + ".*," + tableName3 + ".*"};
    SnapshotArgs args = new SnapshotArgs(argsParam);
    Snapshot app = new Snapshot(admin, args);

    // create snapshot 1
    app.run();
    snapshotDescriptions = listSnapshots(tableName + ".*");
    assertEquals(3, snapshotDescriptions.size());

    // create snapshot 2
    Thread.sleep(1000);
    app.run();
    snapshotDescriptions = listSnapshots(tableName + ".*");
    assertEquals(6, snapshotDescriptions.size());

    // create snapshot 3
    Thread.sleep(1000);
    app.run();
    snapshotDescriptions = listSnapshots(tableName + ".*");
    assertEquals(9, snapshotDescriptions.size());

    // create snapshot 3
    Thread.sleep(1000);
    app.run();
    snapshotDescriptions = listSnapshots(tableName + ".*");
    assertEquals(12, snapshotDescriptions.size());
}
 
Example 27
Source Project: hbase-tools   Source File: SnapshotTableArgTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testList() throws Exception {
    List<HBaseProtos.SnapshotDescription> snapshotDescriptions;
    String[] argsParam;
    SnapshotArgs args;
    Snapshot app;

    // create table
    String tableName2 = createAdditionalTable(tableName + "2");

    // with table list
    argsParam = new String[]{"localhost", tableName + "," + tableName2};
    args = new SnapshotArgs(argsParam);
    app = new Snapshot(admin, args);

    // create snapshot
    app.run();
    snapshotDescriptions = listSnapshots(tableName + ".*");
    assertEquals(2, snapshotDescriptions.size());

    // with table list contains blank
    argsParam = new String[]{"localhost", tableName + " , " + tableName2};
    args = new SnapshotArgs(argsParam);
    app = new Snapshot(admin, args);

    // create snapshot
    Thread.sleep(1000);
    app.run();
    snapshotDescriptions = listSnapshots(tableName + ".*");
    assertEquals(4, snapshotDescriptions.size());
}
 
Example 28
Source Project: hbase-tools   Source File: SnapshotTableArgTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testDetailList() throws Exception {
    List<HBaseProtos.SnapshotDescription> snapshotDescriptions;
    String[] argsParam;
    SnapshotArgs args;
    Snapshot app;

    // create table
    String tableName2 = createAdditionalTable(tableName + "2");

    // with table list
    argsParam = new String[]{"localhost", tableName + "/1/true," + tableName2 + "/2/false"};
    args = new SnapshotArgs(argsParam);
    app = new Snapshot(admin, args);

    // create snapshot 1
    app.run();
    snapshotDescriptions = listSnapshots(tableName + ".*");
    assertEquals(2, snapshotDescriptions.size());
    assertEquals(tableName2, snapshotDescriptions.get(0).getTable());
    assertEquals(HBaseProtos.SnapshotDescription.Type.FLUSH, snapshotDescriptions.get(0).getType());
    assertEquals(tableName, snapshotDescriptions.get(1).getTable());
    assertEquals(HBaseProtos.SnapshotDescription.Type.SKIPFLUSH, snapshotDescriptions.get(1).getType());

    // create snapshot 2
    Thread.sleep(1000);
    app.run();
    snapshotDescriptions = listSnapshots(tableName + ".*");
    assertEquals(3, snapshotDescriptions.size());
    assertEquals(tableName2, snapshotDescriptions.get(0).getTable());
    assertEquals(HBaseProtos.SnapshotDescription.Type.FLUSH, snapshotDescriptions.get(0).getType());
    assertEquals(tableName2, snapshotDescriptions.get(1).getTable());
    assertEquals(HBaseProtos.SnapshotDescription.Type.FLUSH, snapshotDescriptions.get(1).getType());
    assertEquals(tableName, snapshotDescriptions.get(2).getTable());
    assertEquals(HBaseProtos.SnapshotDescription.Type.SKIPFLUSH, snapshotDescriptions.get(2).getType());
}
 
Example 29
Source Project: hbase-tools   Source File: SnapshotOptionTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testSkipFlush() throws Exception {
    List<HBaseProtos.SnapshotDescription> snapshotDescriptions;
    String[] argsParam;
    SnapshotArgs args;
    Snapshot app;

    // skip flush
    argsParam = new String[]{"localhost", ".*", "--skip-flush=true", "--test"};
    args = new SnapshotArgs(argsParam);
    app = new Snapshot(admin, args);

    // create snapshot
    app.run();
    snapshotDescriptions = listSnapshots(tableName + ".*");
    assertEquals(1, snapshotDescriptions.size());
    assertEquals(HBaseProtos.SnapshotDescription.Type.SKIPFLUSH, snapshotDescriptions.get(0).getType());

    // do not skip flush
    argsParam = new String[]{"localhost", ".*", "--test"};
    args = new SnapshotArgs(argsParam);
    app = new Snapshot(admin, args);

    // create snapshot
    Thread.sleep(1000);
    app.run();
    snapshotDescriptions = listSnapshots(tableName + ".*");
    assertEquals(2, snapshotDescriptions.size());
    assertEquals(HBaseProtos.SnapshotDescription.Type.FLUSH, snapshotDescriptions.get(1).getType());
}
 
Example 30
Source Project: hbase-tools   Source File: SnapshotOptionTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testOverride() throws Exception {
    List<HBaseProtos.SnapshotDescription> snapshotDescriptions;
    String[] argsParam;
    SnapshotArgs args;
    Snapshot app;

    // create table
    String tableName2 = createAdditionalTable(tableName + "2");

    // with table list
    argsParam = new String[]{"localhost", ".*", "--override=" + tableName + "/1/true", "--keep=2", "--test"};
    args = new SnapshotArgs(argsParam);
    app = new Snapshot(admin, args);

    // create snapshot 1
    app.run();
    snapshotDescriptions = listSnapshots(tableName + ".*");
    assertEquals(2, snapshotDescriptions.size());
    assertEquals(tableName2, snapshotDescriptions.get(0).getTable());
    assertEquals(HBaseProtos.SnapshotDescription.Type.FLUSH, snapshotDescriptions.get(0).getType());
    assertEquals(tableName, snapshotDescriptions.get(1).getTable());
    assertEquals(HBaseProtos.SnapshotDescription.Type.SKIPFLUSH, snapshotDescriptions.get(1).getType());

    // create snapshot 2
    Thread.sleep(1000);
    app.run();
    snapshotDescriptions = listSnapshots(tableName + ".*");
    assertEquals(3, snapshotDescriptions.size());
    assertEquals(tableName2, snapshotDescriptions.get(0).getTable());
    assertEquals(HBaseProtos.SnapshotDescription.Type.FLUSH, snapshotDescriptions.get(0).getType());
    assertEquals(tableName2, snapshotDescriptions.get(1).getTable());
    assertEquals(HBaseProtos.SnapshotDescription.Type.FLUSH, snapshotDescriptions.get(1).getType());
    assertEquals(tableName, snapshotDescriptions.get(2).getTable());
    assertEquals(HBaseProtos.SnapshotDescription.Type.SKIPFLUSH, snapshotDescriptions.get(2).getType());
}