Package com.senseidb.search.req

Examples of com.senseidb.search.req.SenseiError


      }));
    } catch (Exception e) {
      _errorMeter.mark();
      RESULT emptyResult = getEmptyResultInstance();
      logger.error("Error running scatter/gather", e);
      emptyResult.addError(new SenseiError("Error gathering the results" + e.getMessage(), ErrorType.BrokerGatherError));
      return emptyResult;
    }

    if (resultList.size() == 0)
    {
      logger.error("no result received at all return empty result");
      RESULT emptyResult = getEmptyResultInstance();
      emptyResult.addError(new SenseiError("Error gathering the results. " + "no result received at all return empty result", ErrorType.BrokerGatherError));
      _emptyMeter.mark();
      return emptyResult;
    }

    RESULT result = null;
    try {
      result = _gatherTimer.time(new Callable<RESULT>() {
        @Override
        public RESULT call() throws Exception {
          return mergeResults(req, resultList);
        }
      });
    } catch (Exception e) {
      result = getEmptyResultInstance();
      logger.error("Error gathering the results", e);
      result.addError(new SenseiError("Error gathering the results" + e.getMessage(), ErrorType.BrokerGatherError));
      _errorMeter.mark();
    }

    if (logger.isDebugEnabled()){
      logger.debug("remote search took " + (System.currentTimeMillis() - time) + "ms");
View Full Code Here


          {
            boboBrowseList.add(result);
          }
        }
        RESULT res = mergeResults(_request, boboBrowseList);
        res.addError(new SenseiError("Request timeout", ErrorType.BrokerTimeout));
        if (debugmode)
        {
          logger.debug("merged results: " + res);
          logger.debug("Merging the sensei Results for the input senseiRequest");
        }
View Full Code Here

          doc.removeFields(SenseiSchema.SRC_DATA_COMPRESSED_FIELD_NAME);
          doc.removeFields(SenseiSchema.SRC_DATA_FIELD_NAME);
        }
        catch(Exception e)
        {
          res.addError(new SenseiError(e.getMessage(),ErrorType.BrokerGatherError));
          logger.error(e.getMessage(),e);
        }
      }
    }
View Full Code Here

                  return res;
                }
              });
            } catch (Exception e)
            {
              senseiReq.addError(new SenseiError(e.getMessage(), ErrorType.BoboExecutionError));             
              logger.error(e.getMessage(), e);
            }
          }
          else  // Reuse current thread.
          {
            try
            {
              Timer timer = getTimer(partition);
              Res res = timer.time(new Callable<Res>(){

                @Override
                public Res call() throws Exception {
                  return  handleRequest(senseiReq, readerFactory, _core.getQueryBuilderFactory(), indexReaderCache);
                }                   
              });
             
              resultList.add(res);             
              long end = System.currentTimeMillis();
              res.setTime(end - start);
              logger.info("searching partition: " + partition + " browse took: " + res.getTime());
            } catch (Exception e)
            {
              logger.error(e.getMessage(), e);
              senseiReq.addError(new SenseiError(e.getMessage(), ErrorType.BoboExecutionError));      
             
              resultList.add(getEmptyResultInstance(e));
            }
          }
          ++i;
        }

        for (i=0; i<futures.length; ++i)
        {
          try
          {
            Res res = futures[i].get(_timeout, TimeUnit.MILLISECONDS);
            resultList.add(res);
          }
          catch(Exception e)
          {
           
            logger.error(e.getMessage(), e);
            if (e instanceof TimeoutException) {
              senseiReq.addError(new SenseiError(e.getMessage(), ErrorType.ExecutionTimeout));   
            } else {
              senseiReq.addError(new SenseiError(e.getMessage(), ErrorType.BoboExecutionError));      
            }
            resultList.add(getEmptyResultInstance(e));
          }
        }

          try{
          finalResult = _mergeTimer.time(new Callable<Res>(){
         public Res call() throws Exception{
           return mergePartitionedResults(senseiReq, resultList);
         }
          });
          }
          catch(Exception e){
          logger.error(e.getMessage(),e);
          finalResult = getEmptyResultInstance(null);
          finalResult.addError(new SenseiError(e.getMessage(), ErrorType.MergePartitionError));
          }
      } finally {
        returnIndexReaders(indexReaderCache);
      }
      }
     
      else
      {
        if (logger.isInfoEnabled()){
          logger.info("no partitions specified");
        }
        finalResult = getEmptyResultInstance(null);
        finalResult.addError(new SenseiError("no partitions specified", ErrorType.PartitionCallError));
      }
      if (logger.isInfoEnabled()){
        logger.info("searching partitions: " + String.valueOf(partitions) + "; route by: " + senseiReq.getRouteParam() + "; took: " + finalResult.getTime());
      }
      return finalResult;
