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()));
}
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()));
}
Aggregations