private void handleGET() { if (parts.size() == 1) { resp.add("solrConfig", req.getCore().getSolrConfig().toMap()); } else { if (ConfigOverlay.NAME.equals(parts.get(1))) { resp.add(ConfigOverlay.NAME, req.getCore().getSolrConfig().getOverlay().toMap()); } else if (RequestParams.NAME.equals(parts.get(1))) { if (parts.size() == 3) { RequestParams params = req.getCore().getSolrConfig().getRequestParams(); MapSolrParams p = params.getParams(parts.get(2)); Map m = new LinkedHashMap<>(); m.put(ConfigOverlay.ZNODEVER, params.getZnodeVersion()); if (p != null) { m.put(RequestParams.NAME, ZkNodeProps.makeMap(parts.get(2), p.getMap())); } resp.add(SolrQueryResponse.NAME, m); } else { resp.add( SolrQueryResponse.NAME, req.getCore().getSolrConfig().getRequestParams().toMap()); } } else { Map<String, Object> m = req.getCore().getSolrConfig().toMap(); resp.add("solrConfig", ZkNodeProps.makeMap(parts.get(1), m.get(parts.get(1)))); } } }
private void handlePOST() throws IOException { Iterable<ContentStream> streams = req.getContentStreams(); if (streams == null) { throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "missing content stream"); } ArrayList<CommandOperation> ops = new ArrayList<>(); for (ContentStream stream : streams) ops.addAll(CommandOperation.parse(stream.getReader())); List<Map> errList = CommandOperation.captureErrors(ops); if (!errList.isEmpty()) { resp.add(CommandOperation.ERR_MSGS, errList); return; } try { for (; ; ) { ArrayList<CommandOperation> opsCopy = new ArrayList<>(ops.size()); for (CommandOperation op : ops) opsCopy.add(op.getCopy()); try { if (parts.size() > 1 && RequestParams.NAME.equals(parts.get(1))) { RequestParams params = RequestParams.getFreshRequestParams( req.getCore().getResourceLoader(), req.getCore().getSolrConfig().getRequestParams()); handleParams(opsCopy, params); } else { ConfigOverlay overlay = SolrConfig.getConfigOverlay(req.getCore().getResourceLoader()); handleCommands(opsCopy, overlay); } break; // succeeded . so no need to go over the loop again } catch (ZkController.ResourceModifiedInZkException e) { // retry log.info( "Race condition, the node is modified in ZK by someone else " + e.getMessage()); } } } catch (Exception e) { resp.setException(e); resp.add(CommandOperation.ERR_MSGS, singletonList(SchemaManager.getErrorStr(e))); } }