List of usage examples for org.apache.cassandra.utils ConcurrentBiMap keySet
public Set<K> keySet()
From source file:org.jesterj.ingest.processors.ElasticNodeSender.java
License:Apache License
@Override protected void perDocumentFailure(ConcurrentBiMap<Document, ActionRequest> oldBatch, Exception e) { // something's wrong with the network etc all documents must be errored out: for (Document doc : oldBatch.keySet()) { ThreadContext.put(JesterJAppender.JJ_INGEST_DOCID, doc.getId()); log.info(Status.ERROR.getMarker(), "{} could not be sent to elastic because of {}", doc.getId(), e.getMessage());//from ww w . jav a 2 s .c o m log.error("Error communicating with elastic!", e); } }
From source file:org.jesterj.ingest.processors.ElasticSender.java
License:Apache License
@Override protected void batchOperation(ConcurrentBiMap<Document, ActionRequest> oldBatch) throws Exception { BulkRequestBuilder builder = getClient().prepareBulk(); for (ActionRequest request : oldBatch.values()) { if (request instanceof UpdateRequest) { builder.add((UpdateRequest) request); } else if (request instanceof DeleteRequest) { builder.add((DeleteRequest) request); } else if (request instanceof IndexRequest) { builder.add((IndexRequest) request); } else {/*from www .j a v a 2 s . c om*/ throw new IllegalStateException("Should only have generated index, update and delete " + "actions, but found" + request.getClass()); } } BulkResponse bulkResponse = builder.get(); if (bulkResponse.hasFailures()) { throw new ESBulkFail(); } else { for (Document doc : oldBatch.keySet()) { log.info("Successfully sent {} to elastic", doc.getId()); } } }
From source file:org.jesterj.ingest.processors.SendToSolrCloudProcessor.java
License:Apache License
@Override protected void perDocumentFailure(ConcurrentBiMap<Document, SolrInputDocument> oldBatch, Exception e) { // something's wrong with the network all documents must be errored out: for (Document doc : oldBatch.keySet()) { ThreadContext.put(JesterJAppender.JJ_INGEST_DOCID, doc.getId()); log.info(Status.ERROR.getMarker(), "{} could not be sent to solr because of {}", doc.getId(), e.getMessage());//from w ww . j av a 2s . c o m log.error("Error communicating with solr!", e); } }
From source file:org.jesterj.ingest.processors.SendToSolrCloudProcessor.java
License:Apache License
@Override protected void individualFallbackOperation(ConcurrentBiMap<Document, SolrInputDocument> oldBatch, Exception e) { // TODO: send in bisected batches to avoid massive traffic down due to one doc when batches are large for (Document document : oldBatch.keySet()) { ThreadContext.put(JesterJAppender.JJ_INGEST_DOCID, document.getId()); try {/*from w w w . j a v a 2 s .co m*/ SolrInputDocument doc = oldBatch.get(document); if (doc instanceof Delete) { solrClient.deleteById(oldBatch.inverse().get(doc).getId()); log.info(Status.INDEXED.getMarker(), "{} deleted from solr successfully", document.getId()); } else { solrClient.add(doc); log.info(Status.INDEXED.getMarker(), "{} sent to solr successfully", document.getId()); } } catch (IOException | SolrServerException e1) { log.info(Status.ERROR.getMarker(), "{} could not be sent to solr because of {}", document.getId(), e1.getMessage()); log.error("Error sending to with solr!", e1); } } }
From source file:org.jesterj.ingest.processors.SendToSolrCloudProcessor.java
License:Apache License
@Override protected void batchOperation(ConcurrentBiMap<Document, SolrInputDocument> oldBatch) throws SolrServerException, IOException { List<String> deletes = oldBatch.keySet().stream() .filter(doc -> doc.getOperation() == Document.Operation.DELETE).map(Document::getId) .collect(Collectors.toList()); if (deletes.size() > 0) { solrClient.deleteById(deletes);/*from w ww .ja va2 s . c om*/ } List<SolrInputDocument> adds = oldBatch.keySet().stream() .filter(doc -> doc.getOperation() != Document.Operation.DELETE).map(oldBatch::get) .collect(Collectors.toList()); if (adds.size() > 0) { solrClient.add(adds); } for (Document document : oldBatch.keySet()) { ThreadContext.put(JesterJAppender.JJ_INGEST_DOCID, document.getId()); if (document.getOperation() == Document.Operation.DELETE) { log.info(Status.INDEXED.getMarker(), "{} deleted from solr successfully", document.getId()); } else { log.info(Status.INDEXED.getMarker(), "{} sent to solr successfully", document.getId()); } } }