Package org.apache.hcatalog.hbase.snapshot

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


            // 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

        @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

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

            }
        }

        @Override
        public void commitJob(JobContext jobContext) throws IOException {
            RevisionManager rm = null;
            try {
                rm = HBaseRevisionManagerUtil
                        .getOpenedRevisionManager(jobContext.getConfiguration());
                rm.commitWriteTransaction(HBaseRevisionManagerUtil.getWriteTransaction(jobContext
                        .getConfiguration()));
            } finally {
                if (rm != null)
                    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

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.