View Full Code Here

      numHits = res.getNumHits();
      totalDocs = res.getTotalDocs();
      sendResponse(req, resp, requestContext.senseiReq, res);
   } catch (JSONException e) {
      try {
        writeEmptyResponse(req, resp, new SenseiError(e.getMessage(), ErrorType.JsonParsingError));
      } catch (Exception ex) {
        throw new ServletException(e);
      }
    }
    catch (Exception e)
    {
      try {
        logger.error(e.getMessage(), e);
        if (e.getCause() != null && e.getCause() instanceof JSONException) {
          writeEmptyResponse(req, resp, new SenseiError(e.getMessage(), ErrorType.JsonParsingError));
      } else {
        writeEmptyResponse(req, resp, new SenseiError(e.getMessage(), ErrorType.InternalError));
      }
      } catch (Exception ex) {
        throw new ServletException(e);
      }
    }
View Full Code Here

        requestContext.jsonObj = new FastJSONObject(requestContext.content);
      }
      catch(JSONException jse)
      {
        logger.error("JSON parsing error", jse);
        writeEmptyResponse(req, resp, new SenseiError(jse.getMessage(), ErrorType.JsonParsingError));
        return null;
      }
    }
    else
    {
View Full Code Here

    {
      String contentType = req.getHeader("Content-Type");
      if (contentType != null && contentType.indexOf("json") >= 0)
      {
        logger.error("JSON parsing error", jse);          
          writeEmptyResponse(req, resp, new SenseiError(jse.getMessage(), ErrorType.JsonParsingError));             
          return null;           
      }

      logger.warn("Old client or json error", jse);
View Full Code Here

      if (errMsg == null)
      {
        errMsg = "Unknown parsing error.";
      }
      logger.error("BQL parsing error: " + errMsg + ", BQL: " + requestContext.bqlStmt);
      writeEmptyResponse(req, resp, new SenseiError(errMsg, ErrorType.BQLParsingError));
      return false;
    }

    // Handle extra BQL filter if it exists
    String extraFilter = requestContext.jsonObj.optString(BQL_EXTRA_FILTER);
    JSONObject predObj = null;
    if (extraFilter.length() > 0)
    {
      String bql2 = "SELECT * WHERE " + extraFilter;
      try
      {
        predObj = _compiler.compile(bql2);
      }
      catch (RecognitionException e)
      {
        String errMsg = _compiler.getErrorMessage(e);
        if (errMsg == null)
        {
          errMsg = "Unknown parsing error.";
        }
        logger.error("BQL parsing error for additional preds: " + errMsg + ", BQL: " + bql2);
        writeEmptyResponse(req, resp, new SenseiError("BQL parsing error for additional preds: " + errMsg + ", BQL: " + bql2, ErrorType.BQLParsingError));
        return false;
      }

      // Combine filters
      JSONArray filter_list = new FastJSONArray();
      JSONObject currentFilter = requestContext.compiledJson.optJSONObject("filter");
      if (currentFilter != null)
      {
        filter_list.put(currentFilter);
      }

      JSONArray selections = predObj.optJSONArray("selections");
      if (selections != null)
      {
        for (int i = 0; i < selections.length(); ++i)
        {
          JSONObject pred = selections.getJSONObject(i);
          if (pred != null)
          {
            filter_list.put(pred);
          }
        }
      }
      JSONObject additionalFilter = predObj.optJSONObject("filter");
      if (additionalFilter != null)
      {
        filter_list.put(additionalFilter);
      }
     
      if (filter_list.length() > 1)
      {
        requestContext.compiledJson.put("filter", new FastJSONObject().put("and", filter_list));
      }
      else if (filter_list.length() == 1)
      {
        requestContext.compiledJson.put("filter", filter_list.get(0));
      }
    }

    JSONObject metaData = requestContext.compiledJson.optJSONObject("meta");
    if (metaData != null)
    {
      JSONArray variables = metaData.optJSONArray("variables");
      if (variables != null)
      {
        for (int i = 0; i < variables.length(); ++i)
        {
          String var = variables.getString(i);
          if (requestContext.templatesJson == null ||
              requestContext.templatesJson.opt(var) == null)
          {
            writeEmptyResponse(req, resp, new SenseiError("[line:0, col:0] Variable " + var + " is not found.", ErrorType.BQLParsingError));
            return false;
          }
        }
      }
    }
View Full Code Here

      handleJMXRequest(req, resp);
    }else if (req.getPathInfo().startsWith("/federatedBroker/"))
    {
      if (federatedBroker == null) {
        try {
          writeEmptyResponse(req, resp, new SenseiError("The federated broker wasn't initialized", ErrorType.FederatedBrokerUnavailable)) ;
        } catch (Exception e) {
          throw new RuntimeException(e);
        }                   
      }
      handleSenseiRequest(req, resp, federatedBroker);
View Full Code Here

    merged.getErrors().addAll(req.getErrors());
    for (SenseiResult res : results) {
      merged.getErrors().addAll(res.getErrors());
      if (res.getBoboErrors().size() > 0) {
        for (String boboError : res.getBoboErrors()) {
          merged.addError(new SenseiError(boboError, ErrorType.BoboExecutionError));
        }
      }
    }
  }
View Full Code Here

TOP

Related Classes of com.senseidb.search.req.SenseiError

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.