Search in sources :

Example 61 with SolrException

use of org.apache.solr.common.SolrException in project lucene-solr by apache.

the class Config method getNodeList.

public NodeList getNodeList(String path, boolean errIfMissing) {
    XPath xpath = xpathFactory.newXPath();
    String xstr = normalize(path);
    try {
        NodeList nodeList = (NodeList) xpath.evaluate(xstr, doc, XPathConstants.NODESET);
        if (null == nodeList) {
            if (errIfMissing) {
                throw new RuntimeException(name + " missing " + path);
            } else {
                log.debug(name + " missing optional " + path);
                return null;
            }
        }
        log.trace(name + ":" + path + "=" + nodeList);
        return nodeList;
    } catch (XPathExpressionException e) {
        SolrException.log(log, "Error in xpath", e);
        throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Error in xpath:" + xstr + " for " + name, e);
    } catch (SolrException e) {
        throw (e);
    } catch (Exception e) {
        SolrException.log(log, "Error in xpath", e);
        throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Error in xpath:" + xstr + " for " + name, e);
    }
}
Also used : XPath(javax.xml.xpath.XPath) XPathExpressionException(javax.xml.xpath.XPathExpressionException) NodeList(org.w3c.dom.NodeList) SolrException(org.apache.solr.common.SolrException) XPathExpressionException(javax.xml.xpath.XPathExpressionException) TransformerException(javax.xml.transform.TransformerException) SolrException(org.apache.solr.common.SolrException) ParseException(java.text.ParseException) IOException(java.io.IOException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) SAXException(org.xml.sax.SAXException)

Example 62 with SolrException

use of org.apache.solr.common.SolrException in project lucene-solr by apache.

the class HdfsDirectoryFactory method size.

/**
   * @param path to calculate size of
   * @return size in bytes
   * @throws IOException on low level IO error
   */
@Override
public long size(String path) throws IOException {
    Path hdfsDirPath = new Path(path);
    FileSystem fileSystem = null;
    try {
        fileSystem = FileSystem.newInstance(hdfsDirPath.toUri(), getConf());
        long size = fileSystem.getContentSummary(hdfsDirPath).getLength();
        return size;
    } catch (IOException e) {
        LOG.error("Error checking if hdfs path exists", e);
        throw new SolrException(ErrorCode.SERVER_ERROR, "Error checking if hdfs path exists", e);
    } finally {
        IOUtils.closeQuietly(fileSystem);
    }
}
Also used : Path(org.apache.hadoop.fs.Path) FileSystem(org.apache.hadoop.fs.FileSystem) IOException(java.io.IOException) SolrException(org.apache.solr.common.SolrException)

Example 63 with SolrException

use of org.apache.solr.common.SolrException in project lucene-solr by apache.

the class CollectionsHandler method handleResponse.

private SolrResponse handleResponse(String operation, ZkNodeProps m, SolrQueryResponse rsp, long timeout) throws KeeperException, InterruptedException {
    long time = System.nanoTime();
    if (m.containsKey(ASYNC) && m.get(ASYNC) != null) {
        String asyncId = m.getStr(ASYNC);
        if (asyncId.equals("-1")) {
            throw new SolrException(ErrorCode.BAD_REQUEST, "requestid can not be -1. It is reserved for cleanup purposes.");
        }
        NamedList<String> r = new NamedList<>();
        if (coreContainer.getZkController().getOverseerCompletedMap().contains(asyncId) || coreContainer.getZkController().getOverseerFailureMap().contains(asyncId) || coreContainer.getZkController().getOverseerRunningMap().contains(asyncId) || overseerCollectionQueueContains(asyncId)) {
            r.add("error", "Task with the same requestid already exists.");
        } else {
            coreContainer.getZkController().getOverseerCollectionQueue().offer(Utils.toJSON(m));
        }
        r.add(CoreAdminParams.REQUESTID, (String) m.get(ASYNC));
        SolrResponse response = new OverseerSolrResponse(r);
        rsp.getValues().addAll(response.getResponse());
        return response;
    }
    QueueEvent event = coreContainer.getZkController().getOverseerCollectionQueue().offer(Utils.toJSON(m), timeout);
    if (event.getBytes() != null) {
        SolrResponse response = SolrResponse.deserialize(event.getBytes());
        rsp.getValues().addAll(response.getResponse());
        SimpleOrderedMap exp = (SimpleOrderedMap) response.getResponse().get("exception");
        if (exp != null) {
            Integer code = (Integer) exp.get("rspCode");
            rsp.setException(new SolrException(code != null && code != -1 ? ErrorCode.getErrorCode(code) : ErrorCode.SERVER_ERROR, (String) exp.get("msg")));
        }
        return response;
    } else {
        if (System.nanoTime() - time >= TimeUnit.NANOSECONDS.convert(timeout, TimeUnit.MILLISECONDS)) {
            throw new SolrException(ErrorCode.SERVER_ERROR, operation + " the collection time out:" + timeout / 1000 + "s");
        } else if (event.getWatchedEvent() != null) {
            throw new SolrException(ErrorCode.SERVER_ERROR, operation + " the collection error [Watcher fired on path: " + event.getWatchedEvent().getPath() + " state: " + event.getWatchedEvent().getState() + " type " + event.getWatchedEvent().getType() + "]");
        } else {
            throw new SolrException(ErrorCode.SERVER_ERROR, operation + " the collection unknown case");
        }
    }
}
Also used : OverseerSolrResponse(org.apache.solr.cloud.OverseerSolrResponse) NamedList(org.apache.solr.common.util.NamedList) QueueEvent(org.apache.solr.cloud.OverseerTaskQueue.QueueEvent) StrUtils.formatString(org.apache.solr.common.util.StrUtils.formatString) SolrResponse(org.apache.solr.client.solrj.SolrResponse) OverseerSolrResponse(org.apache.solr.cloud.OverseerSolrResponse) SimpleOrderedMap(org.apache.solr.common.util.SimpleOrderedMap) SolrException(org.apache.solr.common.SolrException)

