public TraceStopwatch peek() { Entry<String,TraceStopwatch> entry = watches.peekLast(); if (null == entry) { NotFoundQueryException qe = new NotFoundQueryException(DatawaveErrorCode.STOPWATCH_MISSING); throw (NoSuchElementException) (new NoSuchElementException().initCause(qe)); } return entry.getValue(); }
private FileSystem getFS(String hdfs, BaseResponse response) { org.apache.hadoop.conf.Configuration conf = new org.apache.hadoop.conf.Configuration(); conf.set("fs.defaultFS", hdfs); // Override default buffer size (4K) to 16K conf.setInt("io.file.buffer.size", 16384); final FileSystem fs; try { fs = FileSystem.get(conf); return fs; } catch (IOException e1) { NotFoundQueryException qe = new NotFoundQueryException(DatawaveErrorCode.HDFS_CONNECTION_ERROR, e1, MessageFormat.format("Location: {0}", hdfs)); log.error(qe); response.addException(qe); throw new NotFoundException(qe, response); } }
public static InputStream consumeHeader(byte[] data) throws InvalidDocumentHeader { if (null == data || 3 > data.length) { QueryException qe = new QueryException(DatawaveErrorCode.DATA_INVALID_ERROR, MessageFormat.format("Length: {0}", (null != data ? data.length : null))); throw new InvalidDocumentHeader(qe); } ByteArrayInputStream bais = new ByteArrayInputStream(data); int magic = readUShort(bais); if (DOC_MAGIC != magic) { NotFoundQueryException qe = new NotFoundQueryException(DatawaveErrorCode.EXPECTED_HEADER_NOT_FOUND); throw new InvalidDocumentHeader(qe); } int compression = readUByte(bais); if (NONE == compression) { return new ByteArrayInputStream(data, 3, data.length - 3); } else if (GZIP == compression) { ByteArrayInputStream bytes = new ByteArrayInputStream(data, 3, data.length - 3); return new InflaterInputStream(bytes, new Inflater(), 1024); } else { BadRequestQueryException qe = new BadRequestQueryException(DatawaveErrorCode.UNKNOWN_COMPRESSION_SCHEME, MessageFormat.format("{0}", compression)); throw new InvalidDocumentHeader(qe); } }
/** * Fetch the literal off of the grandchild. Throws an exception if there is no literal * * @param node * @return * @throws NoSuchElementException */ @SuppressWarnings("rawtypes") public static Object getLiteralValue(JexlNode node) throws NoSuchElementException { Object literal = getLiteral(node); // If the grandchild and its image is non-null and equal to the any-field identifier if (literal instanceof JexlNode.Literal) { return ((JexlNode.Literal) literal).getLiteral(); } else if (literal instanceof ASTTrueNode) { return true; } else if (literal instanceof ASTFalseNode) { return false; } else if (literal instanceof ASTNullLiteral) { return null; } NotFoundQueryException qe = new NotFoundQueryException(DatawaveErrorCode.LITERAL_MISSING); throw (NoSuchElementException) (new NoSuchElementException().initCause(qe)); }
public datawave.query.language.tree.QueryNode build(QueryNode queryNode) throws QueryNodeException { datawave.query.language.tree.QueryNode returnNode = null; int depth = 0; QueryNode parent = queryNode; while ((parent = parent.getParent()) != null) { depth++; } if (queryNode instanceof FunctionQueryNode) { FunctionQueryNode functionQueryNode = (FunctionQueryNode) queryNode; String functionName = functionQueryNode.getFunction(); List<String> parameterList = functionQueryNode.getParameterList(); LuceneQueryFunction referenceFunction = allowedFunctionMap.get(functionName.toUpperCase()); if (referenceFunction == null) { NotFoundQueryException qe = new NotFoundQueryException(DatawaveErrorCode.FUNCTION_NOT_FOUND, MessageFormat.format("{0}", functionName)); throw new IllegalArgumentException(qe); } LuceneQueryFunction function = (LuceneQueryFunction) referenceFunction.duplicate(); returnNode = new FunctionNode(function, parameterList, depth, queryNode.getParent()); } return returnNode; }
public JexlNode build(QueryNode queryNode) { JexlNode returnNode = null; int depth = 0; QueryNode parent = queryNode; while ((parent = parent.getParent()) != null) { depth++; } if (queryNode instanceof FunctionQueryNode) { FunctionQueryNode functionQueryNode = (FunctionQueryNode) queryNode; String functionName = functionQueryNode.getFunction(); List<String> parameterList = functionQueryNode.getParameterList(); JexlQueryFunction referenceFunction = allowedFunctionMap.get(functionName.toUpperCase()); if (referenceFunction == null) { NotFoundQueryException qe = new NotFoundQueryException(DatawaveErrorCode.FUNCTION_NOT_FOUND, MessageFormat.format("{0}", functionName)); throw new IllegalArgumentException(qe); } // if more than one term in quotes, use an AdjNode JexlQueryFunction function = (JexlQueryFunction) referenceFunction.duplicate(); returnNode = new JexlFunctionNode(function, parameterList, depth, queryNode.getParent()); } return returnNode; }
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; }
if (null == response) response = new MapReduceInfoResponseList(); NotFoundQueryException qe = new NotFoundQueryException(DatawaveErrorCode.NO_QUERY_OBJECT_MATCH); response.addException(qe); throw new NotFoundException(qe, response); NotFoundQueryException qe = new NotFoundQueryException(DatawaveErrorCode.TOO_MANY_MAPREDUCE_OBJECT_MATCHES); response.addException(qe); throw new NotFoundException(qe, response);
NotFoundQueryException qe = new NotFoundQueryException(DatawaveErrorCode.JEXL_NODES_MISSING, MessageFormat.format( "Class: {0}, Namespace: {1}, Function: {2}", this.getClass().getSimpleName(), namespace, funcName)); throw new IllegalArgumentException(qe);
NotFoundQueryException qe = new NotFoundQueryException(DatawaveErrorCode.TABLE_NOT_FOUND, e); throw new DatawaveFatalQueryException(qe);
FileSystem fs = getFS(hdfs, response); if (fs.exists(p) && !fs.delete(p, true)) { NotFoundQueryException qe = new NotFoundQueryException(DatawaveErrorCode.WORKING_DIRECTORY_DELETE_ERROR, MessageFormat.format("{0}", wdir)); log.error(qe); response.addException(qe); NotFoundQueryException qe = new NotFoundQueryException(DatawaveErrorCode.WORKING_DIRECTORY_DELETE_ERROR, e, MessageFormat.format("{0}", wdir)); log.error(qe); throw new NotFoundException(qe, response);
NotFoundQueryException qe = new NotFoundQueryException(DatawaveErrorCode.NO_MAPREDUCE_OBJECT_MATCH); response.addException(qe); throw new NotFoundException(qe, response); } else if (list.getResults().size() > 1) { NotFoundQueryException qe = new NotFoundQueryException(DatawaveErrorCode.TOO_MANY_MAPREDUCE_OBJECT_MATCHES); response.addException(qe); throw new NotFoundException(qe, response);
List<Query> queries = persister.findById(id); if (null == queries || queries.isEmpty()) throw new NotFoundQueryException(DatawaveErrorCode.NO_QUERY_OBJECT_MATCH); if (queries.size() > 1) throw new NotFoundQueryException(DatawaveErrorCode.TOO_MANY_QUERY_OBJECT_MATCHES); else { Query q = queries.get(0);
List<Query> queries = persister.findById(id); if (null == queries || queries.isEmpty()) throw new NotFoundQueryException(DatawaveErrorCode.NO_QUERY_OBJECT_MATCH); if (queries.size() > 1) throw new NotFoundQueryException(DatawaveErrorCode.TOO_MANY_QUERY_OBJECT_MATCHES); else { Query q = queries.get(0);
NotFoundQueryException e = new NotFoundQueryException(DatawaveErrorCode.NO_QUERY_OBJECT_MATCH); throw new NotFoundException(e, response); } else {
throw new NotFoundQueryException(DatawaveErrorCode.NO_QUERY_OBJECT_MATCH);
NotFoundQueryException qe = new NotFoundQueryException(DatawaveErrorCode.IDENTIFIER_MISSING); throw (NoSuchElementException) (new NoSuchElementException().initCause(qe));
NotFoundQueryException qe = new NotFoundQueryException(DatawaveErrorCode.NO_ANYFIELD_EXPANSION_MATCH); log.warn(qe); throw new CannotExpandUnfieldedTermFatalException(qe);
NotFoundQueryException e = new NotFoundQueryException(DatawaveErrorCode.NO_QUERY_OBJECT_MATCH); throw new NotFoundException(e, response); } else {
NotFoundQueryException qe = new NotFoundQueryException(DatawaveErrorCode.NO_UNFIELDED_TERM_EXPANSION_MATCH); log.warn(qe); throw new CannotExpandUnfieldedTermFatalException(qe);