Exemplo n.º 1
0
 private String assertProcessIsRegistered(String queryStr) throws Exception {
   //        String dslQuery = String.format("%s where queryText = \"%s\"",
   // HiveDataTypes.HIVE_PROCESS.getName(),
   //                normalize(queryStr));
   //        assertEntityIsRegistered(dslQuery, true);
   // todo replace with DSL
   String typeName = HiveDataTypes.HIVE_PROCESS.getName();
   String gremlinQuery =
       String.format(
           "g.V.has('__typeName', '%s').has('%s.queryText', \"%s\").toList()",
           typeName, typeName, normalize(queryStr));
   return assertEntityIsRegistered(gremlinQuery);
 }
Exemplo n.º 2
0
  private Referenceable getProcessReferenceable(
      HiveMetaStoreBridge dgiBridge,
      HiveEventContext hiveEvent,
      SortedMap<Entity, Referenceable> source,
      SortedMap<Entity, Referenceable> target) {
    Referenceable processReferenceable = new Referenceable(HiveDataTypes.HIVE_PROCESS.getName());

    String queryStr = lower(hiveEvent.getQueryStr());
    processReferenceable.set(
        AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME,
        getProcessQualifiedName(hiveEvent.getOperation(), source, target));

    LOG.debug("Registering query: {}", queryStr);
    List<Referenceable> sourceList = new ArrayList<>(source.values());
    List<Referenceable> targetList = new ArrayList<>(target.values());

    // The serialization code expected a list
    if (sourceList != null && !sourceList.isEmpty()) {
      processReferenceable.set("inputs", sourceList);
    }
    if (targetList != null && !targetList.isEmpty()) {
      processReferenceable.set("outputs", targetList);
    }
    processReferenceable.set(AtlasClient.NAME, queryStr);

    processReferenceable.set("operationType", hiveEvent.getOperation().getOperationName());
    processReferenceable.set("startTime", new Date(hiveEvent.getQueryStartTime()));
    processReferenceable.set("userName", hiveEvent.getUser());
    processReferenceable.set("queryText", queryStr);
    processReferenceable.set("queryId", hiveEvent.getQueryId());
    processReferenceable.set("queryPlan", hiveEvent.getJsonPlan());
    processReferenceable.set(AtlasConstants.CLUSTER_NAME_ATTRIBUTE, dgiBridge.getClusterName());

    List<String> recentQueries = new ArrayList<>(1);
    recentQueries.add(queryStr);
    processReferenceable.set("recentQueries", recentQueries);

    processReferenceable.set("endTime", new Date(System.currentTimeMillis()));
    // TODO set queryGraph
    return processReferenceable;
  }