Search in sources :

Example 11 with HCatAccessorService

use of org.apache.oozie.service.HCatAccessorService in project oozie by apache.

the class HCatCredentials method getProperty.

/**
 * Returns the value for the oozieConfName if its present in prop map else
 * value of hiveConfName. It will also check HCatAccessorService and
 * HiveConf for hiveConfName.
 *
 * @param prop
 * @param oozieConfName
 * @param hiveConfName
 * @return value for the oozieConfName if its present else value of
 *         hiveConfName. If both are absent then returns null.
 */
private String getProperty(HashMap<String, String> prop, String oozieConfName, String hiveConfName) {
    String value = prop.get(oozieConfName) == null ? prop.get(hiveConfName) : prop.get(oozieConfName);
    if (value == null || value.isEmpty()) {
        HCatAccessorService hCatService = Services.get().get(HCatAccessorService.class);
        Configuration hCatConf = hCatService.getHCatConf();
        if (hCatConf != null) {
            value = hCatConf.get(hiveConfName);
        }
    }
    if (value == null || value.isEmpty()) {
        value = hiveConf.get(hiveConfName);
    }
    return value;
}
Also used : HCatAccessorService(org.apache.oozie.service.HCatAccessorService) Configuration(org.apache.hadoop.conf.Configuration)

Example 12 with HCatAccessorService

use of org.apache.oozie.service.HCatAccessorService in project oozie by apache.

the class HCatURIHandler method getDependencyType.

@Override
public DependencyType getDependencyType(URI uri) throws URIHandlerException {
    DependencyType depType = DependencyType.PULL;
    // Not initializing in constructor as this will be part of oozie.services.ext
    // and will be initialized after URIHandlerService
    HCatAccessorService hcatService = Services.get().get(HCatAccessorService.class);
    if (hcatService != null) {
        depType = dependencyTypes.get(uri.getAuthority());
        if (depType == null) {
            depType = hcatService.isKnownPublisher(uri) ? DependencyType.PUSH : DependencyType.PULL;
            dependencyTypes.put(uri.getAuthority(), depType);
        }
    }
    return depType;
}
Also used : HCatAccessorService(org.apache.oozie.service.HCatAccessorService)

Example 13 with HCatAccessorService

use of org.apache.oozie.service.HCatAccessorService in project oozie by apache.

the class TestCoordPushDependencyCheckXCommand method testTimeOutWithUnresolvedMissingDependencies.

@Test
public void testTimeOutWithUnresolvedMissingDependencies() throws Exception {
    String db = "default";
    String table = "tablename";
    String newHCatDependency1 = "hcat://" + server + "/" + db + "/" + table + "/dt=20120430;country=brazil";
    String newHCatDependency2 = "hcat://" + server + "/" + db + "/" + table + "/dt=20120430;country=usa";
    String newHCatDependency3 = "hcat://" + server + "/" + db + "/" + table + "/dt=20120430;country=uk";
    String newHCatDependency = newHCatDependency1 + CoordELFunctions.INSTANCE_SEPARATOR + newHCatDependency2;
    populateTable(db, table);
    String actionId = addInitRecords(newHCatDependency);
    checkCoordAction(actionId, newHCatDependency, CoordinatorAction.Status.WAITING);
    new CoordPushDependencyCheckXCommand(actionId, true).call();
    checkCoordAction(actionId, newHCatDependency1, CoordinatorAction.Status.WAITING);
    PartitionDependencyManagerService pdms = Services.get().get(PartitionDependencyManagerService.class);
    HCatAccessorService hcatService = Services.get().get(HCatAccessorService.class);
    assertTrue(pdms.getWaitingActions(new HCatURI(newHCatDependency1)).contains(actionId));
    assertTrue(hcatService.isRegisteredForNotification(new HCatURI(newHCatDependency1)));
    // Timeout is 10 mins. Change action created time to before 12 min to make the action
    // timeout.
    long timeOutCreationTime = System.currentTimeMillis() - (12 * 60 * 1000);
    setCoordActionCreationTime(actionId, timeOutCreationTime);
    // Set some missing dependency. Instead of latest or future just setting a current one for testing as
    // we are only interested in ensuring CoordActionInputCheckXCommand is run
    setMissingDependencies(actionId, newHCatDependency + CoordELFunctions.INSTANCE_SEPARATOR + newHCatDependency3);
    addPartition(db, table, "dt=20120430;country=brazil");
    checkDependencies(actionId, newHCatDependency + CoordELFunctions.INSTANCE_SEPARATOR + newHCatDependency3, newHCatDependency1);
    new CoordPushDependencyCheckXCommand(actionId).call();
    // Somehow with hive 0.10 it takes 1 second more.
    Thread.sleep(1300);
    checkDependencies(actionId, newHCatDependency3, "");
    assertNull(pdms.getWaitingActions(new HCatURI(newHCatDependency1)));
    assertFalse(hcatService.isRegisteredForNotification(new HCatURI(newHCatDependency1)));
}
Also used : HCatAccessorService(org.apache.oozie.service.HCatAccessorService) HCatURI(org.apache.oozie.util.HCatURI) PartitionDependencyManagerService(org.apache.oozie.service.PartitionDependencyManagerService) Test(org.junit.Test)

