@Override public void safeStop() { stop = true; suss.blockUntilFinished(); suss.shutdownNow(); httpClient.getConnectionManager().shutdown(); }
@Override public void run() { int i = 0; int numDeletes = 0; int numAdds = 0; while (true && !stop) { String id = this.id + "-" + i; ++i; if (doDeletes && random().nextBoolean() && deletes.size() > 0) { String delete = deletes.remove(0); try { numDeletes++; suss.deleteById(delete); } catch (Exception e) { changeUrlOnError(e); // System.err.println("REQUEST FAILED:"); // e.printStackTrace(); fails.incrementAndGet(); } } try { numAdds++; if (numAdds > 4000) continue; SolrInputDocument doc = getDoc( "id", id, i1, 50, t1, "Saxon heptarchies that used to rip around so in old times and raise Cain. My, you ought to seen old Henry the Eight when he was in bloom. He WAS a blossom. He used to marry a new wife every day, and chop off her head next morning. And he would do it just as indifferent as if "); suss.add(doc); } catch (Exception e) { changeUrlOnError(e); // System.err.println("REQUEST FAILED:"); // e.printStackTrace(); fails.incrementAndGet(); } if (doDeletes && random().nextBoolean()) { deletes.add(id); } } System.err.println( "FT added docs:" + numAdds + " with " + fails + " fails" + " deletes:" + numDeletes); }
private void changeUrlOnError(Exception e) { if (e instanceof ConnectException) { clientIndex++; if (clientIndex > clients.size() - 1) { clientIndex = 0; } suss.shutdownNow(); suss = new ConcurrentUpdateSolrServer( ((HttpSolrServer) clients.get(clientIndex)).getBaseURL(), httpClient, 30, 3) { @Override public void handleError(Throwable ex) { log.warn("suss error", ex); } }; } }