当前位置: 首页>>代码示例>>Java>>正文


Java HttpSolrServer.RemoteSolrException方法代码示例

本文整理汇总了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;
}
 
开发者ID:felixhusse,项目名称:bookery,代码行数:17,代码来源:SolrHandler.java

示例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);
    }
}
 
开发者ID:felixhusse,项目名称:bookery,代码行数:18,代码来源:BookeryService.java

示例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;
    }
}
 
开发者ID:graben1437,项目名称:titan0.5.4-hbase1.1.1-custom,代码行数:19,代码来源:SolrIndex.java

示例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);
}
 
开发者ID:europeana,项目名称:search,代码行数:36,代码来源:DeleteShardTest.java

示例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);
  }
}
 
开发者ID:streamsets,项目名称:datacollector,代码行数:15,代码来源:SolrTarget04.java

示例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();
}
 
开发者ID:europeana,项目名称:search,代码行数:79,代码来源:ShardSplitTest.java


注:本文中的org.apache.solr.client.solrj.impl.HttpSolrServer.RemoteSolrException方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。