本文整理汇总了Java中org.apache.solr.client.solrj.request.CoreAdminRequest.setAction方法的典型用法代码示例。如果您正苦于以下问题:Java CoreAdminRequest.setAction方法的具体用法?Java CoreAdminRequest.setAction怎么用?Java CoreAdminRequest.setAction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.solr.client.solrj.request.CoreAdminRequest
的用法示例。
在下文中一共展示了CoreAdminRequest.setAction方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCores
import org.apache.solr.client.solrj.request.CoreAdminRequest; //导入方法依赖的package包/类
/**
* Get target cores via CoreAdminAPI.
*
* @param httpSolrClient
* @return
*/
public static List<String> getCores(HttpSolrClient httpSolrClient) throws SolrServerException, IOException {
List<String> cores = new ArrayList<>();
NoOpResponseParser responseParser = new NoOpResponseParser();
responseParser.setWriterType("json");
httpSolrClient.setParser(responseParser);
CoreAdminRequest coreAdminRequest = new CoreAdminRequest();
coreAdminRequest.setAction(CoreAdminParams.CoreAdminAction.STATUS);
coreAdminRequest.setIndexInfoNeeded(false);
NamedList<Object> coreAdminResponse = httpSolrClient.request(coreAdminRequest);
JsonNode statusJsonNode = om.readTree((String) coreAdminResponse.get("response")).get("status");
for (Iterator<JsonNode> i = statusJsonNode.iterator(); i.hasNext(); ) {
String core = i.next().get("name").textValue();
if (!cores.contains(core)) {
cores.add(core);
}
}
return cores;
}
示例2: getEstimatedSizeOfShard
import org.apache.solr.client.solrj.request.CoreAdminRequest; //导入方法依赖的package包/类
private long getEstimatedSizeOfShard(ReplicaInfo replica) throws IOException {
try (AuthorizedSolrClient solrClient =
spec.getConnectionConfiguration().createClient(replica.baseUrl())) {
CoreAdminRequest req = new CoreAdminRequest();
req.setAction(CoreAdminParams.CoreAdminAction.STATUS);
req.setIndexInfoNeeded(true);
CoreAdminResponse response;
try {
response = solrClient.process(req);
} catch (SolrServerException e) {
throw new IOException("Can not get core status from " + replica, e);
}
NamedList<Object> coreStatus = response.getCoreStatus(replica.coreName());
NamedList<Object> indexStats = (NamedList<Object>) coreStatus.get("index");
return (long) indexStats.get("sizeInBytes");
}
}
示例3: swapActiveCores
import org.apache.solr.client.solrj.request.CoreAdminRequest; //导入方法依赖的package包/类
@Override
public void swapActiveCores() throws ServiceException {
if (SolrContext.isSingleCoreMode()) {
LOG.debug("In single core mode. There are no cores to swap.");
} else {
LOG.debug("Swapping active cores");
CoreAdminRequest car = new CoreAdminRequest();
car.setCoreName(SolrContext.PRIMARY);
car.setOtherCoreName(SolrContext.REINDEX);
car.setAction(CoreAdminAction.SWAP);
try {
SolrContext.getAdminServer().request(car);
} catch (Exception e) {
LOG.error(e);
throw new ServiceException("Unable to swap cores", e);
}
}
}
示例4: getRemoteCores
import org.apache.solr.client.solrj.request.CoreAdminRequest; //导入方法依赖的package包/类
/**
* Get list of cores from the remote Solr server.
*
* @return Map of cores attributes keyed by core name.
* @throws SophieException
* If the list of cores cannot be fetched.
*/
@SuppressWarnings("unchecked")
public static Map<String, NamedList<Object>> getRemoteCores() throws SophieException {
CoreAdminRequest request = new CoreAdminRequest();
request.setAction(CoreAdminAction.STATUS);
try {
CoreAdminResponse response = request.process(Sophie.client);
return response.getCoreStatus().asMap(-1);
} catch (SolrServerException | IOException | SolrException e) {
throw new SophieException("Unable to fetch list of Solr cores", e);
}
}
示例5: testReloadCore
import org.apache.solr.client.solrj.request.CoreAdminRequest; //导入方法依赖的package包/类
@Test
public void testReloadCore() throws Exception {
SolrInputDocument doc = new SolrInputDocument();
doc.addField("uri", "/doc/1");
doc.addField(TITLE_FIELD, TITLE);
doc.addField(TEXT_FIELD, TEXT);
solr.add(doc);
solr.commit(false, true, true);
CoreAdminRequest reload = new CoreAdminRequest();
reload.setAction(CoreAdminAction.RELOAD);
reload.setCoreName("collection1");
reload.process(solr);
}
示例6: getCoreList
import org.apache.solr.client.solrj.request.CoreAdminRequest; //导入方法依赖的package包/类
public List<String> getCoreList() throws IOException, SolrServerException {
SolrClient solrClient = getSolrclient(null);
CoreAdminRequest coreAdminRequest = new CoreAdminRequest();
coreAdminRequest.setAction(CoreAdminParams.CoreAdminAction.STATUS);
CoreAdminResponse cores = coreAdminRequest.process(solrClient);
List<String> coreList = new ArrayList<String>();
for (int i = 0; i < cores.getCoreStatus().size(); i++) {
coreList.add(cores.getCoreStatus().getName(i));
}
return coreList;
}
示例7: checkIndexExists
import org.apache.solr.client.solrj.request.CoreAdminRequest; //导入方法依赖的package包/类
private boolean checkIndexExists(IndexConfiguration indexConfiguration) {
CoreAdminResponse cores = null;
try {
CoreAdminRequest request = new CoreAdminRequest();
request.setAction(CoreAdminAction.STATUS);
cores = request.process(solrServer);
} catch (SolrServerException | IOException e) {
throw new SolrConfigurationException("Unable to check solr indexes status", e);
}
NamedList<Object> indexStatus = cores.getCoreStatus(indexConfiguration.getName());
return indexStatus != null;
}