datawave.webservice.query.Query.getId()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(12.0k)|赞(0)|评价(0)|浏览(168)

本文整理了Java中datawave.webservice.query.Query.getId方法的一些代码示例,展示了Query.getId的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.getId方法的具体详情如下:
包路径:datawave.webservice.query.Query
类名称:Query
方法名:getId

Query.getId介绍

暂无

代码示例

代码示例来源:origin: NationalSecurityAgency/datawave

@Override
protected String serviceName() {
  String id = "NoQueryId";
  if (null != settings && null != settings.getId()) {
    id = settings.getId().toString();
  }
  return "RangeStreamScanner (" + id + ")";
}

代码示例来源:origin: NationalSecurityAgency/datawave

public ParallelExpansionFactory(Query query, String name) {
  if (query == null || query.getId() == null) {
    this.threadIdentifier = "(unknown)";
  } else {
    this.threadIdentifier = query.getId().toString();
  }
  this.name = name;
}

代码示例来源:origin: NationalSecurityAgency/datawave

public FixUnfieldedTermsVisitorThreadFactory(Query query) {
  if (query == null || query.getId() == null) {
    this.threadIdentifier = "(unknown)";
  } else {
    this.threadIdentifier = query.getId().toString();
  }
}

代码示例来源:origin: NationalSecurityAgency/datawave

private void addQueryToTrackingMap(Map<String,String> trackingMap, Query q) {
  
  if (trackingMap == null || q == null) {
    return;
  }
  
  if (q.getOwner() != null) {
    trackingMap.put("query.user", q.getOwner());
  }
  if (q.getId() != null) {
    trackingMap.put("query.id", q.getId().toString());
  }
  if (q.getId() != null) {
    trackingMap.put("query.query", q.getQuery());
  }
}

代码示例来源:origin: NationalSecurityAgency/datawave

private void addQueryToTrackingMap(Map<String,String> trackingMap, Query q) {
  
  if (trackingMap == null || q == null) {
    return;
  }
  
  if (q.getOwner() != null) {
    trackingMap.put("query.user", q.getOwner());
  }
  if (q.getId() != null) {
    trackingMap.put("query.id", q.getId().toString());
  }
  if (q.getId() != null) {
    trackingMap.put("query.query", q.getQuery());
  }
}

代码示例来源:origin: NationalSecurityAgency/datawave

protected URI getFstHdfsQueryCacheUri(ShardQueryConfiguration config, Query settings) {
    if (config.getIvaratorFstHdfsBaseURIs() != null) {
      String[] choices = StringUtils.split(config.getIvaratorFstHdfsBaseURIs(), ',');
      int index = new Random().nextInt(choices.length);
      Path path = new Path(choices[index], settings.getId().toString());
      return path.toUri();
    }
    return null;
  }
}

代码示例来源:origin: NationalSecurityAgency/datawave

@Override
public void close(GenericQueryConfiguration genericConfig, Query settings) {
  if (!(genericConfig instanceof ShardQueryConfiguration)) {
    if (genericConfig != null) {
      log.warn("Config object must be an instance of ShardQueryConfiguration to properly close the DefaultQueryPlanner. You gave me a "
              + genericConfig);
    }
    if (null != builderThread) {
      builderThread.shutdown();
    }
    return;
  }
  
  ShardQueryConfiguration config = (ShardQueryConfiguration) genericConfig;
  
  // lets mark the query as closed (used by ivarators at a minimum)
  try {
    markQueryStopped(config, settings);
  } catch (Exception e) {
    log.error("Failed to close query " + settings.getId(), e);
  }
  
  if (null != builderThread)
    builderThread.shutdown();
}

代码示例来源:origin: NationalSecurityAgency/datawave

private void addNDC() {
  String user = this.settings.getUserDN();
  UUID uuid = this.settings.getId();
  if (user != null && uuid != null) {
    NDC.push("[" + user + "] [" + uuid + "]");
  }
}

代码示例来源:origin: NationalSecurityAgency/datawave

@Override
public GenericQueryConfiguration initialize(Connector connection, Query settings, Set<Authorizations> auths) throws Exception {
  
  this.config = ShardQueryConfiguration.create(this, settings);
  if (log.isTraceEnabled())
    log.trace("Initializing ShardQueryLogic: " + System.identityHashCode(this) + '('
            + (this.getSettings() == null ? "empty" : this.getSettings().getId()) + ')');
  initialize(config, connection, settings, auths);
  return config;
}

代码示例来源:origin: NationalSecurityAgency/datawave

