本文整理了Java中org.apache.hadoop.hbase.client.Admin.cloneSnapshot()
方法的一些代码示例,展示了Admin.cloneSnapshot()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Admin.cloneSnapshot()
方法的具体详情如下:
包路径:org.apache.hadoop.hbase.client.Admin
类名称:Admin
方法名:cloneSnapshot
[英]Create a new table by cloning the snapshot content.
[中]通过克隆快照内容创建新表。
代码示例来源:origin: apache/hbase
@Test(expected=SnapshotDoesNotExistException.class)
public void testCloneNonExistentSnapshot() throws IOException, InterruptedException {
String snapshotName = "random-snapshot-" + System.currentTimeMillis();
TableName tableName = TableName.valueOf("random-table-" + System.currentTimeMillis());
admin.cloneSnapshot(snapshotName, tableName);
}
代码示例来源:origin: apache/hbase
@Test(expected = SnapshotDoesNotExistException.class)
public void testCloneNonExistentSnapshot() throws IOException, InterruptedException {
String snapshotName = "random-snapshot-" + System.currentTimeMillis();
final TableName tableName =
TableName.valueOf(getValidMethodName() + "-" + System.currentTimeMillis());
admin.cloneSnapshot(snapshotName, tableName);
}
代码示例来源:origin: apache/hbase
@Test(expected = NamespaceNotFoundException.class)
public void testCloneOnMissingNamespace() throws IOException, InterruptedException {
final TableName clonedTableName = TableName.valueOf("unknownNS:" + getValidMethodName());
admin.cloneSnapshot(snapshotName1, clonedTableName);
}
}
代码示例来源:origin: apache/hbase
public void cloneAndAssertOneRetry(final String snapshotName, final TableName tableName)
throws Exception {
MasterSyncObserver observer = getMasterSyncObserver();
observer.cloneCount = new AtomicInteger(0);
TEST_UTIL.getAdmin().cloneSnapshot(snapshotName, tableName);
assertEquals(1, observer.cloneCount.get());
}
代码示例来源:origin: apache/hbase
@Test
public void testRestoreSnapshotOfCloned() throws IOException, InterruptedException {
TableName clonedTableName = TableName.valueOf("clonedtb-" + System.currentTimeMillis());
admin.cloneSnapshot(snapshotName0, clonedTableName);
verifyRowCount(UTIL, clonedTableName, snapshot0Rows);
admin.snapshot(Bytes.toString(snapshotName2), clonedTableName, SnapshotType.FLUSH);
UTIL.deleteTable(clonedTableName);
admin.cloneSnapshot(snapshotName2, clonedTableName);
verifyRowCount(UTIL, clonedTableName, snapshot0Rows);
UTIL.deleteTable(clonedTableName);
}
代码示例来源:origin: apache/hbase
private void testCloneSnapshot(final TableName tableName, final byte[] snapshotName,
int snapshotRows) throws IOException, InterruptedException {
// create a new table from snapshot
admin.cloneSnapshot(snapshotName, tableName);
verifyRowCount(UTIL, tableName, snapshotRows);
UTIL.deleteTable(tableName);
}
代码示例来源:origin: apache/hbase
private void testCloneSnapshot(TableName tableName, byte[] snapshotName, int snapshotRows)
throws IOException, InterruptedException {
// create a new table from snapshot
admin.cloneSnapshot(snapshotName, tableName);
verifyRowCount(TEST_UTIL, tableName, snapshotRows);
verifyReplicasCameOnline(tableName);
TEST_UTIL.deleteTable(tableName);
}
代码示例来源:origin: apache/hbase
@Test
public void testCloneSnapshot() throws Exception {
byte[] FAMILY = Bytes.toBytes("test");
String snapshotName = tableName.getNameAsString() + "_snap";
TableName clonedTableName = TableName.valueOf(tableName.getNameAsString() + "_clone");
// create base table
TEST_UTIL.createTable(tableName, FAMILY);
// create snapshot
admin.snapshot(snapshotName, tableName);
// clone
admin.cloneSnapshot(snapshotName, clonedTableName);
}
代码示例来源:origin: apache/hbase
@Test
public void testOnlineSnapshotAfterSplittingRegions() throws IOException, InterruptedException {
List<RegionInfo> regionInfos = admin.getRegions(tableName);
RegionReplicaUtil.removeNonDefaultRegions(regionInfos);
// Split a region
splitRegion(regionInfos.get(0));
// Take a online snapshot
admin.snapshot(snapshotName1, tableName);
// Clone the snapshot to another table
TableName clonedTableName =
TableName.valueOf(name.getMethodName() + "-" + System.currentTimeMillis());
admin.cloneSnapshot(snapshotName1, clonedTableName);
verifyRowCount(TEST_UTIL, clonedTableName, snapshot1Rows);
}
}
代码示例来源:origin: apache/hbase
@Test
public void testCorruptedSnapshot() throws IOException, InterruptedException {
SnapshotTestingUtils.corruptSnapshot(TEST_UTIL, Bytes.toString(snapshotName0));
TableName cloneName =
TableName.valueOf(getValidMethodName() + "-" + System.currentTimeMillis());
try {
admin.cloneSnapshot(snapshotName0, cloneName);
fail("Expected CorruptedSnapshotException, got succeeded cloneSnapshot()");
} catch (CorruptedSnapshotException e) {
// Got the expected corruption exception.
// check for no references of the cloned table.
assertFalse(admin.tableExists(cloneName));
} catch (Exception e) {
fail("Expected CorruptedSnapshotException got: " + e);
}
}
}
代码示例来源:origin: apache/hbase
@Test(expected = QuotaExceededException.class)
public void testCloneSnapshotQuotaExceed() throws Exception {
String nsp = prefix + "_testTableQuotaExceedWithCloneSnapshot";
NamespaceDescriptor nspDesc =
NamespaceDescriptor.create(nsp).addConfiguration(TableNamespaceManager.KEY_MAX_TABLES, "1")
.build();
ADMIN.createNamespace(nspDesc);
assertNotNull("Namespace descriptor found null.", ADMIN.getNamespaceDescriptor(nsp));
TableName tableName = TableName.valueOf(nsp + TableName.NAMESPACE_DELIM + "table1");
TableName cloneTableName = TableName.valueOf(nsp + TableName.NAMESPACE_DELIM + "table2");
HColumnDescriptor fam1 = new HColumnDescriptor("fam1");
HTableDescriptor tableDescOne = new HTableDescriptor(tableName);
tableDescOne.addFamily(fam1);
ADMIN.createTable(tableDescOne);
String snapshot = "snapshot_testTableQuotaExceedWithCloneSnapshot";
ADMIN.snapshot(snapshot, tableName);
ADMIN.cloneSnapshot(snapshot, cloneTableName);
ADMIN.deleteSnapshot(snapshot);
}
代码示例来源:origin: apache/hbase
/**
* Takes the snapshot of originalTable and clones the snapshot to another tables.
* If {@code online} is false, the original table is disabled during taking snapshot, so also
* enables it again.
* @param online - Whether the table is online or not during the snapshot
*/
private void createAndCloneSnapshot(boolean online) throws Exception {
SnapshotTestingUtils.createSnapshotAndValidate(admin, originalTableName, TEST_FAM_STR,
snapshotNameAsString, rootDir, fs, online);
// If offline, enable the table disabled by snapshot testing util.
if (!online) {
admin.enableTable(originalTableName);
UTIL.waitTableAvailable(originalTableName);
}
admin.cloneSnapshot(snapshotName, cloneTableName);
UTIL.waitUntilAllRegionsAssigned(cloneTableName);
}
代码示例来源:origin: apache/hbase
@Test
public void testCloneSnapshotOfCloned() throws IOException, InterruptedException {
TableName clonedTableName =
TableName.valueOf(getValidMethodName() + "-" + System.currentTimeMillis());
admin.cloneSnapshot(snapshotName0, clonedTableName);
verifyRowCount(TEST_UTIL, clonedTableName, snapshot0Rows);
SnapshotTestingUtils.verifyReplicasCameOnline(clonedTableName, admin, getNumReplicas());
admin.disableTable(clonedTableName);
admin.snapshot(snapshotName2, clonedTableName);
TEST_UTIL.deleteTable(clonedTableName);
waitCleanerRun();
admin.cloneSnapshot(snapshotName2, clonedTableName);
verifyRowCount(TEST_UTIL, clonedTableName, snapshot0Rows);
SnapshotTestingUtils.verifyReplicasCameOnline(clonedTableName, admin, getNumReplicas());
TEST_UTIL.deleteTable(clonedTableName);
}
代码示例来源:origin: apache/hbase
admin.cloneSnapshot(snapshotName2, clonedTableName);
SnapshotTestingUtils.waitForTableToBeOnline(TEST_UTIL, clonedTableName);
代码示例来源:origin: apache/hbase
@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);
}
}
代码示例来源:origin: apache/hbase
admin.cloneSnapshot(snapshotBeforeMergeName, cloneBeforeMergeName);
SnapshotTestingUtils.waitForTableToBeOnline(UTIL, cloneBeforeMergeName);
admin.cloneSnapshot(snapshotBeforeMergeName, cloneAfterMergeName);
SnapshotTestingUtils.waitForTableToBeOnline(UTIL, cloneAfterMergeName);
代码示例来源:origin: apache/hbase
admin.cloneSnapshot(snapshotName, cloneName);
SnapshotTestingUtils.waitForTableToBeOnline(UTIL, cloneName);
代码示例来源:origin: apache/hbase
familiesList, snapshotNameAsString, rootDir, fs, /* onlineSnapshot= */ false);
admin.cloneSnapshot(snapshotName, clonedTableName);
Table clonedTable = UTIL.getConnection().getTable(clonedTableName);
HTableDescriptor cloneHtd = admin.getTableDescriptor(clonedTableName);
代码示例来源:origin: apache/hbase
String snapshot = "snapshot_testCloneSnapshot";
ADMIN.snapshot(snapshot, tableName);
ADMIN.cloneSnapshot(snapshot, cloneTableName);
代码示例来源:origin: apache/hbase
@Test
public void testCloneAndRestoreSnapshot() throws IOException, InterruptedException {
TEST_UTIL.deleteTable(tableName);
waitCleanerRun();
admin.cloneSnapshot(snapshotName0, tableName);
verifyRowCount(TEST_UTIL, tableName, snapshot0Rows);
SnapshotTestingUtils.verifyReplicasCameOnline(tableName, admin, getNumReplicas());
waitCleanerRun();
admin.disableTable(tableName);
admin.restoreSnapshot(snapshotName0);
admin.enableTable(tableName);
verifyRowCount(TEST_UTIL, tableName, snapshot0Rows);
SnapshotTestingUtils.verifyReplicasCameOnline(tableName, admin, getNumReplicas());
}
内容来源于网络,如有侵权,请联系作者删除!