Search in sources :

Example 1 with VerifyReplication

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());
}
Also used : TokenIdentifier(org.apache.hadoop.security.token.TokenIdentifier) AuthenticationTokenIdentifier(org.apache.hadoop.hbase.security.token.AuthenticationTokenIdentifier) Configuration(org.apache.hadoop.conf.Configuration) AuthenticationTokenIdentifier(org.apache.hadoop.hbase.security.token.AuthenticationTokenIdentifier) VerifyReplication(org.apache.hadoop.hbase.mapreduce.replication.VerifyReplication) Token(org.apache.hadoop.security.token.Token) Text(org.apache.hadoop.io.Text) Job(org.apache.hadoop.mapreduce.Job) Credentials(org.apache.hadoop.security.Credentials) Test(org.junit.Test)

Example 2 with VerifyReplication

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());
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) VerifyReplication(org.apache.hadoop.hbase.mapreduce.replication.VerifyReplication) Job(org.apache.hadoop.mapreduce.Job)

Example 3 with VerifyReplication

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());
}
Also used : Path(org.apache.hadoop.fs.Path) Configuration(org.apache.hadoop.conf.Configuration) HBaseConfiguration(org.apache.hadoop.hbase.HBaseConfiguration) FileSystem(org.apache.hadoop.fs.FileSystem) VerifyReplication(org.apache.hadoop.hbase.mapreduce.replication.VerifyReplication) Job(org.apache.hadoop.mapreduce.Job) Test(org.junit.Test)

Aggregations

Configuration (org.apache.hadoop.conf.Configuration)3 VerifyReplication (org.apache.hadoop.hbase.mapreduce.replication.VerifyReplication)3 Job (org.apache.hadoop.mapreduce.Job)3 Test (org.junit.Test)2 FileSystem (org.apache.hadoop.fs.FileSystem)1 Path (org.apache.hadoop.fs.Path)1 HBaseConfiguration (org.apache.hadoop.hbase.HBaseConfiguration)1 AuthenticationTokenIdentifier (org.apache.hadoop.hbase.security.token.AuthenticationTokenIdentifier)1 Text (org.apache.hadoop.io.Text)1 Credentials (org.apache.hadoop.security.Credentials)1 Token (org.apache.hadoop.security.token.Token)1 TokenIdentifier (org.apache.hadoop.security.token.TokenIdentifier)1