@Override
public String toString() {
  
  String host = System.getProperty("jboss.host.name");
  
  return new StringBuilder().append("host:").append(host).append(", id:").append(this.getSettings().getId()).append(", query:")
          .append(StringEscapeUtils.escapeHtml(this.getSettings().getQuery())).append(", auths:")
          .append(this.getSettings().getQueryAuthorizations()).append(", user:").append(this.getSettings().getOwner()).append(", queryLogic:")
          .append(this.getSettings().getQueryLogicName()).append(", name:").append(this.getSettings().getQueryName()).append(", pagesize:")
          .append(this.getSettings().getPagesize()).append(", begin:").append(this.getSettings().getBeginDate()).append(", end:")
          .append(this.getSettings().getEndDate()).append(", expiration:").append(this.getSettings().getExpirationDate()).append(", params: ")
          .append(this.getSettings().getParameters()).append(", callTime: ")
          .append((this.getTimeOfCurrentCall() == 0) ? 0 : System.currentTimeMillis() - this.getTimeOfCurrentCall()).toString();
  
}

代码示例来源:origin: NationalSecurityAgency/datawave

public static <T extends Query> Mutation toMutation(T query, ColumnVisibility vis) {
  // Store by sid for backwards compatibility
  Mutation m = new Mutation(query.getOwner());
  try {
    @SuppressWarnings("unchecked")
    Schema<T> schema = (Schema<T>) RuntimeSchema.getSchema(query.getClass());
    byte[] bytes = ProtobufIOUtil.toByteArray(query, schema, BUFFER.get());
    m.put(query.getQueryName(), query.getId() + NULL_BYTE + query.getClass().getName(), vis, query.getExpirationDate().getTime(), new Value(bytes));
    return m;
  } finally {
    BUFFER.get().clear();
  }
}

代码示例来源:origin: NationalSecurityAgency/datawave

@Override
public CloseableIterable<QueryData> process(GenericQueryConfiguration genericConfig, String query, Query settings, ScannerFactory scannerFactory)
        throws DatawaveQueryException {
  if (!(genericConfig instanceof ShardQueryConfiguration)) {
    throw new ClassCastException("Config object must be an instance of ShardQueryConfiguration");
  }
  
  builderThread = Executors.newSingleThreadExecutor();
  
  ShardQueryConfiguration config = (ShardQueryConfiguration) genericConfig;
  
  // lets mark the query as started (used by ivarators at a minimum)
  try {
    markQueryStarted(config, settings);
  } catch (Exception e) {
    throw new DatawaveQueryException("Failed to mark query as started" + settings.getId(), e);
  }
  
  return process(scannerFactory, getMetadataHelper(config), getDateIndexHelper(config), config, query, settings);
}

代码示例来源:origin: NationalSecurityAgency/datawave

private void close(RunningQuery query) throws Exception {
  
  query.closeConnection(connectionFactory);
  queryCache.remove(query.getSettings().getId().toString());
  
  // The trace was already stopped, but mark the time we closed it in the trace data.
  TInfo traceInfo = query.getTraceInfo();
  if (traceInfo != null) {
    Span span = Trace.trace(traceInfo, "query:close");
    span.data("closedAt", new Date().toString());
    // Spans aren't recorded if they take no time, so sleep for a
    // couple milliseconds just to ensure we get something saved.
    try {
      Thread.sleep(2);
    } catch (InterruptedException e) {
      // ignore
    }
    span.stop();
    // TODO: not sure this makes any sense anymore in Accumulo 1.8.1
    // Tracer.getInstance().flush();
  }
}

代码示例来源:origin: NationalSecurityAgency/datawave

/**
 * Method to determine if a query has been idle too long based on configured values.
 *
 * @param query
 * @param currentTime
 * @return true if query has been idle too long, false otherwise
 */
private boolean isIdleTooLong(RunningQuery query, long currentTime) {
  long difference = currentTime - query.getLastUsed();
  if (log.isDebugEnabled()) {
    long countDown = (conf.getIdleTimeInMS() / 1000) - (difference / 1000);
    log.debug("Query: " + query.getSettings().getOwner() + " - " + query.getSettings().getId() + " will be evicted in: " + countDown + " seconds.");
  }
  
  return difference > conf.getIdleTimeInMS();
}

代码示例来源:origin: NationalSecurityAgency/datawave

private QueryLock getQueryLock(ShardQueryConfiguration config, Query settings) throws Exception {
  return new QueryLock.Builder().forQueryId(settings.getId() == null ? null : settings.getId().toString()).forZookeeper(config.getZookeeperConfig(), 0)
          .forHdfs(config.getHdfsSiteConfigURLs()).forIvaratorDirs(config.getIvaratorCacheBaseURIs())
          .forFstDirs(config.getIvaratorFstHdfsBaseURIs()).build();
}

代码示例来源:origin: NationalSecurityAgency/datawave

public Query create(String userDN, List<String> dnList, SecurityMarking marking, String queryLogicName, QueryParameters qp,
        MultivaluedMap<String,String> optionalQueryParameters) {
  Query q = responseObjectFactory.getQueryImpl();
  q.initialize(userDN, dnList, queryLogicName, qp, optionalQueryParameters);
  q.setColumnVisibility(marking.toColumnVisibilityString());
  q.setUncaughtExceptionHandler(new QueryUncaughtExceptionHandler());
  Thread.currentThread().setUncaughtExceptionHandler(q.getUncaughtExceptionHandler());
  // Persist the query object if required
  if (qp.getPersistenceMode().equals(QueryPersistence.PERSISTENT)) {
    log.debug("Persisting query with id: " + q.getId());
    create(q);
  }
  return q;
}

