use of org.apache.solr.response.SolrQueryResponse in project lucene-solr by apache.
the class SolrTestCaseJ4 method addDoc.
public static void addDoc(String doc, String updateRequestProcessorChain) throws Exception {
Map<String, String[]> params = new HashMap<>();
MultiMapSolrParams mmparams = new MultiMapSolrParams(params);
params.put(UpdateParams.UPDATE_CHAIN, new String[] { updateRequestProcessorChain });
SolrQueryRequestBase req = new SolrQueryRequestBase(h.getCore(), (SolrParams) mmparams) {
};
UpdateRequestHandler handler = new UpdateRequestHandler();
handler.init(null);
ArrayList<ContentStream> streams = new ArrayList<>(2);
streams.add(new ContentStreamBase.StringStream(doc));
req.setContentStreams(streams);
handler.handleRequestBody(req, new SolrQueryResponse());
req.close();
}
use of org.apache.solr.response.SolrQueryResponse in project lucene-solr by apache.
the class StatsReloadRaceTest method checkReloadComlpetion.
private boolean checkReloadComlpetion(int asyncId) {
boolean isCompleted;
SolrQueryResponse rsp = new SolrQueryResponse();
h.getCoreContainer().getMultiCoreHandler().handleRequest(req(CoreAdminParams.ACTION, CoreAdminParams.CoreAdminAction.REQUESTSTATUS.toString(), CoreAdminParams.REQUESTID, "" + asyncId), rsp);
@SuppressWarnings("unchecked") List<Object> statusLog = rsp.getValues().getAll(CoreAdminAction.STATUS.name());
assertFalse("expect status check w/o error, got:" + statusLog, statusLog.contains(CoreAdminHandler.FAILED));
isCompleted = statusLog.contains(CoreAdminHandler.COMPLETED);
return isCompleted;
}
use of org.apache.solr.response.SolrQueryResponse in project lucene-solr by apache.
the class StatsReloadRaceTest method requestMetrics.
private void requestMetrics(boolean softFail) throws Exception {
SolrQueryResponse rsp = new SolrQueryResponse();
String registry = "solr.core." + h.coreName;
String key = "SEARCHER.searcher.indexVersion";
boolean found = false;
int count = 10;
while (!found && count-- > 0) {
h.getCoreContainer().getRequestHandler("/admin/metrics").handleRequest(req("prefix", "SEARCHER", "registry", registry, "compact", "true"), rsp);
NamedList values = rsp.getValues();
// this is not guaranteed to exist right away after core reload - there's a
// small window between core load and before searcher metrics are registered
// so we may have to check a few times, and then fail softly if reload is not complete yet
NamedList metrics = (NamedList) values.get("metrics");
if (metrics == null) {
if (softFail) {
return;
} else {
fail("missing 'metrics' element in handler's output: " + values.asMap(5).toString());
}
}
metrics = (NamedList) metrics.get(registry);
if (metrics.get(key) != null) {
found = true;
assertTrue(metrics.get(key) instanceof Long);
break;
} else {
Thread.sleep(500);
}
}
if (softFail && !found) {
return;
}
assertTrue("Key " + key + " not found in registry " + registry, found);
}
use of org.apache.solr.response.SolrQueryResponse in project lucene-solr by apache.
the class TestApiFramework method testFramework.
public void testFramework() {
Map<String, Object[]> calls = new HashMap<>();
Map<String, Object> out = new HashMap<>();
CoreContainer mockCC = TestCoreAdminApis.getCoreContainerMock(calls, out);
PluginBag<SolrRequestHandler> containerHandlers = new PluginBag<>(SolrRequestHandler.class, null, false);
containerHandlers.put(COLLECTIONS_HANDLER_PATH, new TestCollectionAPIs.MockCollectionsHandler());
containerHandlers.put(CORES_HANDLER_PATH, new CoreAdminHandler(mockCC));
containerHandlers.put(CONFIGSETS_HANDLER_PATH, new ConfigSetsHandler(mockCC));
out.put("getRequestHandlers", containerHandlers);
PluginBag<SolrRequestHandler> coreHandlers = new PluginBag<>(SolrRequestHandler.class, null, false);
coreHandlers.put("/schema", new SchemaHandler());
coreHandlers.put("/config", new SolrConfigHandler());
coreHandlers.put("/admin/ping", new PingRequestHandler());
Map<String, String> parts = new HashMap<>();
String fullPath = "/collections/hello/shards";
Api api = V2HttpCall.getApiInfo(containerHandlers, fullPath, "POST", fullPath, parts);
assertNotNull(api);
assertConditions(api.getSpec(), Utils.makeMap("/methods[0]", "POST", "/commands/create", NOT_NULL));
assertEquals("hello", parts.get("collection"));
parts = new HashMap<>();
api = V2HttpCall.getApiInfo(containerHandlers, "/collections/hello/shards", "POST", null, parts);
assertConditions(api.getSpec(), Utils.makeMap("/methods[0]", "POST", "/commands/split", NOT_NULL, "/commands/add-replica", NOT_NULL));
parts = new HashMap<>();
api = V2HttpCall.getApiInfo(containerHandlers, "/collections/hello/shards/shard1", "POST", null, parts);
assertConditions(api.getSpec(), Utils.makeMap("/methods[0]", "POST", "/commands/force-leader", NOT_NULL));
assertEquals("hello", parts.get("collection"));
assertEquals("shard1", parts.get("shard"));
parts = new HashMap<>();
api = V2HttpCall.getApiInfo(containerHandlers, "/collections/hello", "POST", null, parts);
assertConditions(api.getSpec(), Utils.makeMap("/methods[0]", "POST", "/commands/add-replica-property", NOT_NULL, "/commands/delete-replica-property", NOT_NULL));
assertEquals("hello", parts.get("collection"));
api = V2HttpCall.getApiInfo(containerHandlers, "/collections/hello/shards/shard1/replica1", "DELETE", null, parts);
assertConditions(api.getSpec(), Utils.makeMap("/methods[0]", "DELETE", "/url/params/onlyIfDown/type", "boolean"));
assertEquals("hello", parts.get("collection"));
assertEquals("shard1", parts.get("shard"));
assertEquals("replica1", parts.get("replica"));
SolrQueryResponse rsp = invoke(containerHandlers, null, "/collections/_introspect", GET, mockCC);
assertConditions(rsp.getValues().asMap(2), Utils.makeMap("/spec[0]/methods[0]", "DELETE", "/spec[1]/methods[0]", "POST", "/spec[2]/methods[0]", "GET"));
rsp = invoke(coreHandlers, "/schema/_introspect", "/collections/hello/schema/_introspect", GET, mockCC);
assertConditions(rsp.getValues().asMap(2), Utils.makeMap("/spec[0]/methods[0]", "POST", "/spec[0]/commands", NOT_NULL, "/spec[1]/methods[0]", "GET"));
rsp = invoke(coreHandlers, "/", "/collections/hello/_introspect", GET, mockCC);
assertConditions(rsp.getValues().asMap(2), Utils.makeMap("/availableSubPaths", NOT_NULL, "availableSubPaths /collections/hello/config/jmx", NOT_NULL, "availableSubPaths /collections/hello/schema", NOT_NULL, "availableSubPaths /collections/hello/shards", NOT_NULL, "availableSubPaths /collections/hello/shards/{shard}", NOT_NULL, "availableSubPaths /collections/hello/shards/{shard}/{replica}", NOT_NULL));
}
use of org.apache.solr.response.SolrQueryResponse in project lucene-solr by apache.
the class TestApiFramework method invoke.
private SolrQueryResponse invoke(PluginBag<SolrRequestHandler> reqHandlers, String path, String fullPath, SolrRequest.METHOD method, CoreContainer mockCC) {
HashMap<String, String> parts = new HashMap<>();
boolean containerHandlerLookup = mockCC.getRequestHandlers() == reqHandlers;
path = path == null ? fullPath : path;
Api api = null;
if (containerHandlerLookup) {
api = V2HttpCall.getApiInfo(reqHandlers, path, "GET", fullPath, parts);
} else {
api = V2HttpCall.getApiInfo(mockCC.getRequestHandlers(), fullPath, "GET", fullPath, parts);
if (api == null)
api = new CompositeApi(null);
if (api instanceof CompositeApi) {
CompositeApi compositeApi = (CompositeApi) api;
api = V2HttpCall.getApiInfo(reqHandlers, path, "GET", fullPath, parts);
compositeApi.add(api);
api = compositeApi;
}
}
SolrQueryResponse rsp = new SolrQueryResponse();
LocalSolrQueryRequest req = new LocalSolrQueryRequest(null, new MapSolrParams(new HashMap<>())) {
@Override
public List<CommandOperation> getCommands(boolean validateInput) {
return Collections.emptyList();
}
};
api.call(req, rsp);
return rsp;
}
Aggregations