0

我有一个网络服务,它在 modeshape 内容存储库中搜索文本。界面看起来像这样:

 @POST
    @Path("globalSearch")
    @Consumes(MediaType.TEXT_PLAIN)
    @Produces(MediaType.TEXT_XML)
    public String globalSearch(String search) {
        XMLConverterService xmlOb = new XMLConverterService();
        Map<String,String> param = xmlOb.fetchMapFromXml(search);
        StringBuffer xmlString = new StringBuffer();
        xmlString.append("<xml>");
        int count = 0;
        List<Map<String, String>> result = (new DataInterfaceService())
                .fetchGlobalSearch(param);
        if(result!=null){
        for (Map<String, String> map : result) {
            count++;
            xmlString.append("<result" + count + ">")
                    .append(xmlOb.fetchXmlFromMap(map))
                    .append("</result" + count + ">");
        }
        xmlString.append("</xml>");
        return xmlString.toString();
        }
        return null;
    }

fetchGlobalSearch() 函数看起来像这样:

public List<Map<String, String>> fetchGlobalSearch(Map<String, String> param) {
    logger.log(Level.INFO, "entering fetchGlobalSearch");
    String keyWord = param.get("keyword");
    String type = param.get("type");
    List<Map<String, String>> listOfMaps = null;
    Map<String, String> retValue = null;
    String qry = "";
    if (type.equalsIgnoreCase("GRA")) {
        qry = "SELECT [med:UNIQUE_ID],[med:GRPNAME],[med:CSR],[med:UW],[med:GROUP_STATE],[med:STR_DATE] "
                + "FROM [med:notes] where contains([med:XML_STORE], $uuid)";
    } else {
        qry = "SELECT [fur:UNIQUE_ID],[fur:MM],[fur:FROMUW],[fur:INSURED],[fur:POLICY_NUM],[fur:UWCSRDATE],[fur:FURCOMPDATE],[fur:FUR_DATE],[fur:CSRCOMPDATE] "
                + "FROM [fur:notesfur] where contains([fur:XML_STORE], $uuid)";
    }
    try {
        Query qr = qrym.createQuery(qry, Query.JCR_SQL2);

        Value uid = session.getValueFactory().createValue(keyWord);
        qr.bindValue("uuid", uid);

        QueryResult resultSet = qr.execute();
        String[] columns = resultSet.getColumnNames();

        RowIterator rowiter = resultSet.getRows();

        while (rowiter.hasNext()) {
            if (listOfMaps == null)
                listOfMaps = new ArrayList<Map<String, String>>();
            retValue = new HashMap<String, String>();
            Row row = rowiter.nextRow();
            for (String column : columns) {
                if (row.getValue(column) != null) {
                    retValue.put(column, row.getValue(column).toString());
                }
            }
            listOfMaps.add(retValue);
        }

    } catch (RepositoryException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    logger.log(Level.INFO, "exiting fetchGlobalSearch");
    return listOfMaps;
}

我通过以下代码访问网络服务:

private static void callGlobalSearch(){
        try {
            String param = "";
            param = fetchGlobalParams();
            System.out.println("param : " + param);
            // Create a socket connection to the host
            URL url = new URL(
                    "http://localhost:8080/xxttrr/rest/globalSearch");
            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
            // make url connection
            conn.setDoOutput(true);
            conn.setDoInput(true);
            conn.setUseCaches(false);
            conn.setAllowUserInteraction(true);
            conn.setRequestMethod("POST");
            conn.setRequestProperty("Content-Type",
                    "text/plain; charset=utf-8");
            conn.setRequestProperty("Content-Length", Integer.toString(param.getBytes().length));
            DataOutputStream printout = new DataOutputStream (conn.getOutputStream());
            printout.writeBytes(param);
            printout.flush();
            printout.close();
            BufferedReader in = new BufferedReader(new java.io.InputStreamReader(conn.getInputStream()));
            String line;            
            while ((line = in.readLine()) != null) {
                System.out.println(line);
            }
            in.close();
            conn.disconnect();
        } catch (Exception e) {
            System.out.println("Error: " + e);
        }

    }

问题是当我对本地 modeshape 存储库进行 Web 服务调用时,结果按预期返回。但是当我在我的 DEV 服务器中部署代码时,它会形成以下日志:

14:32:47,033 INFO [DataInterfaceService] (http-/0.0.0.0:8380-1) entering fetchGlobalSearch
14:32:47,035 DEBUG [org.modeshape.jcr.query.optimize.RuleBasedOptimizer] (http-/0.0.0.0:8380-1) Running query optimizer rule org.modeshape.jcr.query.optimize.RewritePseudoColumns@580ba9a4
14:32:47,036 DEBUG [org.modeshape.jcr.query.optimize.RuleBasedOptimizer] (http-/0.0.0.0:8380-1) Running query optimizer rule ReplaceViews
14:32:47,036 DEBUG [org.modeshape.jcr.query.optimize.RuleBasedOptimizer] (http-/0.0.0.0:8380-1) Running query optimizer rule CopyCriteria
14:32:47,037 DEBUG [org.modeshape.jcr.query.optimize.RuleBasedOptimizer] (http-/0.0.0.0:8380-1) Running query optimizer rule RightOuterToLeftOuterJoins
14:32:47,037 DEBUG [org.modeshape.jcr.query.optimize.RuleBasedOptimizer] (http-/0.0.0.0:8380-1) Running query optimizer rule AddAccessNodes
14:32:47,037 DEBUG [org.modeshape.jcr.query.optimize.RuleBasedOptimizer] (http-/0.0.0.0:8380-1) Running query optimizer rule PushSelectCriteria
14:32:47,037 DEBUG [org.modeshape.jcr.query.optimize.RuleBasedOptimizer] (http-/0.0.0.0:8380-1) Running query optimizer rule PushProjects
14:32:47,037 DEBUG [org.modeshape.jcr.query.optimize.RuleBasedOptimizer] (http-/0.0.0.0:8380-1) Running query optimizer rule AddOrderingColumnsToSources
14:32:47,038 DEBUG [org.modeshape.jcr.query.optimize.RuleBasedOptimizer] (http-/0.0.0.0:8380-1) Running query optimizer rule RewriteAsRangeCriteria
14:32:47,038 DEBUG [org.modeshape.jcr.query.optimize.RuleBasedOptimizer] (http-/0.0.0.0:8380-1) Running query optimizer rule RewritePathAndNameCriteria
14:32:47,039 DEBUG [org.modeshape.jcr.query.lucene.LuceneQueryEngine] (http-/0.0.0.0:8380-1) Executing the lucene query: +(::wks:System ::wks:Default) +:ft:ddd:XML_STORE:"uuid" +jcr:mixinTypes:ddd:notes
14:32:47,051 INFO [DataInterfaceService] (http-/0.0.0.0:8380-1) exiting fetchGlobalSearch

并终止。

它与模式形状配置或网络服务有关吗?只是让您知道,在某一时刻,modeshape 中可能有一百万条记录。导致问题的超时也是如此。如果是这样,那么我该如何配置我的网络服务,使其可以存活 5 分钟?

任何帮助,将不胜感激。相同代码在不同服务器中的行为方式不同,这确实令人困惑。

4

1 回答 1

0

没什么。错误说明了一切。显然 uuid 不应用作将参数传递给 SQL2 查询的变量名。将其更改为 uid ,它就像一个魅力。

于 2014-02-24T19:21:27.400 回答