@Override public TransportBuffer newTransportBuffer() throws TransportException { try { return new GenericTransportBuffer(1, false, serializer); } catch (IOException e) { throw new TransportException(e); } }
@Override public TransportBuffer newTransportBuffer() throws TransportException { try { return new GenericTransportBuffer(1, false, serializer); } catch (IOException e) { throw new TransportException(e); } }
@Override public TransportBuffer newTransportBuffer() throws TransportException { try { return new GenericTransportBuffer(1, false, serializer); } catch (IOException e) { throw new TransportException(e); } }
@Override public TransportBuffer newTransportBuffer() throws TransportException { try { return new GenericTransportBuffer(1, false, serializer); } catch (IOException e) { throw new TransportException(e); } }
/** * Processes the response sent back by HTTP server. Override this method to implement custom * response processing logic. Note connection is already released when this method is called. * * @param resp Response object from server. * @param responseString Response string message from server. * @throws TransportException when HTTP call was unsuccessful. */ public void checkResponse(HttpResponse resp, String responseString) throws TransportException { /* * Check responses status code of the overall bulk call. */ if (resp.getStatusLine().getStatusCode() == HttpStatus.SC_OK) { return; } throw new TransportException( "http transport call failed because \"" + resp.getStatusLine().getReasonPhrase() + "\" payload response \"" + responseString + "\""); } }
/** * Processes the response sent back by HTTP server. Override this method to implement custom * response processing logic. Note connection is already released when this method is called. * * @param resp Response object from server. * @param responseString Response string message from server. * @throws TransportException when HTTP call was unsuccessful. */ public void checkResponse(HttpResponse resp, String responseString) throws TransportException { /* * Check responses status code of the overall bulk call. */ if (resp.getStatusLine().getStatusCode() == HttpStatus.SC_OK) { return; } throw new TransportException( "http transport call failed because \"" + resp.getStatusLine().getReasonPhrase() + "\" payload response \"" + responseString + "\""); } }
protected HttpResponse sendBatchUncompressed(HttpPost httpPost, byte[] raw) throws TransportException { HttpEntity entity = new ByteArrayEntity(raw, getUncompressedContentType()); httpPost.setEntity(entity); /* * Make call */ HttpResponse resp = null; try { resp = this.client.execute(httpPost); } catch (IOException e) { throw new TransportException("failed to make call", e); } return resp; }
protected HttpResponse sendBatchUncompressed(HttpPost httpPost, byte[] raw) throws TransportException { HttpEntity entity = new ByteArrayEntity(raw, getUncompressedContentType()); httpPost.setEntity(entity); /* * Make call */ HttpResponse resp = null; try { resp = this.client.execute(httpPost); } catch (IOException e) { throw new TransportException("failed to make call", e); } return resp; }
@Override public void sendBatch(TransportBuffer buffer) throws TransportException { FileTransportBuffer buf = (FileTransportBuffer) buffer; FileOutputStream out = null; try { out = new FileOutputStream(new File(this.filename)); out.write(buf.getInternalBuffer().toByteArray()); } catch (IOException e) { throw new TransportException("unable to write to file", e); } finally { if (out != null) { try { out.close(); } catch (IOException e) { } } } } }
@Override public void sendBatch(TransportBuffer buffer) throws TransportException { FileTransportBuffer buf = (FileTransportBuffer) buffer; FileOutputStream out = null; try { out = new FileOutputStream(new File(this.filename)); out.write(buf.getInternalBuffer().toByteArray()); } catch (IOException e) { throw new TransportException("unable to write to file", e); } finally { if (out != null) { try { out.close(); } catch (IOException e) { } } } } }
protected HttpResponse sendBatchCompressed(HttpPost httpPost, byte[] raw) throws TransportException { /* * Write gzip data to Entity and set content encoding to gzip */ ByteArrayEntity entity = new ByteArrayEntity(raw, ContentType.DEFAULT_BINARY); entity.setContentEncoding("gzip"); httpPost.addHeader(new BasicHeader("Accept-Encoding", "gzip")); httpPost.setEntity(entity); /* * Make call */ HttpResponse resp = null; try { resp = this.client.execute(httpPost); } catch (IOException e) { throw new TransportException("failed to make call", e); } return resp; }
protected HttpResponse sendBatchCompressed(HttpPost httpPost, byte[] raw) throws TransportException { /* * Write gzip data to Entity and set content encoding to gzip */ ByteArrayEntity entity = new ByteArrayEntity(raw, ContentType.DEFAULT_BINARY); entity.setContentEncoding("gzip"); httpPost.addHeader(new BasicHeader("Accept-Encoding", "gzip")); httpPost.setEntity(entity); /* * Make call */ HttpResponse resp = null; try { resp = this.client.execute(httpPost); } catch (IOException e) { throw new TransportException("failed to make call", e); } return resp; }
throw new TransportException( "es call failed because " + resp.getStatusLine().getReasonPhrase()); esResp = gson.fromJson(responseString, EsResponse.class); } catch (JsonSyntaxException e) { throw new TransportException( "es call failed because " + resp.getStatusLine().getReasonPhrase(), e); throw new TransportException( "es call failed because " + resp.getStatusLine().getReasonPhrase()); throw new TransportException("es index failure count is " + failures);
public S3TransportBuffer(long maxBytes, boolean useCompression, S3TransportSerializer serializer) throws TransportException { this.maxBytes = maxBytes; this.serializer = serializer; baos = new ByteArrayOutputStream(); cos = new CountingOutputStream(baos); if (useCompression) { this.isCompressed = true; try { os = new BZip2CompressorOutputStream(cos); } catch (IOException e) { throw new TransportException("unable to create BZip2CompressorOutputStream", e); } } else { this.isCompressed = false; os = cos; } }
throw new TransportException( "es call failed because " + resp.getStatusLine().getReasonPhrase()); esResp = gson.fromJson(responseString, EsResponse.class); } catch (JsonSyntaxException e) { throw new TransportException( "es call failed because " + resp.getStatusLine().getReasonPhrase(), e); throw new TransportException( "es call failed because " + resp.getStatusLine().getReasonPhrase()); throw new TransportException("es index failure count is " + failures);
public S3TransportBuffer(long maxBytes, boolean useCompression, S3TransportSerializer serializer) throws TransportException { this.maxBytes = maxBytes; this.serializer = serializer; baos = new ByteArrayOutputStream(); cos = new CountingOutputStream(baos); if (useCompression) { this.isCompressed = true; try { os = new BZip2CompressorOutputStream(cos); } catch (IOException e) { throw new TransportException("unable to create BZip2CompressorOutputStream", e); } } else { this.isCompressed = false; os = cos; } }
protected ByteArrayOutputStream compress(ByteArrayOutputStream raw) throws TransportException { ByteArrayOutputStream compressed = new ByteArrayOutputStream(); BZip2CompressorOutputStream bcos = null; try { bcos = new BZip2CompressorOutputStream(compressed); } catch (IOException e) { throw new TransportException("unable to open compressed stream", e); } try { raw.writeTo(bcos); bcos.flush(); } catch (IOException e) { throw new TransportException("unable to compress data", e); } finally { try { bcos.close(); } catch (IOException e) { } } return compressed; }
protected ByteArrayOutputStream compress(ByteArrayOutputStream raw) throws TransportException { ByteArrayOutputStream compressed = new ByteArrayOutputStream(); BZip2CompressorOutputStream bcos = null; try { bcos = new BZip2CompressorOutputStream(compressed); } catch (IOException e) { throw new TransportException("unable to open compressed stream", e); } try { raw.writeTo(bcos); bcos.flush(); } catch (IOException e) { throw new TransportException("unable to compress data", e); } finally { try { bcos.close(); } catch (IOException e) { } } return compressed; }
@Override public void sendBatch(TransportBuffer buffer) throws TransportException { Buffer internalBuffer = ((TcpTransportBuffer) buffer).getInternalBuffer(); Callable<Boolean> write = () -> { try { sink.write(internalBuffer, internalBuffer.size()); return true; } catch (IOException ex) { throw new TransportException("Error while sending in tcp transport", ex); } }; try { new CallExecutor(retryConfig).execute(write); } catch (RetriesExhaustedException | UnexpectedException ue) { throw new TransportException(ue); } }
send(buffer, partitions); } catch (IOException e) { throw new TransportException("Exception occurred while adding to buffer", e); buffer.add(ievent); } catch (IllegalStateException e) { throw new TransportException("Buffer is full despite being newly created", e); } catch (IOException e) { throw new TransportException("Exception ocurred while adding to buffer", e);