当前位置: 首页>>代码示例>>Java>>正文


Java SnapshotTestingUtils.loadData方法代码示例

本文整理汇总了Java中org.apache.hadoop.hbase.snapshot.SnapshotTestingUtils.loadData方法的典型用法代码示例。如果您正苦于以下问题:Java SnapshotTestingUtils.loadData方法的具体用法?Java SnapshotTestingUtils.loadData怎么用?Java SnapshotTestingUtils.loadData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.hadoop.hbase.snapshot.SnapshotTestingUtils的用法示例。


在下文中一共展示了SnapshotTestingUtils.loadData方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testCloneLinksAfterDelete

import org.apache.hadoop.hbase.snapshot.SnapshotTestingUtils; //导入方法依赖的package包/类
@Test
@Override
public void testCloneLinksAfterDelete() throws IOException, InterruptedException {
  // delay the flush to make sure
  delayFlush = true;
  SnapshotTestingUtils.loadData(TEST_UTIL, tableName, 20, FAMILY);
  long tid = System.currentTimeMillis();
  byte[] snapshotName3 = Bytes.toBytes("snaptb3-" + tid);
  TableName clonedTableName3 = TableName.valueOf(name.getMethodName() + System.currentTimeMillis());
  admin.snapshot(snapshotName3, tableName);
  delayFlush = false;
  int snapshot3Rows = -1;
  try (Table table = TEST_UTIL.getConnection().getTable(tableName)) {
    snapshot3Rows = TEST_UTIL.countRows(table);
  }
  admin.cloneSnapshot(snapshotName3, clonedTableName3);
  admin.deleteSnapshot(snapshotName3);
  super.testCloneLinksAfterDelete();
  verifyRowCount(TEST_UTIL, clonedTableName3, snapshot3Rows);
  admin.disableTable(clonedTableName3);
  admin.deleteTable(clonedTableName3);
}
 
开发者ID:apache,项目名称:hbase,代码行数:23,代码来源:TestMobCloneSnapshotFromClient.java

示例2: getSnapshot

import org.apache.hadoop.hbase.snapshot.SnapshotTestingUtils; //导入方法依赖的package包/类
private SnapshotProtos.SnapshotDescription getSnapshot() throws Exception {
  if (snapshot == null) {
    final TableName snapshotTableName = TableName.valueOf("testCloneSnapshot");
    long tid = System.currentTimeMillis();
    final byte[] snapshotName = Bytes.toBytes("snapshot-" + tid);

    Admin admin = UTIL.getAdmin();
    // create Table
    SnapshotTestingUtils.createTable(UTIL, snapshotTableName, getNumReplicas(), CF);
    // Load data
    SnapshotTestingUtils.loadData(UTIL, snapshotTableName, 500, CF);
    admin.disableTable(snapshotTableName);
    // take a snapshot
    admin.snapshot(snapshotName, snapshotTableName);
    admin.enableTable(snapshotTableName);

    List<SnapshotDescription> snapshotList = admin.listSnapshots();
    snapshot = ProtobufUtil.createHBaseProtosSnapshotDesc(snapshotList.get(0));
  }
  return snapshot;
}
 
开发者ID:apache,项目名称:hbase,代码行数:22,代码来源:TestCloneSnapshotProcedure.java

示例3: testFlushCreateListDestroy

import org.apache.hadoop.hbase.snapshot.SnapshotTestingUtils; //导入方法依赖的package包/类
/**
 * Basic end-to-end test of simple-flush-based snapshots
 */
