public void log(Logger log) { log(log,this); } public static void log(Logger log, Throwable e) {
public void log(Logger log) { log(log,this); } public static void log(Logger log, Throwable e) {
public void log(Logger log) { log(log,this); } public static void log(Logger log, Throwable e) {
public void test(boolean condition) { try { if (!condition) { throw new RuntimeException("test requestHandler: assertion failed!"); } } catch (RuntimeException e) { SolrException.log(log,e); throw(e); } }
final void sendErr(int rc, String msg, HttpServletRequest request, HttpServletResponse response) { try { // hmmm, what if this was already set to text/xml? try{ response.setContentType(QueryResponseWriter.CONTENT_TYPE_TEXT_UTF8); // response.setCharacterEncoding("UTF-8"); } catch (Exception e) {} try{response.setStatus(rc);} catch (Exception e) {} PrintWriter writer = response.getWriter(); writer.write(msg); } catch (IOException e) { SolrException.log(log,e); } } }
public synchronized void disconnected() { for (DisconnectedListener listener : disconnectedListeners) { try { listener.disconnected(); } catch (Exception e) { SolrException.log(log, "", e); } } }
public synchronized void connected() { for (ConnectedListener listener : connectedListeners) { try { listener.connected(); } catch (Exception e) { SolrException.log(log, "", e); } } }
private void closeCallbackExecutor() { try { ExecutorUtil.shutdownAndAwaitTermination(zkCallbackExecutor); } catch (Exception e) { SolrException.log(log, e); } }
public SolrCache newInstance() { try { SolrCache cache = (SolrCache)clazz.newInstance(); persistence[0] = cache.init(args, persistence[0], regenerator); return cache; } catch (Exception e) { SolrException.log(SolrCache.log,"Error instantiating cache",e); // we can carry on without a cache... but should we? // in some cases (like an OOM) we probably should try to continue. return null; } }
public synchronized void connected() { for (ConnectedListener listener : connectedListeners) { try { listener.connected(); } catch (Exception e) { SolrException.log(log, "", e); } } }
public synchronized void disconnected() { for (DisconnectedListener listener : disconnectedListeners) { try { listener.disconnected(); } catch (Exception e) { SolrException.log(log, "", e); } } }
private Map<String,Object> getNextFromCache(String query, Iterator<Map<String,Object>> rowIterator) { try { if (rowIterator == null) return null; if (rowIterator.hasNext()) return rowIterator.next(); return null; } catch (Exception e) { SolrException.log(log, "getNextFromCache() failed for query '" + query + "'", e); wrapAndThrow(DataImportHandlerException.WARN, e); return null; } }
/** * Return a registered {@link RefCounted}<{@link SolrIndexSearcher}> with * the reference count incremented. It <b>must</b> be decremented when no longer needed. * This method should not be called from SolrCoreAware.inform() since it can result * in a deadlock if useColdSearcher==false. * If handling a normal request, the searcher should be obtained from * {@link org.apache.solr.request.SolrQueryRequest#getSearcher()} instead. */ public RefCounted<SolrIndexSearcher> getSearcher() { try { return getSearcher(false,true,null); } catch (IOException e) { SolrException.log(log,null,e); return null; } }
public Tuple read() { if(openException != null) { //There was an exception during the open. Map fields = new HashMap(); fields.put("EXCEPTION", openException.getMessage()); fields.put("EOF", true); SolrException.log(log, openException); return new Tuple(fields); } try { return stream.read(); } catch (Exception e) { Map fields = new HashMap(); fields.put("EXCEPTION", e.getMessage()); fields.put("EOF", true); SolrException.log(log, e); return new Tuple(fields); } }
public Node getNode(String path, boolean errIfMissing) { XPath xpath = xpathFactory.newXPath(); Node nd = null; String xstr = normalize(path); try { nd = (Node)xpath.evaluate(xstr, doc, XPathConstants.NODE); if (nd==null) { if (errIfMissing) { throw new RuntimeException(name + " missing "+path); } else { log.debug(name + " missing optional " + path); return null; } } log.trace(name + ":" + path + "=" + nd); return nd; } catch (XPathExpressionException e) { SolrException.log(log,"Error in xpath",e); throw new SolrException( SolrException.ErrorCode.SERVER_ERROR,"Error in xpath:" + xstr + " for " + name,e,false); } catch (SolrException e) { throw(e); } catch (Throwable e) { SolrException.log(log,"Error in xpath",e); throw new SolrException( SolrException.ErrorCode.SERVER_ERROR,"Error in xpath:" + xstr+ " for " + name,e,false); } }
@Override public void reconnect(final String serverAddress, final int zkClientTimeout, final Watcher watcher, final ZkUpdate updater) throws IOException { log.warn("Connection expired - starting a new one..."); SolrZooKeeper zk = createSolrZooKeeper(serverAddress, zkClientTimeout, watcher); boolean success = false; try { updater .update(zk); success = true; log.info("Reconnected to ZooKeeper"); } catch (Exception e) { SolrException.log(log, "Reconnect to ZooKeeper failed", e); log.warn("Reconnect to ZooKeeper failed"); } finally { if (!success) { try { zk.close(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } } } }
@Override public void close() { try { processor.finish(); } catch (IOException e) { throw new DataImportHandlerException(DataImportHandlerException.SEVERE, "Unable to call finish() on UpdateRequestProcessor", e); } finally { deltaKeys = null; try { processor.close(); } catch (IOException e) { SolrException.log(log, e); } } } @Override
public void doFullImport(DIHWriter writer, RequestInfo requestParams) { log.info("Starting Full Import"); setStatus(Status.RUNNING_FULL_DUMP); try { DIHProperties dihPropWriter = createPropertyWriter(); setIndexStartTime(dihPropWriter.getCurrentTimestamp()); docBuilder = new DocBuilder(this, writer, dihPropWriter, requestParams); checkWritablePersistFile(writer, dihPropWriter); docBuilder.execute(); if (!requestParams.isDebug()) cumulativeStatistics.add(docBuilder.importStatistics); } catch (Exception e) { SolrException.log(log, "Full Import failed", e); docBuilder.handleError("Full Import failed", e); } finally { setStatus(Status.IDLE); DocBuilder.INSTANCE.set(null); } }