代码示例来源:origin: NationalSecurityAgency/datawave

private RunningQuery adminGetQueryById(String id) throws Exception {
  RunningQuery query = queryCache.get(id);
  
  if (query == null) {
    log.info("Query not found in cache, retrieving from accumulo");
    List<Query> queries = persister.adminFindById(id);
    
    if (queries == null || queries.isEmpty())
      throw new NotFoundQueryException(DatawaveErrorCode.NO_QUERY_OBJECT_MATCH);
    if (queries.size() > 1)
      throw new NotFoundQueryException(DatawaveErrorCode.TOO_MANY_QUERY_OBJECT_MATCHES);
    
    Query q = queries.get(0);
    
    final String auths = q.getQueryAuthorizations();
    
    // will throw IllegalArgumentException if not defined
    final QueryLogic<?> logic = queryLogicFactory.getQueryLogic(q.getQueryLogicName(), ctx.getCallerPrincipal());
    final AccumuloConnectionFactory.Priority priority = logic.getConnectionPriority();
    query = RunningQuery.createQueryWithAuthorizations(metrics, null, priority, logic, q, auths,
            new RunningQueryTimingImpl(queryExpirationConf, qp.getPageTimeout()), this.executor, this.predictor, this.metricFactory);
    
    // Put in the cache by id and name, we will have two copies that reference the same object
    queryCache.put(q.getId().toString(), query);
  }
  
  return query;
}

代码示例来源:origin: NationalSecurityAgency/datawave

public QueryInformation(Query query, String queryStr) {
  Preconditions.checkNotNull(query);
  queryId = testAndSetOption(query.getId());
  queryLogicName = testAndSetOption(query.getQueryLogicName());
  queryName = testAndSetOption(query.getQueryName());
  if (null == queryStr)
    queryString = testAndSetOption(query.getQuery());
  else
    queryString = testAndSetOption(queryStr);
  queryUser = testAndSetOption(query.getOwner());
}

代码示例来源:origin: NationalSecurityAgency/datawave

private void configureIterator(ShardQueryConfiguration config, IteratorSetting cfg, String newQueryString, boolean isFullTable)
        throws DatawaveQueryException {
  
  // Load enrichers, filters, unevaluatedExpressions, and projection
  // fields
  setCommonIteratorOptions(config, cfg);
  
  addOption(cfg, QueryOptions.LIMIT_FIELDS, config.getLimitFieldsAsString(), true);
  addOption(cfg, QueryOptions.GROUP_FIELDS, config.getGroupFieldsAsString(), true);
  addOption(cfg, QueryOptions.GROUP_FIELDS_BATCH_SIZE, config.getGroupFieldsBatchSizeAsString(), true);
  addOption(cfg, QueryOptions.UNIQUE_FIELDS, config.getUniqueFieldsAsString(), true);
  addOption(cfg, QueryOptions.HIT_LIST, Boolean.toString(config.isHitList()), false);
  addOption(cfg, QueryOptions.TYPE_METADATA_IN_HDFS, Boolean.toString(config.isTypeMetadataInHdfs()), true);
  addOption(cfg, QueryOptions.TERM_FREQUENCY_FIELDS, Joiner.on(',').join(config.getQueryTermFrequencyFields()), false);
  addOption(cfg, QueryOptions.TERM_FREQUENCIES_REQUIRED, Boolean.toString(config.isTermFrequenciesRequired()), true);
  addOption(cfg, QueryOptions.QUERY, newQueryString, false);
  addOption(cfg, QueryOptions.QUERY_ID, config.getQuery().getId().toString(), false);
  addOption(cfg, QueryOptions.FULL_TABLE_SCAN_ONLY, Boolean.toString(isFullTable), false);
  addOption(cfg, QueryOptions.TRACK_SIZES, Boolean.toString(config.isTrackSizes()), true);
  // Set the start and end dates
  configureTypeMappings(config, cfg, metadataHelper, compressMappings);
}

代码示例来源:origin: NationalSecurityAgency/datawave

public HudQuerySummary build(Query query) {
  HudQuerySummary summary = new HudQuerySummary();
  summary.setQueryLogicName(query.getQueryLogicName());
  summary.setId(query.getId().toString());
  summary.setQueryName(query.getQueryName());
  summary.setUserDN(query.getUserDN());
  summary.setQuery(query.getQuery());
  summary.setQueryAuthorizations(query.getQueryAuthorizations());
  summary.setExpirationDate(query.getExpirationDate().getTime());
  return summary;
}

相关文章