@Test (timeout=300000)
public void testFlushCreateListDestroy() throws Exception {
  LOG.debug("------- Starting Snapshot test -------------");
  HBaseAdmin admin = UTIL.getHBaseAdmin();
  // make sure we don't fail on listing snapshots
  SnapshotTestingUtils.assertNoSnapshots(admin);
  // load the table so we have some data
  SnapshotTestingUtils.loadData(UTIL, TABLE_NAME, DEFAULT_NUM_ROWS, TEST_FAM);

  String snapshotName = "flushSnapshotCreateListDestroy";
  FileSystem fs = UTIL.getHBaseCluster().getMaster().getMasterFileSystem().getFileSystem();
  Path rootDir = UTIL.getHBaseCluster().getMaster().getMasterFileSystem().getRootDir();
  SnapshotTestingUtils.createSnapshotAndValidate(admin,
    TableName.valueOf(STRING_TABLE_NAME), Bytes.toString(TEST_FAM),
    snapshotName, rootDir, fs, true);
}
 
开发者ID:shenli-uiuc,项目名称:PyroDB,代码行数:20,代码来源:TestFlushSnapshotFromClient.java

示例4: setup

import org.apache.hadoop.hbase.snapshot.SnapshotTestingUtils; //导入方法依赖的package包/类
/**
 * Initialize the tests with a table filled with some data
 * and two snapshots (snapshotName0, snapshotName1) of different states.
 * The tableName, snapshotNames and the number of rows in the snapshot are initialized.
 */
