本文整理汇总了Java中org.apache.solr.client.solrj.impl.HttpSolrServer.RemoteSolrException方法的典型用法代码示例。如果您正苦于以下问题:Java HttpSolrServer.RemoteSolrException方法的具体用法?Java HttpSolrServer.RemoteSolrException怎么用?Java HttpSolrServer.RemoteSolrException使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.solr.client.solrj.impl.HttpSolrServer
的用法示例。
在下文中一共展示了HttpSolrServer.RemoteSolrException方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDatasetCount
import org.apache.solr.client.solrj.impl.HttpSolrServer; //导入方法依赖的package包/类
public long getDatasetCount() throws SearchException{
SolrQuery solrQuery = new SolrQuery();
solrQuery.setQuery("*:*");
solrQuery.setFilterQueries(SearchFields.TYPE+":datasets",
SearchFields.PUBLICATION_STATUS+":Published");
solrQuery.setStart(0);
solrQuery.setRows(0);
QueryResponse queryResponse = null;
try {
queryResponse = solrServer.query(solrQuery);
return queryResponse.getResults().getNumFound();
} catch (HttpSolrServer.RemoteSolrException | SolrServerException ex) {
logger.log(Level.INFO, null, ex);
throw new SearchException("Internal Dataverse Search Engine Error", ex);
}
}
开发者ID:pengchengluo,项目名称:Peking-University-Open-Research-Data-Platform,代码行数:17,代码来源:SolrSearchServiceBean.java
示例2: getDataverseCount
import org.apache.solr.client.solrj.impl.HttpSolrServer; //导入方法依赖的package包/类
public long getDataverseCount() throws SearchException{
SolrQuery solrQuery = new SolrQuery();
solrQuery.setQuery("*:*");
solrQuery.setFilterQueries(SearchFields.TYPE+":dataverses",
SearchFields.PUBLICATION_STATUS+":Published");
solrQuery.setStart(0);
solrQuery.setRows(0);
QueryResponse queryResponse = null;
try {
queryResponse = solrServer.query(solrQuery);
return queryResponse.getResults().getNumFound();
} catch (HttpSolrServer.RemoteSolrException | SolrServerException ex) {
logger.log(Level.INFO, null, ex);
throw new SearchException("Internal Dataverse Search Engine Error", ex);
}
}
开发者ID:pengchengluo,项目名称:Peking-University-Open-Research-Data-Platform,代码行数:17,代码来源:SolrSearchServiceBean.java
示例3: createConnection
import org.apache.solr.client.solrj.impl.HttpSolrServer; //导入方法依赖的package包/类
public static SolrServer createConnection(String solrURL, String solrCore) throws SolrServerException, IOException {
if (!solrURL.endsWith("/")) {
solrURL = solrURL + "/";
}
HttpSolrServer solrServer = new HttpSolrServer(solrURL + solrCore);
try {
if (solrServer.ping().getStatus()!=0) {
throw new SolrServerException("Solr Server not found! ");
}
} catch (HttpSolrServer.RemoteSolrException ex) {
throw new SolrServerException(ex.getMessage(),ex);
}
return solrServer;
}
示例4: updateConfiguration
import org.apache.solr.client.solrj.impl.HttpSolrServer; //导入方法依赖的package包/类
public void updateConfiguration() throws SolrServerException, IOException {
String solrURL = settingDAO.findByKey(SettingKey.SOLR_URL).getConfigurationValue();
String solrCore = settingDAO.findByKey(SettingKey.SOLR_CORE).getConfigurationValue();
if (!solrURL.endsWith("/")) {
solrURL = solrURL + "/";
}
solrServer = new HttpSolrServer(solrURL + solrCore);
try {
if (solrServer.ping().getStatus()!=0) {
throw new SolrServerException("Solr Server not found! ");
}
} catch (HttpSolrServer.RemoteSolrException ex) {
throw new SolrServerException(ex.getMessage(),ex);
}
}
示例5: commitDocumentChanges
import org.apache.solr.client.solrj.impl.HttpSolrServer; //导入方法依赖的package包/类
private void commitDocumentChanges(String collectionName, Collection<SolrInputDocument> documents) throws SolrServerException, IOException {
if (documents.size() == 0) return;
try {
solrServer.request(newUpdateRequest(collectionName).add(documents));
} catch (HttpSolrServer.RemoteSolrException rse) {
logger.error("Unable to save documents to Solr as one of the shape objects stored were not compatible with Solr.", rse);
logger.error("Details in failed document batch: ");
for (SolrInputDocument d : documents) {
Collection<String> fieldNames = d.getFieldNames();
for (String name : fieldNames) {
logger.error(name + ":" + d.getFieldValue(name).toString());
}
}
throw rse;
}
}
示例6: doTest
import org.apache.solr.client.solrj.impl.HttpSolrServer; //导入方法依赖的package包/类
@Override
public void doTest() throws Exception {
ClusterState clusterState = cloudClient.getZkStateReader().getClusterState();
Slice slice1 = clusterState.getSlice(AbstractDistribZkTestBase.DEFAULT_COLLECTION, SHARD1);
Slice slice2 = clusterState.getSlice(AbstractDistribZkTestBase.DEFAULT_COLLECTION, SHARD2);
assertNotNull("Shard1 not found", slice1);
assertNotNull("Shard2 not found", slice2);
assertEquals("Shard1 is not active", Slice.ACTIVE, slice1.getState());
assertEquals("Shard2 is not active", Slice.ACTIVE, slice2.getState());
try {
deleteShard(SHARD1);
fail("Deleting an active shard should not have succeeded");
} catch (HttpSolrServer.RemoteSolrException e) {
// expected
}
setSliceState(SHARD1, Slice.INACTIVE);
clusterState = cloudClient.getZkStateReader().getClusterState();
slice1 = clusterState.getSlice(AbstractDistribZkTestBase.DEFAULT_COLLECTION, SHARD1);
assertEquals("Shard1 is not inactive yet.", Slice.INACTIVE, slice1.getState());
deleteShard(SHARD1);
confirmShardDeletion(SHARD1);
setSliceState(SHARD2, Slice.CONSTRUCTION);
deleteShard(SHARD2);
confirmShardDeletion(SHARD2);
}
示例7: add
import org.apache.solr.client.solrj.impl.HttpSolrServer; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public void add(List<Map<String, Object>> fieldMaps) throws StageException {
List<SolrInputDocument> documents = new ArrayList();
for(Map<String, Object> fieldMap : fieldMaps) {
SolrInputDocument document = createDocument(fieldMap);
documents.add(document);
}
try {
this.solrClient.add(documents);
} catch (SolrServerException | IOException | HttpSolrServer.RemoteSolrException ex) {
throw new StageException(Errors.SOLR_04, ex.toString(), ex);
}
}
示例8: splitByRouteFieldTest
import org.apache.solr.client.solrj.impl.HttpSolrServer; //导入方法依赖的package包/类
public void splitByRouteFieldTest() throws Exception {
log.info("Starting testSplitWithRouteField");
String collectionName = "routeFieldColl";
int numShards = 4;
int replicationFactor = 2;
int maxShardsPerNode = (((numShards * replicationFactor) / getCommonCloudSolrServer()
.getZkStateReader().getClusterState().getLiveNodes().size())) + 1;
HashMap<String, List<Integer>> collectionInfos = new HashMap<>();
CloudSolrServer client = null;
String shard_fld = "shard_s";
try {
client = createCloudClient(null);
Map<String, Object> props = ZkNodeProps.makeMap(
REPLICATION_FACTOR, replicationFactor,
MAX_SHARDS_PER_NODE, maxShardsPerNode,
NUM_SLICES, numShards,
"router.field", shard_fld);
createCollection(collectionInfos, collectionName,props,client);
} finally {
if (client != null) client.shutdown();
}
List<Integer> list = collectionInfos.get(collectionName);
checkForCollection(collectionName, list, null);
waitForRecoveriesToFinish(false);
String url = CustomCollectionTest.getUrlFromZk(getCommonCloudSolrServer().getZkStateReader().getClusterState(), collectionName);
HttpSolrServer collectionClient = new HttpSolrServer(url);
ClusterState clusterState = cloudClient.getZkStateReader().getClusterState();
final DocRouter router = clusterState.getCollection(collectionName).getRouter();
Slice shard1 = clusterState.getSlice(collectionName, SHARD1);
DocRouter.Range shard1Range = shard1.getRange() != null ? shard1.getRange() : router.fullRange();
final List<DocRouter.Range> ranges = router.partitionRange(2, shard1Range);
final int[] docCounts = new int[ranges.size()];
for (int i = 100; i <= 200; i++) {
String shardKey = "" + (char)('a' + (i % 26)); // See comment in ShardRoutingTest for hash distribution
collectionClient.add(getDoc(id, i, "n_ti", i, shard_fld, shardKey));
int idx = getHashRangeIdx(router, ranges, shardKey);
if (idx != -1) {
docCounts[idx]++;
}
}
for (int i = 0; i < docCounts.length; i++) {
int docCount = docCounts[i];
log.info("Shard {} docCount = {}", "shard1_" + i, docCount);
}
collectionClient.commit();
for (int i = 0; i < 3; i++) {
try {
splitShard(collectionName, SHARD1, null, null);
break;
} catch (HttpSolrServer.RemoteSolrException e) {
if (e.code() != 500) {
throw e;
}
log.error("SPLITSHARD failed. " + (i < 2 ? " Retring split" : ""), e);
if (i == 2) {
fail("SPLITSHARD was not successful even after three tries");
}
}
}
waitForRecoveriesToFinish(collectionName, false);
assertEquals(docCounts[0], collectionClient.query(new SolrQuery("*:*").setParam("shards", "shard1_0")).getResults().getNumFound());
assertEquals(docCounts[1], collectionClient.query(new SolrQuery("*:*").setParam("shards", "shard1_1")).getResults().getNumFound());
collectionClient.shutdown();
}