Package org.apache.hcatalog.hbase.snapshot

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


        Job job = configureJob(testName, 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(hbaseTableName);
            for (String family : snapshot.getColumnFamilies()) {
                assertEquals(1, snapshot.getRevision(family));
                List<FamilyRevision> abortedWriteTransactions = rm.getAbortedWriteTransactions(
                    hbaseTableName, family);
                assertEquals(1, abortedWriteTransactions.size());
                assertEquals(1, abortedWriteTransactions.get(0).getRevision());
            }
        } finally {
            rm.close();
        }

        // verify that hbase has the records of the successful maps.
        HTable table = new HTable(conf, hbaseTableName);
        Scan scan = new Scan();
View Full Code Here


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

        assertTrue(doesTableExist);

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

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

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

    }
View Full Code Here

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

        assertTrue(doesTableExist);

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

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

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

    }
View Full Code Here

        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

        resultItr = this.scanner.iterator();
    }

    private Set<Long> getAbortedTransactions(String tableName, Scan scan) throws IOException {
        Set<Long> abortedTransactions = new HashSet<Long>();
        RevisionManager rm = null;
        try {
            rm = HBaseRevisionManagerUtil.getOpenedRevisionManager(conf);
            byte[][] families = scan.getFamilies();
            for (byte[] familyKey : families) {
                String family = Bytes.toString(familyKey);
                List<FamilyRevision> abortedWriteTransactions = rm.getAbortedWriteTransactions(
                    tableName, family);
                if (abortedWriteTransactions != null) {
                    for (FamilyRevision revision : abortedWriteTransactions) {
                        abortedTransactions.add(revision.getRevision());
                    }
View Full Code Here

     * @throws IOException Signals that an I/O exception has occurred.
     */
    static HCatTableSnapshot createSnapshot(Configuration jobConf,
                                            String hbaseTableName, HCatTableInfo tableInfo) throws IOException {

        RevisionManager rm = null;
        TableSnapshot snpt;
        try {
            rm = getOpenedRevisionManager(jobConf);
            snpt = rm.createSnapshot(hbaseTableName);
        } finally {
            closeRevisionManagerQuietly(rm);
        }

        HCatTableSnapshot hcatSnapshot = HBaseRevisionManagerUtil.convertSnapshot(snpt, tableInfo);
View Full Code Here

    static HCatTableSnapshot createSnapshot(Configuration jobConf,
                                            String tableName, long revision)
        throws IOException {

        TableSnapshot snpt;
        RevisionManager rm = null;
        try {
            rm = getOpenedRevisionManager(jobConf);
            snpt = rm.createSnapshot(tableName, revision);
        } finally {
            closeRevisionManagerQuietly(rm);
        }

        String inputJobString = jobConf.get(HCatConstants.HCAT_KEY_JOB_INFO);
View Full Code Here

     * @throws IOException
     */
    static Transaction beginWriteTransaction(String qualifiedTableName,
                                             HCatTableInfo tableInfo, Configuration jobConf) throws IOException {
        Transaction txn;
        RevisionManager rm = null;
        try {
            rm = HBaseRevisionManagerUtil.getOpenedRevisionManager(jobConf);
            String hBaseColumns = tableInfo.getStorerInfo().getProperties()
                .getProperty(HBaseSerDe.HBASE_COLUMNS_MAPPING);
            String[] splits = hBaseColumns.split("[,:]");
            Set<String> families = new HashSet<String>();
            for (int i = 0; i < splits.length; i += 2) {
                if (!splits[i].isEmpty())
                    families.add(splits[i]);
            }
            txn = rm.beginWriteTransaction(qualifiedTableName, new ArrayList<String>(families));
        } finally {
            HBaseRevisionManagerUtil.closeRevisionManagerQuietly(rm);
        }
        return txn;
    }
View Full Code Here

            // ensure the table is online
            new HTable(hbaseConf, tableDesc.getName());

            //Set up table in revision manager.
            RevisionManager rm = HBaseRevisionManagerUtil.getOpenedRevisionManager(hbaseConf);
            rm.createTable(tableName, new ArrayList<String>(uniqueColumnFamilies));

        } catch (MasterNotRunningException mnre) {
            throw new MetaException(StringUtils.stringifyException(mnre));
        } catch (IOException ie) {
            throw new MetaException(StringUtils.stringifyException(ie));
View Full Code Here

    }

    private void checkDeleteTable(Table table) throws MetaException {
        boolean isExternal = MetaStoreUtils.isExternalTable(table);
        String tableName = getFullyQualifiedHBaseTableName(table);
        RevisionManager rm = null;
        try {
            if (!isExternal && getHBaseAdmin().tableExists(tableName)) {
                // we have created an HBase table, so we delete it to roll back;
                if (getHBaseAdmin().isTableEnabled(tableName)) {
                    getHBaseAdmin().disableTable(tableName);
                }
                getHBaseAdmin().deleteTable(tableName);

                //Drop table in revision manager.
                rm = HBaseRevisionManagerUtil.getOpenedRevisionManager(hbaseConf);
                rm.dropTable(tableName);
            }
        } catch (IOException ie) {
            throw new MetaException(StringUtils.stringifyException(ie));
        } finally {
            HBaseRevisionManagerUtil.closeRevisionManagerQuietly(rm);
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.