Package org.apache.hcatalog.hbase.snapshot

Examples of org.apache.hcatalog.hbase.snapshot.RevisionManager


    HBaseAdmin hAdmin = new HBaseAdmin(getHbaseConf());
    boolean doesTableExist = hAdmin.tableExists("CaseSensitiveTable");

    assertTrue(doesTableExist);

    RevisionManager rm = HBaseRevisionManagerUtil.getOpenedRevisionManager(hcatConf);
    rm.open();
    //Should be able to successfully query revision manager
    rm.getAbortedWriteTransactions("CaseSensitiveTable", "cf1");

    hcatDriver.run("drop table test_table");
    doesTableExist = hAdmin.tableExists("CaseSensitiveTable");
    assertTrue(doesTableExist == false);

    try {
      rm.getAbortedWriteTransactions("CaseSensitiveTable", "cf1");
    } catch (Exception e) {
      assertTrue(e.getCause() instanceof NoNodeException);
    }
    rm.close();

  }
View Full Code Here


        job.setOutputFormat(HBaseBulkOutputFormat.class);
        org.apache.hadoop.mapred.SequenceFileOutputFormat.setOutputPath(job, interPath);
        job.setOutputCommitter(HBaseBulkOutputCommitter.class);

        //manually create transaction
        RevisionManager rm = HBaseRevisionManagerUtil.getOpenedRevisionManager(conf);
        try {
            OutputJobInfo outputJobInfo = OutputJobInfo.create("default", tableName, null);
            Transaction txn = rm.beginWriteTransaction(tableName, Arrays.asList(familyName));
            outputJobInfo.getProperties().setProperty(HBaseConstants.PROPERTY_WRITE_TXN_KEY,
                HCatUtil.serialize(txn));
            job.set(HCatConstants.HCAT_KEY_OUTPUT_INFO,
                HCatUtil.serialize(outputJobInfo));
        } finally {
            rm.close();
        }

        job.setMapOutputKeyClass(ImmutableBytesWritable.class);
        job.setMapOutputValueClass(HCatRecord.class);
View Full Code Here

        job.setOutputValueClass(HCatRecord.class);

        job.setNumReduceTasks(0);

        assertTrue(job.waitForCompletion(true));
        RevisionManager rm = HBaseRevisionManagerUtil.getOpenedRevisionManager(conf);
        try {
            TableSnapshot snapshot = rm.createSnapshot(databaseName + "." + tableName);
            for (String el : snapshot.getColumnFamilies()) {
                assertEquals(1, snapshot.getRevision(el));
            }
        } finally {
            rm.close();
        }

        //verify
        HTable table = new HTable(conf, databaseName + "." + tableName);
        Scan scan = new Scan();
View Full Code Here

            conf, workingDir, MapWriteAbortTransaction.class,
            outputJobInfo, inputPath);
        assertFalse(job.waitForCompletion(true));

        // verify that revision manager has it as aborted transaction
        RevisionManager rm = HBaseRevisionManagerUtil.getOpenedRevisionManager(conf);
        try {
            TableSnapshot snapshot = rm.createSnapshot(databaseName + "." + tableName);
            for (String family : snapshot.getColumnFamilies()) {
                assertEquals(1, snapshot.getRevision(family));
                List<FamilyRevision> abortedWriteTransactions = rm.getAbortedWriteTransactions(
                    databaseName + "." + tableName, family);
                assertEquals(1, abortedWriteTransactions.size());
                assertEquals(1, abortedWriteTransactions.get(0).getRevision());
            }
        } finally {
            rm.close();
        }

        //verify that hbase does not have any of the records.
        //Since records are only written during commitJob,
        //hbase should not have any records.
View Full Code Here

        @Override
        public void abortJob(JobContext jobContext, int status)
            throws IOException {
            baseOutputCommitter.abortJob(jobContext, status);
            RevisionManager rm = null;
            try {
                rm = HBaseRevisionManagerUtil
                    .getOpenedRevisionManager(jobContext.getConfiguration());
                rm.abortWriteTransaction(HBaseRevisionManagerUtil
                    .getWriteTransaction(jobContext.getConfiguration()));
            } finally {
                cleanIntermediate(jobContext);
                if (rm != null)
                    rm.close();
            }
        }
View Full Code Here

        }

        @Override
        public void commitJob(JobContext jobContext) throws IOException {
            baseOutputCommitter.commitJob(jobContext);
            RevisionManager rm = null;
            try {
                Configuration conf = jobContext.getConfiguration();
                Path srcPath = FileOutputFormat.getOutputPath(jobContext.getJobConf());
                if (!FileSystem.get(conf).exists(srcPath)) {
                    throw new IOException("Failed to bulk import hfiles. " +
                        "Intermediate data directory is cleaned up or missing. " +
                        "Please look at the bulk import job if it exists for failure reason");
                }
                Path destPath = new Path(srcPath.getParent(), srcPath.getName() + "_hfiles");
                boolean success = ImportSequenceFile.runJob(jobContext,
                    conf.get(HBaseConstants.PROPERTY_OUTPUT_TABLE_NAME_KEY),
                    srcPath,
                    destPath);
                if (!success) {
                    cleanIntermediate(jobContext);
                    throw new IOException("Failed to bulk import hfiles." +
                        " Please look at the bulk import job for failure reason");
                }
                rm = HBaseRevisionManagerUtil.getOpenedRevisionManager(conf);
                rm.commitWriteTransaction(HBaseRevisionManagerUtil.getWriteTransaction(conf));
                cleanIntermediate(jobContext);
            } finally {
                if (rm != null)
                    rm.close();
            }
        }
View Full Code Here

TOP

Related Classes of org.apache.hcatalog.hbase.snapshot.RevisionManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.