use of org.apache.hadoop.hbase.mapreduce.replication.VerifyReplication in project hbase by apache.
the class TestVerifyReplicationSecureClusterCredentials method testJobCredentials.
@Test
@SuppressWarnings("unchecked")
public void testJobCredentials() throws Exception {
Job job = new VerifyReplication().createSubmittableJob(new Configuration(UTIL1.getConfiguration()), new String[] { peer.get(), "table" });
Credentials credentials = job.getCredentials();
Collection<Token<? extends TokenIdentifier>> tokens = credentials.getAllTokens();
assertEquals(2, tokens.size());
String clusterId1 = ZKClusterId.readClusterIdZNode(UTIL1.getZooKeeperWatcher());
Token<AuthenticationTokenIdentifier> tokenForCluster1 = (Token<AuthenticationTokenIdentifier>) credentials.getToken(new Text(clusterId1));
assertEquals(FULL_USER_PRINCIPAL, tokenForCluster1.decodeIdentifier().getUsername());
String clusterId2 = ZKClusterId.readClusterIdZNode(UTIL2.getZooKeeperWatcher());
Token<AuthenticationTokenIdentifier> tokenForCluster2 = (Token<AuthenticationTokenIdentifier>) credentials.getToken(new Text(clusterId2));
assertEquals(FULL_USER_PRINCIPAL, tokenForCluster2.decodeIdentifier().getUsername());
}
use of org.apache.hadoop.hbase.mapreduce.replication.VerifyReplication in project hbase by apache.
the class TestVerifyReplication method runVerifyReplication.
static void runVerifyReplication(String[] args, int expectedGoodRows, int expectedBadRows) throws IOException, InterruptedException, ClassNotFoundException {
Job job = new VerifyReplication().createSubmittableJob(new Configuration(CONF1), args);
if (job == null) {
fail("Job wasn't created, see the log");
}
if (!job.waitForCompletion(true)) {
fail("Job failed, see the log");
}
assertEquals(expectedGoodRows, job.getCounters().findCounter(VerifyReplication.Verifier.Counters.GOODROWS).getValue());
assertEquals(expectedBadRows, job.getCounters().findCounter(VerifyReplication.Verifier.Counters.BADROWS).getValue());
}
use of org.apache.hadoop.hbase.mapreduce.replication.VerifyReplication in project hbase by apache.
the class TestVerifyReplicationCrossDiffHdfs method testVerifyRepBySnapshot.
@Test
public void testVerifyRepBySnapshot() throws Exception {
Path rootDir = CommonFSUtils.getRootDir(conf1);
FileSystem fs = rootDir.getFileSystem(conf1);
String sourceSnapshotName = "sourceSnapshot-" + EnvironmentEdgeManager.currentTime();
SnapshotTestingUtils.createSnapshotAndValidate(util1.getAdmin(), TABLE_NAME, Bytes.toString(FAMILY), sourceSnapshotName, rootDir, fs, true);
// Take target snapshot
Path peerRootDir = CommonFSUtils.getRootDir(conf2);
FileSystem peerFs = peerRootDir.getFileSystem(conf2);
String peerSnapshotName = "peerSnapshot-" + EnvironmentEdgeManager.currentTime();
SnapshotTestingUtils.createSnapshotAndValidate(util2.getAdmin(), TABLE_NAME, Bytes.toString(FAMILY), peerSnapshotName, peerRootDir, peerFs, true);
String peerFSAddress = peerFs.getUri().toString();
String temPath1 = new Path(fs.getUri().toString(), "/tmp1").toString();
String temPath2 = "/tmp2";
String[] args = new String[] { "--sourceSnapshotName=" + sourceSnapshotName, "--sourceSnapshotTmpDir=" + temPath1, "--peerSnapshotName=" + peerSnapshotName, "--peerSnapshotTmpDir=" + temPath2, "--peerFSAddress=" + peerFSAddress, "--peerHBaseRootAddress=" + CommonFSUtils.getRootDir(conf2), PEER_ID, TABLE_NAME.toString() };
// Use the yarn's config override the source cluster's config.
Configuration newConf = HBaseConfiguration.create(conf1);
HBaseConfiguration.merge(newConf, mapReduceUtil.getConfiguration());
newConf.set(HConstants.ZOOKEEPER_ZNODE_PARENT, "/1");
CommonFSUtils.setRootDir(newConf, CommonFSUtils.getRootDir(conf1));
Job job = new VerifyReplication().createSubmittableJob(newConf, args);
if (job == null) {
fail("Job wasn't created, see the log");
}
if (!job.waitForCompletion(true)) {
fail("Job failed, see the log");
}
assertEquals(10, job.getCounters().findCounter(VerifyReplication.Verifier.Counters.GOODROWS).getValue());
assertEquals(0, job.getCounters().findCounter(VerifyReplication.Verifier.Counters.BADROWS).getValue());
}
Aggregations