use of org.apache.solr.common.util.SimpleOrderedMap in project lucene-solr by apache.
the class ThreadDumpHandler method handleRequestBody.
@Override
public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throws IOException {
SimpleOrderedMap<Object> system = new SimpleOrderedMap<>();
rsp.add("system", system);
ThreadMXBean tmbean = ManagementFactory.getThreadMXBean();
// Thread Count
SimpleOrderedMap<Object> nl = new SimpleOrderedMap<>();
nl.add("current", tmbean.getThreadCount());
nl.add("peak", tmbean.getPeakThreadCount());
nl.add("daemon", tmbean.getDaemonThreadCount());
system.add("threadCount", nl);
// Deadlocks
ThreadInfo[] tinfos;
long[] tids = tmbean.findMonitorDeadlockedThreads();
if (tids != null) {
tinfos = tmbean.getThreadInfo(tids, Integer.MAX_VALUE);
NamedList<SimpleOrderedMap<Object>> lst = new NamedList<>();
for (ThreadInfo ti : tinfos) {
if (ti != null) {
lst.add("thread", getThreadInfo(ti, tmbean));
}
}
system.add("deadlocks", lst);
}
// Now show all the threads....
tids = tmbean.getAllThreadIds();
tinfos = tmbean.getThreadInfo(tids, Integer.MAX_VALUE);
NamedList<SimpleOrderedMap<Object>> lst = new NamedList<>();
for (ThreadInfo ti : tinfos) {
if (ti != null) {
lst.add("thread", getThreadInfo(ti, tmbean));
}
}
system.add("threadDump", lst);
rsp.setHttpCaching(false);
}
use of org.apache.solr.common.util.SimpleOrderedMap in project lucene-solr by apache.
the class SegmentsInfoRequestHandler method getSegmentsInfo.
private SimpleOrderedMap<Object> getSegmentsInfo(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception {
SolrIndexSearcher searcher = req.getSearcher();
SegmentInfos infos = SegmentInfos.readLatestCommit(searcher.getIndexReader().directory());
List<String> mergeCandidates = getMergeCandidatesNames(req, infos);
SimpleOrderedMap<Object> segmentInfos = new SimpleOrderedMap<>();
SimpleOrderedMap<Object> segmentInfo = null;
for (SegmentCommitInfo segmentCommitInfo : infos) {
segmentInfo = getSegmentInfo(segmentCommitInfo);
if (mergeCandidates.contains(segmentCommitInfo.info.name)) {
segmentInfo.add("mergeCandidate", true);
}
segmentInfos.add((String) segmentInfo.get(NAME), segmentInfo);
}
return segmentInfos;
}
use of org.apache.solr.common.util.SimpleOrderedMap in project lucene-solr by apache.
the class SolrInfoMBeanHandler method diffNamedList.
public NamedList diffNamedList(NamedList ref, NamedList now) {
NamedList out = new SimpleOrderedMap();
for (int i = 0; i < ref.size(); i++) {
String name = ref.getName(i);
Object r = ref.getVal(i);
Object n = now.remove(name);
if (n == null) {
if (r != null) {
out.add("REMOVE " + name, r);
}
} else {
out.add(name, diffObject(r, n));
}
}
for (int i = 0; i < now.size(); i++) {
String name = now.getName(i);
Object v = now.getVal(i);
if (v != null) {
out.add("ADD " + name, v);
}
}
return out;
}
use of org.apache.solr.common.util.SimpleOrderedMap in project lucene-solr by apache.
the class FieldType method getAnalyzerProperties.
/**
* Returns a description of the given analyzer, by either reporting the Analyzer class
* name (and optionally luceneMatchVersion) if it's not a TokenizerChain, or if it is,
* querying each analysis factory for its name and args.
*/
protected static SimpleOrderedMap<Object> getAnalyzerProperties(Analyzer analyzer) {
SimpleOrderedMap<Object> analyzerProps = new SimpleOrderedMap<>();
if (analyzer instanceof TokenizerChain) {
Map<String, String> factoryArgs;
TokenizerChain tokenizerChain = (TokenizerChain) analyzer;
CharFilterFactory[] charFilterFactories = tokenizerChain.getCharFilterFactories();
if (0 < charFilterFactories.length) {
List<SimpleOrderedMap<Object>> charFilterProps = new ArrayList<>();
for (CharFilterFactory charFilterFactory : charFilterFactories) {
SimpleOrderedMap<Object> props = new SimpleOrderedMap<>();
props.add(CLASS_NAME, charFilterFactory.getClassArg());
factoryArgs = charFilterFactory.getOriginalArgs();
if (null != factoryArgs) {
for (String key : factoryArgs.keySet()) {
if (!CLASS_NAME.equals(key)) {
if (LUCENE_MATCH_VERSION_PARAM.equals(key)) {
if (charFilterFactory.isExplicitLuceneMatchVersion()) {
props.add(key, factoryArgs.get(key));
}
} else {
props.add(key, factoryArgs.get(key));
}
}
}
}
charFilterProps.add(props);
}
analyzerProps.add(CHAR_FILTERS, charFilterProps);
}
SimpleOrderedMap<Object> tokenizerProps = new SimpleOrderedMap<>();
TokenizerFactory tokenizerFactory = tokenizerChain.getTokenizerFactory();
tokenizerProps.add(CLASS_NAME, tokenizerFactory.getClassArg());
factoryArgs = tokenizerFactory.getOriginalArgs();
if (null != factoryArgs) {
for (String key : factoryArgs.keySet()) {
if (!CLASS_NAME.equals(key)) {
if (LUCENE_MATCH_VERSION_PARAM.equals(key)) {
if (tokenizerFactory.isExplicitLuceneMatchVersion()) {
tokenizerProps.add(key, factoryArgs.get(key));
}
} else {
tokenizerProps.add(key, factoryArgs.get(key));
}
}
}
}
analyzerProps.add(TOKENIZER, tokenizerProps);
TokenFilterFactory[] filterFactories = tokenizerChain.getTokenFilterFactories();
if (0 < filterFactories.length) {
List<SimpleOrderedMap<Object>> filterProps = new ArrayList<>();
for (TokenFilterFactory filterFactory : filterFactories) {
SimpleOrderedMap<Object> props = new SimpleOrderedMap<>();
props.add(CLASS_NAME, filterFactory.getClassArg());
factoryArgs = filterFactory.getOriginalArgs();
if (null != factoryArgs) {
for (String key : factoryArgs.keySet()) {
if (!CLASS_NAME.equals(key)) {
if (LUCENE_MATCH_VERSION_PARAM.equals(key)) {
if (filterFactory.isExplicitLuceneMatchVersion()) {
props.add(key, factoryArgs.get(key));
}
} else {
props.add(key, factoryArgs.get(key));
}
}
}
}
filterProps.add(props);
}
analyzerProps.add(FILTERS, filterProps);
}
} else {
// analyzer is not instanceof TokenizerChain
analyzerProps.add(CLASS_NAME, analyzer.getClass().getName());
if (analyzer.getVersion() != Version.LATEST) {
analyzerProps.add(LUCENE_MATCH_VERSION_PARAM, analyzer.getVersion().toString());
}
}
return analyzerProps;
}
use of org.apache.solr.common.util.SimpleOrderedMap in project lucene-solr by apache.
the class HttpSolrCall method writeResponse.
private void writeResponse(SolrQueryResponse solrRsp, QueryResponseWriter responseWriter, Method reqMethod) throws IOException {
try {
Object invalidStates = solrReq.getContext().get(CloudSolrClient.STATE_VERSION);
// the response for each request
if (invalidStates != null)
solrRsp.add(CloudSolrClient.STATE_VERSION, invalidStates);
// Now write it out
final String ct = responseWriter.getContentType(solrReq, solrRsp);
// don't call setContentType on null
if (null != ct)
response.setContentType(ct);
if (solrRsp.getException() != null) {
NamedList info = new SimpleOrderedMap();
int code = ResponseUtils.getErrorInfo(solrRsp.getException(), info, log);
solrRsp.add("error", info);
response.setStatus(code);
}
if (Method.HEAD != reqMethod) {
// Prevent close of container streams, see SOLR-8933
OutputStream out = new CloseShieldOutputStream(response.getOutputStream());
QueryResponseWriterUtil.writeQueryResponse(out, responseWriter, solrReq, solrRsp, ct);
}
//else http HEAD request, nothing to write out, waited this long just to get ContentType
} catch (EOFException e) {
log.info("Unable to write response, client closed connection or we are shutting down", e);
}
}
Aggregations