private void solrCommit() throws Exception { JsonObject jsonResponse = null; Exception ex = null; for (int i = 0; i < _urlUpdates.size(); i++) { try { jsonResponse = SolrTools.solrCommit(getSolrUpdateUrl(), _connectTimeout, _readTimeout); if (SolrTools.getStatus(jsonResponse) == 0) { ex = null; break; } } catch (Exception e) { ex = e; try { Thread.sleep(100); } catch (InterruptedException e1) { } } } if (ex != null) { throw ex; } if (SolrTools.getStatus(jsonResponse) != 0) { throw new RuntimeException(jsonResponse.encodePrettily()); } }
private void solrDelete(K key) throws Exception { JsonObject doc = new JsonObject(); doc.putObject("delete", (new JsonObject()).putString(SolrTools.F_ID, buildSolrId(key))); JsonObject jsonResponse = null; Exception ex = null; for (int i = 0; i < _urlUpdates.size(); i++) { try { jsonResponse = SolrTools.delDoc(getSolrUpdateUrl(), _connectTimeout, _readTimeout, doc); if (SolrTools.getStatus(jsonResponse) == 0) { ex = null; break; } } catch (Exception e) { ex = e; try { Thread.sleep(100); } catch (InterruptedException e1) { } } } if (ex != null) { throw ex; } if (SolrTools.getStatus(jsonResponse) != 0) { throw new RuntimeException(jsonResponse.encodePrettily()); } }
private void solrStore(K key, V value) throws Exception { JsonObject doc = new JsonObject(); doc.putString(SolrTools.F_ID, buildSolrId(key)); doc.putNumber(SolrTools.F_VERSION, 0); // =0 Don’t care (normal overwrite if exists) doc.putString( SolrTools.F_HZ_CTIME, SolrTools.solrDateFormat.format(new java.util.Date(System.currentTimeMillis()))); doc.putString(SolrTools.F_HZ_CLASS, value.getClass().getName()); doc.putString(SolrTools.F_HZ_DATA, JsonObject.toJson(value)); JsonObject jsonResponse = null; Exception ex = null; for (int i = 0; i < _urlUpdates.size(); i++) { try { jsonResponse = SolrTools.updateDoc(getSolrUpdateUrl(), _connectTimeout, _readTimeout, doc); if (SolrTools.getStatus(jsonResponse) == 0) { ex = null; break; } } catch (Exception e) { ex = e; try { Thread.sleep(100); } catch (InterruptedException e1) { } } } if (ex != null) { throw ex; } if (SolrTools.getStatus(jsonResponse) != 0) { throw new RuntimeException(jsonResponse.encodePrettily()); } }