Search in sources :

Example 21 with URIHandler

use of org.apache.oozie.dependency.URIHandler in project oozie by apache.

the class TestFsActionExecutor method testDeleteHcatTable.

public void testDeleteHcatTable() throws Exception {
    createTestTable();
    URI hcatURI = getHCatURI(db, table);
    URIHandler handler = uriService.getURIHandler(hcatURI);
    FsActionExecutor ae = new FsActionExecutor();
    Path path = new Path(hcatURI);
    Path nameNodePath = new Path(getNameNodeUri());
    Context context = createContext("<fs/>");
    XConfiguration conf = new XConfiguration();
    assertTrue(handler.exists(hcatURI, conf, getTestUser()));
    ae.delete(context, conf, nameNodePath, path, true);
    assertFalse(handler.exists(hcatURI, conf, getTestUser()));
}
Also used : Path(org.apache.hadoop.fs.Path) XConfiguration(org.apache.oozie.util.XConfiguration) HCatURIHandler(org.apache.oozie.dependency.HCatURIHandler) URIHandler(org.apache.oozie.dependency.URIHandler) FSURIHandler(org.apache.oozie.dependency.FSURIHandler) URI(java.net.URI)

Example 22 with URIHandler

use of org.apache.oozie.dependency.URIHandler in project oozie by apache.

the class TestCoordRerunXCommand method testCoordRerunCleanupForHCat.

/**
 * Test : rerun with refresh option when input dependency is hcat partition
 *
 * @throws Exception
 */
public void testCoordRerunCleanupForHCat() throws Exception {
    // setting current user as test user because directory structure created by HCat have current user permissions (755).
    setSystemProperty(XTestCase.TEST_USER1_PROP, System.getProperty("user.name"));
    super.setupHCatalogServer();
    services = super.setupServicesForHCatalog();
    services.init();
    final String jobId = "0000000-" + new Date().getTime() + "-testCoordRerun-C";
    final int actionNum = 1;
    final String actionId = jobId + "@" + actionNum;
    try {
        addRecordToJobTable(jobId, CoordinatorJob.Status.SUCCEEDED);
        addRecordToActionTable(jobId, actionNum, actionId, CoordinatorAction.Status.SUCCEEDED, "coord-rerun-action1.xml", true);
    } catch (Exception e) {
        e.printStackTrace();
        fail("Could not update db.");
    }
    String db = "mydb";
    String table = "mytable";
    String server = getHCatalogServer().getMetastoreAuthority();
    String newHCatDependency = "hcat://" + server + "/" + db + "/" + table + "/ds=2009121411;region=usa";
    dropTable(db, table, true);
    dropDatabase(db, true);
    createDatabase(db);
    createTable(db, table, "ds,region");
    addPartition(db, table, "ds=2009121411;region=usa");
    // before cleanup
    Configuration conf = new Configuration();
    URIHandler handler = services.get(URIHandlerService.class).getURIHandler(newHCatDependency);
    assertTrue(handler.exists(new URI(newHCatDependency), conf, getTestUser()));
    final OozieClient coordClient = LocalOozie.getCoordClient();
    coordClient.reRunCoord(jobId, RestConstants.JOB_COORD_SCOPE_ACTION, Integer.toString(actionNum), false, false);
    CoordinatorActionBean action2 = CoordActionQueryExecutor.getInstance().get(CoordActionQuery.GET_COORD_ACTION, actionId);
    assertNotSame(action2.getStatus(), CoordinatorAction.Status.SUCCEEDED);
    waitFor(120 * 1000, new Predicate() {

        @Override
        public boolean evaluate() throws Exception {
            CoordinatorAction bean = coordClient.getCoordActionInfo(actionId);
            return (bean.getStatus() == CoordinatorAction.Status.WAITING || bean.getStatus() == CoordinatorAction.Status.READY);
        }
    });
    // after cleanup
    assertFalse(handler.exists(new URI(newHCatDependency), conf, getTestUser()));
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) XConfiguration(org.apache.oozie.util.XConfiguration) CoordinatorActionBean(org.apache.oozie.CoordinatorActionBean) URI(java.net.URI) Date(java.util.Date) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) JDOMException(org.jdom.JDOMException) CommandException(org.apache.oozie.command.CommandException) StoreException(org.apache.oozie.store.StoreException) IOException(java.io.IOException) URIHandlerService(org.apache.oozie.service.URIHandlerService) URIHandler(org.apache.oozie.dependency.URIHandler)

Aggregations

URIHandler (org.apache.oozie.dependency.URIHandler)22 URI (java.net.URI)15 URIHandlerService (org.apache.oozie.service.URIHandlerService)13 FSURIHandler (org.apache.oozie.dependency.FSURIHandler)9 IOException (java.io.IOException)5 CommandException (org.apache.oozie.command.CommandException)5 Configuration (org.apache.hadoop.conf.Configuration)4 Path (org.apache.hadoop.fs.Path)4 LauncherURIHandler (org.apache.oozie.action.hadoop.LauncherURIHandler)4 HCatURIHandler (org.apache.oozie.dependency.HCatURIHandler)4 JPAExecutorException (org.apache.oozie.executor.jpa.JPAExecutorException)4 ELEvaluator (org.apache.oozie.util.ELEvaluator)4 Element (org.jdom.Element)4 PreconditionException (org.apache.oozie.command.PreconditionException)3 ElException (org.apache.oozie.coord.ElException)3 Context (org.apache.oozie.dependency.URIHandler.Context)3 XConfiguration (org.apache.oozie.util.XConfiguration)3 XLog (org.apache.oozie.util.XLog)3 URISyntaxException (java.net.URISyntaxException)2 Calendar (java.util.Calendar)2