@Before
public void setup() throws Exception {
  this.admin = TEST_UTIL.getHBaseAdmin();

  long tid = System.currentTimeMillis();
  tableName =
      TableName.valueOf("testtb-" + tid);
  emptySnapshot = Bytes.toBytes("emptySnaptb-" + tid);
  snapshotName0 = Bytes.toBytes("snaptb0-" + tid);
  snapshotName1 = Bytes.toBytes("snaptb1-" + tid);
  snapshotName2 = Bytes.toBytes("snaptb2-" + tid);

  // create Table and disable it
  SnapshotTestingUtils.createTable(TEST_UTIL, tableName, getNumReplicas(), FAMILY);
  admin.disableTable(tableName);

  // take an empty snapshot
  admin.snapshot(emptySnapshot, tableName);

  // enable table and insert data
  admin.enableTable(tableName);
  SnapshotTestingUtils.loadData(TEST_UTIL, tableName, 500, FAMILY);
  try (Table table = TEST_UTIL.getConnection().getTable(tableName)) {
    snapshot0Rows = TEST_UTIL.countRows(table);
  }
  admin.disableTable(tableName);

  // take a snapshot
  admin.snapshot(snapshotName0, tableName);

  // enable table and insert more data
  admin.enableTable(tableName);
  SnapshotTestingUtils.loadData(TEST_UTIL, tableName, 500, FAMILY);
  try (Table table = TEST_UTIL.getConnection().getTable(tableName)) {
    snapshot1Rows = TEST_UTIL.countRows(table);
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:43,代码来源:TestRestoreSnapshotFromClient.java

示例5: setup

import org.apache.hadoop.hbase.snapshot.SnapshotTestingUtils; //导入方法依赖的package包/类
/**
 * Initialize the tests with a table filled with some data
 * and two snapshots (snapshotName0, snapshotName1) of different states.
 * The tableName, snapshotNames and the number of rows in the snapshot are initialized.
 */
@Before
public void setup() throws Exception {
  this.admin = TEST_UTIL.getHBaseAdmin();

  long tid = System.currentTimeMillis();
  tableName =
      TableName.valueOf("testtb-" + tid);
  emptySnapshot = Bytes.toBytes("emptySnaptb-" + tid);
  snapshotName0 = Bytes.toBytes("snaptb0-" + tid);
  snapshotName1 = Bytes.toBytes("snaptb1-" + tid);
  snapshotName2 = Bytes.toBytes("snaptb2-" + tid);

  // create Table and disable it
  SnapshotTestingUtils.createTable(TEST_UTIL, tableName, FAMILY);
  admin.disableTable(tableName);

  // take an empty snapshot
  admin.snapshot(emptySnapshot, tableName);

  HTable table = new HTable(TEST_UTIL.getConfiguration(), tableName);
  // enable table and insert data
  admin.enableTable(tableName);
  SnapshotTestingUtils.loadData(TEST_UTIL, table, 500, FAMILY);
  snapshot0Rows = TEST_UTIL.countRows(table);
  admin.disableTable(tableName);

  // take a snapshot
  admin.snapshot(snapshotName0, tableName);

  // enable table and insert more data
  admin.enableTable(tableName);
  SnapshotTestingUtils.loadData(TEST_UTIL, table, 500, FAMILY);
  snapshot1Rows = TEST_UTIL.countRows(table);
  table.close();
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:41,代码来源:TestRestoreSnapshotFromClient.java

示例6: setup

import org.apache.hadoop.hbase.snapshot.SnapshotTestingUtils; //导入方法依赖的package包/类
/**
 * Initialize the tests with a table filled with some data
 * and two snapshots (snapshotName0, snapshotName1) of different states.
 * The tableName, snapshotNames and the number of rows in the snapshot are initialized.
 */
@Before
public void setup() throws Exception {
  this.admin = TEST_UTIL.getAdmin();

  long tid = System.currentTimeMillis();
  tableName = TableName.valueOf(name.getMethodName() + "-" + tid);
  emptySnapshot = Bytes.toBytes("emptySnaptb-" + tid);
  snapshotName0 = Bytes.toBytes("snaptb0-" + tid);
  snapshotName1 = Bytes.toBytes("snaptb1-" + tid);
  snapshotName2 = Bytes.toBytes("snaptb2-" + tid);

  // create Table and disable it
  createTable();
  admin.disableTable(tableName);

  // take an empty snapshot
  admin.snapshot(emptySnapshot, tableName);

  // enable table and insert data
  admin.enableTable(tableName);
  SnapshotTestingUtils.loadData(TEST_UTIL, tableName, 500, FAMILY);
  try (Table table = TEST_UTIL.getConnection().getTable(tableName)) {
    snapshot0Rows = countRows(table);
  }
  admin.disableTable(tableName);

  // take a snapshot
  admin.snapshot(snapshotName0, tableName);

  // enable table and insert more data
  admin.enableTable(tableName);
  SnapshotTestingUtils.loadData(TEST_UTIL, tableName, 500, FAMILY);
  try (Table table = TEST_UTIL.getConnection().getTable(tableName)) {
    snapshot1Rows = countRows(table);
  }
}
 
开发者ID:apache,项目名称:hbase,代码行数:42,代码来源:TestRestoreSnapshotFromClient.java

示例7: createTableAndSnapshots

import org.apache.hadoop.hbase.snapshot.SnapshotTestingUtils; //导入方法依赖的package包/类
@Override
protected void createTableAndSnapshots() throws Exception {
  // create Table and disable it
  createMobTable(TEST_UTIL, tableName, SnapshotTestingUtils.getSplitKeys(), getNumReplicas(),
    FAMILY);
  delayFlush = false;
  admin.disableTable(tableName);

  // take an empty snapshot
  admin.snapshot(emptySnapshot, tableName);

  Connection c = ConnectionFactory.createConnection(TEST_UTIL.getConfiguration());
  Table table = c.getTable(tableName);
  try {
    // enable table and insert data
    admin.enableTable(tableName);
    SnapshotTestingUtils.loadData(TEST_UTIL, tableName, 20, FAMILY);
    snapshot0Rows = MobSnapshotTestingUtils.countMobRows(table);
    admin.disableTable(tableName);

    // take a snapshot
    admin.snapshot(snapshotName0, tableName);

    // enable table and insert more data
    admin.enableTable(tableName);
    SnapshotTestingUtils.loadData(TEST_UTIL, tableName, 20, FAMILY);
    snapshot1Rows = MobSnapshotTestingUtils.countMobRows(table);
    admin.disableTable(tableName);

    // take a snapshot of the updated table
    admin.snapshot(snapshotName1, tableName);

    // re-enable table
    admin.enableTable(tableName);
  } finally {
    table.close();
  }
}
 
开发者ID:apache,项目名称:hbase,代码行数:39,代码来源:TestMobCloneSnapshotFromClient.java

示例8: testFlushTableSnapshot

import org.apache.hadoop.hbase.snapshot.SnapshotTestingUtils; //导入方法依赖的package包/类
/**
 * Test simple flush snapshotting a table that is online
 * @throws Exception
 */
@Test (timeout=300000)
public void testFlushTableSnapshot() throws Exception {
  HBaseAdmin admin = UTIL.getHBaseAdmin();
  // make sure we don't fail on listing snapshots
  SnapshotTestingUtils.assertNoSnapshots(admin);

  // put some stuff in the table
  HTable table = new HTable(UTIL.getConfiguration(), TABLE_NAME);
  SnapshotTestingUtils.loadData(UTIL, table, DEFAULT_NUM_ROWS, TEST_FAM);

  LOG.debug("FS state before snapshot:");
  FSUtils.logFileSystemState(UTIL.getTestFileSystem(),
      FSUtils.getRootDir(UTIL.getConfiguration()), LOG);

  // take a snapshot of the enabled table
  String snapshotString = "offlineTableSnapshot";
  byte[] snapshot = Bytes.toBytes(snapshotString);
  admin.snapshot(snapshotString, STRING_TABLE_NAME, SnapshotDescription.Type.FLUSH);
  LOG.debug("Snapshot completed.");

  // make sure we have the snapshot
  List<SnapshotDescription> snapshots = SnapshotTestingUtils.assertOneSnapshotThatMatches(admin,
    snapshot, TABLE_NAME);

  // make sure its a valid snapshot
  FileSystem fs = UTIL.getHBaseCluster().getMaster().getMasterFileSystem().getFileSystem();
  Path rootDir = UTIL.getHBaseCluster().getMaster().getMasterFileSystem().getRootDir();
  LOG.debug("FS state after snapshot:");
  FSUtils.logFileSystemState(UTIL.getTestFileSystem(),
      FSUtils.getRootDir(UTIL.getConfiguration()), LOG);

  SnapshotTestingUtils.confirmSnapshotValid(snapshots.get(0), TABLE_NAME, TEST_FAM, rootDir,
      admin, fs);
}
 
开发者ID:shenli-uiuc,项目名称:PyroDB,代码行数:39,代码来源:TestFlushSnapshotFromClient.java

示例9: testFlushTableSnapshotWithProcedure

import org.apache.hadoop.hbase.snapshot.SnapshotTestingUtils; //导入方法依赖的package包/类
/**
 * Test simple flush snapshotting a table that is online
 * @throws Exception
 */
@Test (timeout=300000)
public void testFlushTableSnapshotWithProcedure() throws Exception {
  HBaseAdmin admin = UTIL.getHBaseAdmin();
  // make sure we don't fail on listing snapshots
  SnapshotTestingUtils.assertNoSnapshots(admin);

  // put some stuff in the table
  HTable table = new HTable(UTIL.getConfiguration(), TABLE_NAME);
  SnapshotTestingUtils.loadData(UTIL, table, DEFAULT_NUM_ROWS, TEST_FAM);

  LOG.debug("FS state before snapshot:");
  FSUtils.logFileSystemState(UTIL.getTestFileSystem(),
      FSUtils.getRootDir(UTIL.getConfiguration()), LOG);

  // take a snapshot of the enabled table
  String snapshotString = "offlineTableSnapshot";
  byte[] snapshot = Bytes.toBytes(snapshotString);
  Map<String, String> props = new HashMap<String, String>();
  props.put("table", STRING_TABLE_NAME);
  admin.execProcedure(SnapshotManager.ONLINE_SNAPSHOT_CONTROLLER_DESCRIPTION,
      snapshotString, props);


  LOG.debug("Snapshot completed.");

  // make sure we have the snapshot
  List<SnapshotDescription> snapshots = SnapshotTestingUtils.assertOneSnapshotThatMatches(admin,
    snapshot, TABLE_NAME);

  // make sure its a valid snapshot
  FileSystem fs = UTIL.getHBaseCluster().getMaster().getMasterFileSystem().getFileSystem();
  Path rootDir = UTIL.getHBaseCluster().getMaster().getMasterFileSystem().getRootDir();
  LOG.debug("FS state after snapshot:");
  FSUtils.logFileSystemState(UTIL.getTestFileSystem(),
      FSUtils.getRootDir(UTIL.getConfiguration()), LOG);

  SnapshotTestingUtils.confirmSnapshotValid(snapshots.get(0), TABLE_NAME, TEST_FAM, rootDir,
      admin, fs);
}
 
开发者ID:shenli-uiuc,项目名称:PyroDB,代码行数:44,代码来源:TestFlushSnapshotFromClient.java

示例10: testRestoreSchemaChange

import org.apache.hadoop.hbase.snapshot.SnapshotTestingUtils; //导入方法依赖的package包/类
@Test
public void testRestoreSchemaChange() throws Exception {
  byte[] TEST_FAMILY2 = Bytes.toBytes("cf2");

  HTable table = new HTable(TEST_UTIL.getConfiguration(), tableName);

  // Add one column family and put some data in it
  admin.disableTable(tableName);
  admin.addColumn(tableName, new HColumnDescriptor(TEST_FAMILY2));
  admin.enableTable(tableName);
  assertEquals(2, table.getTableDescriptor().getFamilies().size());
  HTableDescriptor htd = admin.getTableDescriptor(tableName);
  assertEquals(2, htd.getFamilies().size());
  SnapshotTestingUtils.loadData(TEST_UTIL, tableName, 500, TEST_FAMILY2);
  long snapshot2Rows = snapshot1Rows + 500;
  assertEquals(snapshot2Rows, TEST_UTIL.countRows(table));
  assertEquals(500, TEST_UTIL.countRows(table, TEST_FAMILY2));
  Set<String> fsFamilies = getFamiliesFromFS(tableName);
  assertEquals(2, fsFamilies.size());

  // Take a snapshot
  admin.disableTable(tableName);
  admin.snapshot(snapshotName2, tableName);

  // Restore the snapshot (without the cf)
  admin.restoreSnapshot(snapshotName0);
  admin.enableTable(tableName);
  assertEquals(1, table.getTableDescriptor().getFamilies().size());
  try {
    TEST_UTIL.countRows(table, TEST_FAMILY2);
    fail("family '" + Bytes.toString(TEST_FAMILY2) + "' should not exists");
  } catch (NoSuchColumnFamilyException e) {
    // expected
  }
  assertEquals(snapshot0Rows, TEST_UTIL.countRows(table));
  htd = admin.getTableDescriptor(tableName);
  assertEquals(1, htd.getFamilies().size());
  fsFamilies = getFamiliesFromFS(tableName);
  assertEquals(1, fsFamilies.size());

  // Restore back the snapshot (with the cf)
  admin.disableTable(tableName);
  admin.restoreSnapshot(snapshotName2);
  admin.enableTable(tableName);
  htd = admin.getTableDescriptor(tableName);
  assertEquals(2, htd.getFamilies().size());
  assertEquals(2, table.getTableDescriptor().getFamilies().size());
  assertEquals(500, TEST_UTIL.countRows(table, TEST_FAMILY2));
  assertEquals(snapshot2Rows, TEST_UTIL.countRows(table));
  fsFamilies = getFamiliesFromFS(tableName);
  assertEquals(2, fsFamilies.size());
  table.close();
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:54,代码来源:TestRestoreSnapshotFromClient.java

示例11: setup

import org.apache.hadoop.hbase.snapshot.SnapshotTestingUtils; //导入方法依赖的package包/类
/**
 * Initialize the tests with a table filled with some data
 * and two snapshots (snapshotName0, snapshotName1) of different states.
 * The tableName, snapshotNames and the number of rows in the snapshot are initialized.
 */
@Before
public void setup() throws Exception {
  this.admin = TEST_UTIL.getHBaseAdmin();

  long tid = System.currentTimeMillis();
  tableName = TableName.valueOf("testtb-" + tid);
  emptySnapshot = Bytes.toBytes("emptySnaptb-" + tid);
  snapshotName0 = Bytes.toBytes("snaptb0-" + tid);
  snapshotName1 = Bytes.toBytes("snaptb1-" + tid);
  snapshotName2 = Bytes.toBytes("snaptb2-" + tid);

  // create Table and disable it
  SnapshotTestingUtils.createTable(TEST_UTIL, tableName, getNumReplicas(), FAMILY);
  admin.disableTable(tableName);

  // take an empty snapshot
  admin.snapshot(emptySnapshot, tableName);

  // enable table and insert data
  admin.enableTable(tableName);
  SnapshotTestingUtils.loadData(TEST_UTIL, tableName, 500, FAMILY);
  try (Table table = TEST_UTIL.getConnection().getTable(tableName)){
    snapshot0Rows = TEST_UTIL.countRows(table);
  }
  admin.disableTable(tableName);

  // take a snapshot
  admin.snapshot(snapshotName0, tableName);

  // enable table and insert more data
  admin.enableTable(tableName);
  SnapshotTestingUtils.loadData(TEST_UTIL, tableName, 500, FAMILY);
  try (Table table = TEST_UTIL.getConnection().getTable(tableName)){
    snapshot1Rows = TEST_UTIL.countRows(table);
  }
  admin.disableTable(tableName);

  // take a snapshot of the updated table
  admin.snapshot(snapshotName1, tableName);

  // re-enable table
  admin.enableTable(tableName);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:49,代码来源:TestCloneSnapshotFromClient.java

示例12: setup

import org.apache.hadoop.hbase.snapshot.SnapshotTestingUtils; //导入方法依赖的package包/类
/**
 * Initialize the tests with a table filled with some data
 * and two snapshots (snapshotName0, snapshotName1) of different states.
 * The tableName, snapshotNames and the number of rows in the snapshot are initialized.
 */
@Before
public void setup() throws Exception {
  this.admin = TEST_UTIL.getHBaseAdmin();

  long tid = System.currentTimeMillis();
  tableName = Bytes.toBytes("testtb-" + tid);
  emptySnapshot = Bytes.toBytes("emptySnaptb-" + tid);
  snapshotName0 = Bytes.toBytes("snaptb0-" + tid);
  snapshotName1 = Bytes.toBytes("snaptb1-" + tid);
  snapshotName2 = Bytes.toBytes("snaptb2-" + tid);

  // create Table and disable it
  SnapshotTestingUtils.createTable(TEST_UTIL, tableName, FAMILY);
  admin.disableTable(tableName);

  // take an empty snapshot
  admin.snapshot(emptySnapshot, tableName);

  HTable table = new HTable(TEST_UTIL.getConfiguration(), tableName);
  // enable table and insert data
  admin.enableTable(tableName);
  SnapshotTestingUtils.loadData(TEST_UTIL, table, 500, FAMILY);
  snapshot0Rows = TEST_UTIL.countRows(table);
  admin.disableTable(tableName);

  // take a snapshot
  admin.snapshot(snapshotName0, tableName);

  // enable table and insert more data
  admin.enableTable(tableName);
  SnapshotTestingUtils.loadData(TEST_UTIL, table, 500, FAMILY);
  snapshot1Rows = TEST_UTIL.countRows(table);
  admin.disableTable(tableName);

  // take a snapshot of the updated table
  admin.snapshot(snapshotName1, tableName);

  // re-enable table
  admin.enableTable(tableName);
  table.close();
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:47,代码来源:TestRestoreSnapshotFromClient.java

示例13: testRestoreSchemaChange

import org.apache.hadoop.hbase.snapshot.SnapshotTestingUtils; //导入方法依赖的package包/类
@Test
public void testRestoreSchemaChange() throws Exception {
  byte[] TEST_FAMILY2 = Bytes.toBytes("cf2");

  HTable table = new HTable(TEST_UTIL.getConfiguration(), tableName);

  // Add one column family and put some data in it
  admin.disableTable(tableName);
  admin.addColumn(tableName, new HColumnDescriptor(TEST_FAMILY2));
  admin.enableTable(tableName);
  assertEquals(2, table.getTableDescriptor().getFamilies().size());
  HTableDescriptor htd = admin.getTableDescriptor(tableName);
  assertEquals(2, htd.getFamilies().size());
  SnapshotTestingUtils.loadData(TEST_UTIL, table, 500, TEST_FAMILY2);
  long snapshot2Rows = snapshot1Rows + 500;
  assertEquals(snapshot2Rows, TEST_UTIL.countRows(table));
  assertEquals(500, TEST_UTIL.countRows(table, TEST_FAMILY2));
  Set<String> fsFamilies = getFamiliesFromFS(tableName);
  assertEquals(2, fsFamilies.size());
  table.close();

  // Take a snapshot
  admin.disableTable(tableName);
  admin.snapshot(snapshotName2, tableName);

  // Restore the snapshot (without the cf)
  admin.restoreSnapshot(snapshotName0);
  assertEquals(1, table.getTableDescriptor().getFamilies().size());
  admin.enableTable(tableName);
  try {
    TEST_UTIL.countRows(table, TEST_FAMILY2);
    fail("family '" + Bytes.toString(TEST_FAMILY2) + "' should not exists");
  } catch (NoSuchColumnFamilyException e) {
    // expected
  }
  assertEquals(snapshot0Rows, TEST_UTIL.countRows(table));
  htd = admin.getTableDescriptor(tableName);
  assertEquals(1, htd.getFamilies().size());
  fsFamilies = getFamiliesFromFS(tableName);
  assertEquals(1, fsFamilies.size());
  table.close();

  // Restore back the snapshot (with the cf)
  admin.disableTable(tableName);
  admin.restoreSnapshot(snapshotName2);
  admin.enableTable(tableName);
  htd = admin.getTableDescriptor(tableName);
  assertEquals(2, htd.getFamilies().size());
  assertEquals(2, table.getTableDescriptor().getFamilies().size());
  assertEquals(500, TEST_UTIL.countRows(table, TEST_FAMILY2));
  assertEquals(snapshot2Rows, TEST_UTIL.countRows(table));
  fsFamilies = getFamiliesFromFS(tableName);
  assertEquals(2, fsFamilies.size());
  table.close();
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:56,代码来源:TestRestoreSnapshotFromClient.java

示例14: setup

import org.apache.hadoop.hbase.snapshot.SnapshotTestingUtils; //导入方法依赖的package包/类
/**
 * Initialize the tests with a table filled with some data
 * and two snapshots (snapshotName0, snapshotName1) of different states.
 * The tableName, snapshotNames and the number of rows in the snapshot are initialized.
 */
@Before
public void setup() throws Exception {
  this.admin = TEST_UTIL.getHBaseAdmin();

  long tid = System.currentTimeMillis();
  tableName = Bytes.toBytes("testtb-" + tid);
  emptySnapshot = Bytes.toBytes("emptySnaptb-" + tid);
  snapshotName0 = Bytes.toBytes("snaptb0-" + tid);
  snapshotName1 = Bytes.toBytes("snaptb1-" + tid);
  snapshotName2 = Bytes.toBytes("snaptb2-" + tid);

  // create Table and disable it
  SnapshotTestingUtils.createTable(TEST_UTIL, tableName, FAMILY);
  admin.disableTable(tableName);

  // take an empty snapshot
  admin.snapshot(emptySnapshot, tableName);

  HTable table = new HTable(TEST_UTIL.getConfiguration(), tableName);
  try {
    // enable table and insert data
    admin.enableTable(tableName);
    SnapshotTestingUtils.loadData(TEST_UTIL, table, 500, FAMILY);
    snapshot0Rows = TEST_UTIL.countRows(table);
    admin.disableTable(tableName);

    // take a snapshot
    admin.snapshot(snapshotName0, tableName);

    // enable table and insert more data
    admin.enableTable(tableName);
    SnapshotTestingUtils.loadData(TEST_UTIL, table, 500, FAMILY);
    snapshot1Rows = TEST_UTIL.countRows(table);
    admin.disableTable(tableName);

    // take a snapshot of the updated table
    admin.snapshot(snapshotName1, tableName);

    // re-enable table
    admin.enableTable(tableName);
  } finally {
    table.close();
  }
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:50,代码来源:TestCloneSnapshotFromClient.java

示例15: testRestoreSchemaChange

import org.apache.hadoop.hbase.snapshot.SnapshotTestingUtils; //导入方法依赖的package包/类
@Test
public void testRestoreSchemaChange() throws Exception {
  byte[] TEST_FAMILY2 = Bytes.toBytes("cf2");

  HTable table = new HTable(TEST_UTIL.getConfiguration(), tableName);

  // Add one column family and put some data in it
  admin.disableTable(tableName);
  admin.addColumn(tableName, new HColumnDescriptor(TEST_FAMILY2));
  admin.enableTable(tableName);
  assertEquals(2, table.getTableDescriptor().getFamilies().size());
  HTableDescriptor htd = admin.getTableDescriptor(tableName);
  assertEquals(2, htd.getFamilies().size());
  SnapshotTestingUtils.loadData(TEST_UTIL, table, 500, TEST_FAMILY2);
  long snapshot2Rows = snapshot1Rows + 500;
  assertEquals(snapshot2Rows, TEST_UTIL.countRows(table));
  assertEquals(500, TEST_UTIL.countRows(table, TEST_FAMILY2));
  Set<String> fsFamilies = getFamiliesFromFS(tableName);
  assertEquals(2, fsFamilies.size());
  table.close();

  // Take a snapshot
  admin.disableTable(tableName);
  admin.snapshot(snapshotName2, tableName);

  // Restore the snapshot (without the cf)
  admin.restoreSnapshot(snapshotName0);
  admin.enableTable(tableName);
  assertEquals(1, table.getTableDescriptor().getFamilies().size());
  try {
    TEST_UTIL.countRows(table, TEST_FAMILY2);
    fail("family '" + Bytes.toString(TEST_FAMILY2) + "' should not exists");
  } catch (NoSuchColumnFamilyException e) {
    // expected
  }
  assertEquals(snapshot0Rows, TEST_UTIL.countRows(table));
  htd = admin.getTableDescriptor(tableName);
  assertEquals(1, htd.getFamilies().size());
  fsFamilies = getFamiliesFromFS(tableName);
  assertEquals(1, fsFamilies.size());
  table.close();

  // Restore back the snapshot (with the cf)
  admin.disableTable(tableName);
  admin.restoreSnapshot(snapshotName2);
  admin.enableTable(tableName);
  htd = admin.getTableDescriptor(tableName);
  assertEquals(2, htd.getFamilies().size());
  assertEquals(2, table.getTableDescriptor().getFamilies().size());
  assertEquals(500, TEST_UTIL.countRows(table, TEST_FAMILY2));
  assertEquals(snapshot2Rows, TEST_UTIL.countRows(table));
  fsFamilies = getFamiliesFromFS(tableName);
  assertEquals(2, fsFamilies.size());
  table.close();
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:56,代码来源:TestRestoreSnapshotFromClient.java


注:本文中的org.apache.hadoop.hbase.snapshot.SnapshotTestingUtils.loadData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。