Package org.apache.hcatalog.hbase.snapshot

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


    @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

    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

    job.setOutputFormat(HBaseDirectOutputFormat.class);
    job.set(TableOutputFormat.OUTPUT_TABLE, tableName);
    job.set(HBaseConstants.PROPERTY_OUTPUT_TABLE_NAME_KEY, tableName);

    //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(BytesWritable.class);
    job.setMapOutputValueClass(HCatRecord.class);
    job.setOutputKeyClass(BytesWritable.class);
View Full Code Here

      tableName, null);
    Job job = configureJob(testName, conf, workingDir, MapHCatWrite.class,
      outputJobInfo, inputPath);
    assertTrue(job.waitForCompletion(true));

    RevisionManager rm = HBaseRevisionManagerUtil.getOpenedRevisionManager(conf);
    try {
      TableSnapshot snapshot = rm.createSnapshot(hbaseTableName);
      for (String el : snapshot.getColumnFamilies()) {
        assertEquals(1, snapshot.getRevision(el));
      }
    } finally {
      rm.close();
    }

    //verify
    HTable table = new HTable(conf, hbaseTableName);
    Scan scan = new Scan();
View Full Code Here

    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

        job.setOutputFormat(HBaseDirectOutputFormat.class);
        job.set(TableOutputFormat.OUTPUT_TABLE, tableName);
        job.set(HBaseConstants.PROPERTY_OUTPUT_TABLE_NAME_KEY, tableName);

        //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(BytesWritable.class);
        job.setMapOutputValueClass(HCatRecord.class);
        job.setOutputKeyClass(BytesWritable.class);
View Full Code Here

            tableName, null);
        Job job = configureJob(testName, conf, workingDir, MapHCatWrite.class,
            outputJobInfo, inputPath);
        assertTrue(job.waitForCompletion(true));

        RevisionManager rm = HBaseRevisionManagerUtil.getOpenedRevisionManager(conf);
        try {
            TableSnapshot snapshot = rm.createSnapshot(hbaseTableName);
            for (String el : snapshot.getColumnFamilies()) {
                assertEquals(1, snapshot.getRevision(el));
            }
        } finally {
            rm.close();
        }

        //verify
        HTable table = new HTable(conf, hbaseTableName);
        Scan scan = new Scan();
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.