Example 14 with HCatAccessorService

use of org.apache.oozie.service.HCatAccessorService in project oozie by apache.

the class TestCoordPushDependencyCheckXCommand method testTimeOut.

@Test
public void testTimeOut() throws Exception {
    String db = "default";
    String table = "tablename";
    String newHCatDependency1 = "hcat://" + server + "/" + db + "/" + table + "/dt=20120430;country=brazil";
    String newHCatDependency2 = "hcat://" + server + "/" + db + "/" + table + "/dt=20120430;country=usa";
    String newHCatDependency = newHCatDependency1 + CoordELFunctions.INSTANCE_SEPARATOR + newHCatDependency2;
    populateTable(db, table);
    String actionId = addInitRecords(newHCatDependency);
    checkCoordAction(actionId, newHCatDependency, CoordinatorAction.Status.WAITING);
    new CoordPushDependencyCheckXCommand(actionId, true).call();
    checkCoordAction(actionId, newHCatDependency1, CoordinatorAction.Status.WAITING);
    PartitionDependencyManagerService pdms = Services.get().get(PartitionDependencyManagerService.class);
    HCatAccessorService hcatService = Services.get().get(HCatAccessorService.class);
    assertTrue(pdms.getWaitingActions(new HCatURI(newHCatDependency1)).contains(actionId));
    assertTrue(hcatService.isRegisteredForNotification(new HCatURI(newHCatDependency1)));
    // Timeout is 10 mins. Change action created time to before 12 min to make the action
    // timeout.
    long timeOutCreationTime = System.currentTimeMillis() - (12 * 60 * 1000);
    setCoordActionCreationTime(actionId, timeOutCreationTime);
    new CoordPushDependencyCheckXCommand(actionId).call();
    Thread.sleep(100);
    // Check for timeout status and unregistered missing dependencies
    checkCoordAction(actionId, newHCatDependency1, CoordinatorAction.Status.TIMEDOUT);
    assertNull(pdms.getWaitingActions(new HCatURI(newHCatDependency1)));
    assertFalse(hcatService.isRegisteredForNotification(new HCatURI(newHCatDependency1)));
}
Also used : HCatAccessorService(org.apache.oozie.service.HCatAccessorService) HCatURI(org.apache.oozie.util.HCatURI) PartitionDependencyManagerService(org.apache.oozie.service.PartitionDependencyManagerService) Test(org.junit.Test)

Aggregations

HCatAccessorService (org.apache.oozie.service.HCatAccessorService)14 HCatURI (org.apache.oozie.util.HCatURI)8 PartitionDependencyManagerService (org.apache.oozie.service.PartitionDependencyManagerService)7 Test (org.junit.Test)6 Map (java.util.Map)4 Collection (java.util.Collection)3 HashMap (java.util.HashMap)3 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)3 ConcurrentMap (java.util.concurrent.ConcurrentMap)3 ArrayList (java.util.ArrayList)2 HCatMessageHandler (org.apache.oozie.dependency.hcat.HCatMessageHandler)2 JPAExecutorException (org.apache.oozie.executor.jpa.JPAExecutorException)2 URISyntaxException (java.net.URISyntaxException)1 HashSet (java.util.HashSet)1 Message (javax.jms.Message)1 MessageProducer (javax.jms.MessageProducer)1 Topic (javax.jms.Topic)1 Configuration (org.apache.hadoop.conf.Configuration)1 HiveConf (org.apache.hadoop.hive.conf.HiveConf)1 HCatClient (org.apache.hive.hcatalog.api.HCatClient)1