Example 64 with SolrException

use of org.apache.solr.common.SolrException in project lucene-solr by apache.

the class CollectionsHandler method verifyRuleParams.

public static void verifyRuleParams(CoreContainer cc, Map<String, Object> m) {
    List l = (List) m.get(RULE);
    if (l != null) {
        for (Object o : l) {
            Map map = (Map) o;
            try {
                new Rule(map);
            } catch (Exception e) {
                throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Error in rule " + m, e);
            }
        }
    }
    ReplicaAssigner.verifySnitchConf(cc, (List) m.get(SNITCH));
}
Also used : ArrayList(java.util.ArrayList) NamedList(org.apache.solr.common.util.NamedList) List(java.util.List) Rule(org.apache.solr.cloud.rule.Rule) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap) SimpleOrderedMap(org.apache.solr.common.util.SimpleOrderedMap) IOException(java.io.IOException) SolrException(org.apache.solr.common.SolrException) KeeperException(org.apache.zookeeper.KeeperException) SolrException(org.apache.solr.common.SolrException)

Example 65 with SolrException

use of org.apache.solr.common.SolrException in project lucene-solr by apache.

the class CollectionsHandler method createSysConfigSet.

private static void createSysConfigSet(CoreContainer coreContainer) throws KeeperException, InterruptedException {
    SolrZkClient zk = coreContainer.getZkController().getZkStateReader().getZkClient();
    ZkCmdExecutor cmdExecutor = new ZkCmdExecutor(zk.getZkClientTimeout());
    cmdExecutor.ensureExists(ZkStateReader.CONFIGS_ZKNODE, zk);
    cmdExecutor.ensureExists(ZkStateReader.CONFIGS_ZKNODE + "/" + SYSTEM_COLL, zk);
    try {
        String path = ZkStateReader.CONFIGS_ZKNODE + "/" + SYSTEM_COLL + "/schema.xml";
        byte[] data = IOUtils.toByteArray(Thread.currentThread().getContextClassLoader().getResourceAsStream("SystemCollectionSchema.xml"));
        assert data != null && data.length > 0;
        cmdExecutor.ensureExists(path, data, CreateMode.PERSISTENT, zk);
        path = ZkStateReader.CONFIGS_ZKNODE + "/" + SYSTEM_COLL + "/solrconfig.xml";
        data = IOUtils.toByteArray(Thread.currentThread().getContextClassLoader().getResourceAsStream("SystemCollectionSolrConfig.xml"));
        assert data != null && data.length > 0;
        cmdExecutor.ensureExists(path, data, CreateMode.PERSISTENT, zk);
    } catch (IOException e) {
        throw new SolrException(ErrorCode.SERVER_ERROR, e);
    }
}
Also used : ZkCmdExecutor(org.apache.solr.common.cloud.ZkCmdExecutor) StrUtils.formatString(org.apache.solr.common.util.StrUtils.formatString) IOException(java.io.IOException) SolrZkClient(org.apache.solr.common.cloud.SolrZkClient) SolrException(org.apache.solr.common.SolrException)

Aggregations

SolrException (org.apache.solr.common.SolrException)617 IOException (java.io.IOException)172 ArrayList (java.util.ArrayList)100 ModifiableSolrParams (org.apache.solr.common.params.ModifiableSolrParams)80 NamedList (org.apache.solr.common.util.NamedList)79 HashMap (java.util.HashMap)75 Map (java.util.Map)70 SolrParams (org.apache.solr.common.params.SolrParams)64 KeeperException (org.apache.zookeeper.KeeperException)60 Test (org.junit.Test)55 Replica (org.apache.solr.common.cloud.Replica)48 Slice (org.apache.solr.common.cloud.Slice)45 DocCollection (org.apache.solr.common.cloud.DocCollection)41 SolrInputDocument (org.apache.solr.common.SolrInputDocument)39 SchemaField (org.apache.solr.schema.SchemaField)39 List (java.util.List)38 SimpleOrderedMap (org.apache.solr.common.util.SimpleOrderedMap)38 SolrServerException (org.apache.solr.client.solrj.SolrServerException)37 SolrQueryRequest (org.apache.solr.request.SolrQueryRequest)34 SolrCore (org.apache.solr.core.SolrCore)33