org.apache.http.nio.util.HeapByteBufferAllocator Java Examples
The following examples show how to use
org.apache.http.nio.util.HeapByteBufferAllocator.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SimpleInputBufferPooledObjectOpsTest.java From log4j2-elasticsearch with Apache License 2.0 | 6 votes |
@Test public void createsItemSource() { // given SimpleInputBufferPooledObjectOps ops = new SimpleInputBufferPooledObjectOps( HeapByteBufferAllocator.INSTANCE, TEST_BUFFER_SIZE ); // when ItemSource result = ops.createItemSource(mock(ReleaseCallback.class)); // then assertNotNull(result); }
Example #2
Source File: SimpleInputBufferPooledObjectOpsTest.java From log4j2-elasticsearch with Apache License 2.0 | 6 votes |
@Test public void purgeDoesNotAffectItemSource() { // given SimpleInputBufferPooledObjectOps ops = new SimpleInputBufferPooledObjectOps( HeapByteBufferAllocator.INSTANCE, TEST_BUFFER_SIZE ); ItemSource result = spy(ops.createItemSource(mock(ReleaseCallback.class))); // when ops.purge(result); // then verifyNoMoreInteractions(result); }
Example #3
Source File: SimpleInputBufferPooledObjectOpsTest.java From log4j2-elasticsearch with Apache License 2.0 | 6 votes |
@Test public void resetDelegatesToUnderlyingItem() { // given SimpleInputBufferPooledObjectOps ops = new SimpleInputBufferPooledObjectOps( HeapByteBufferAllocator.INSTANCE, TEST_BUFFER_SIZE ); ItemSource<SimpleInputBuffer> result = spy(ops.createItemSource(source -> {})); SimpleInputBuffer simpleInputBuffer = mock(SimpleInputBuffer.class); when(result.getSource()).thenReturn(simpleInputBuffer); // when ops.reset(result); // then verify(simpleInputBuffer).reset(); }
Example #4
Source File: SimpleInputBufferPooledObjectOpsTest.java From log4j2-elasticsearch with Apache License 2.0 | 6 votes |
@Test public void metricsSupplierReturnsNull() { // given SimpleInputBufferPooledObjectOps ops = new SimpleInputBufferPooledObjectOps( HeapByteBufferAllocator.INSTANCE, TEST_BUFFER_SIZE ); Supplier<String> metricsSupplier = ops.createMetricsSupplier(); // when String result = metricsSupplier.get(); // then assertNull(result); }
Example #5
Source File: SimpleInputBufferObjectOpsTest.java From log4j2-elasticsearch with Apache License 2.0 | 6 votes |
public static GenericItemSourcePool<SimpleInputBuffer> createDefaultTestGenericItemSourcePool( int initialSize, boolean monitored, ResizePolicy resizePolicy ) { SimpleInputBufferPooledObjectOps pooledObjectOps = new SimpleInputBufferPooledObjectOps( HeapByteBufferAllocator.INSTANCE, DEFAULT_TEST_ITEM_SIZE_IN_BYTES); return new GenericItemSourcePool<>( DEFAULT_TEST_ITEM_POOL_NAME, pooledObjectOps, resizePolicy, DEFAULT_TEST_RESIZE_TIMEOUT, monitored, DEFAULT_TEST_MONITOR_TASK_INTERVAL, initialSize ); }
Example #6
Source File: AsyncHTTPConduit.java From cxf with Apache License 2.0 | 6 votes |
public AsyncWrappedOutputStream(Message message, boolean needToCacheRequest, boolean isChunking, int chunkThreshold, String conduitName, URI uri) { super(message, needToCacheRequest, isChunking, chunkThreshold, conduitName, uri); csPolicy = getClient(message); entity = message.get(CXFHttpRequest.class); basicEntity = (BasicHttpEntity)entity.getEntity(); basicEntity.setChunked(isChunking); HeapByteBufferAllocator allocator = new HeapByteBufferAllocator(); int bufSize = csPolicy.getChunkLength() > 0 ? csPolicy.getChunkLength() : 16320; inbuf = new SharedInputBuffer(bufSize, allocator); outbuf = new SharedOutputBuffer(bufSize, allocator); isAsync = outMessage != null && outMessage.getExchange() != null && !outMessage.getExchange().isSynchronous(); }
Example #7
Source File: HL7EndpointManager.java From micro-integrator with Apache License 2.0 | 5 votes |
@Override public boolean startListener(int port, String name, InboundProcessorParams params) { log.info("Starting HL7 Inbound Endpoint on port " + port); Map<String, Object> parameters = new HashMap<String, Object>(); parameters.put(MLLPConstants.INBOUND_PARAMS, params); parameters.put(MLLPConstants.INBOUND_HL7_BUFFER_FACTORY, new BufferFactory(8 * 1024, new HeapByteBufferAllocator(), 1024)); validateParameters(params, parameters); HL7Processor hl7Processor = new HL7Processor(parameters); parameters.put(MLLPConstants.HL7_REQ_PROC, hl7Processor); return InboundHL7IOReactor.bind(port, hl7Processor); }
Example #8
Source File: AbstractResponseConsumer.java From fc-java-sdk with MIT License | 5 votes |
protected void onEntityEnclosed(HttpEntity entity, ContentType contentType) throws IOException { long len = entity.getContentLength(); if (len > 2147483647L) { throw new ContentTooLongException("Entity content is too long: " + len); } else { if (len < 0L) { len = 4096L; } this.buf = new SimpleInputBuffer((int)len, new HeapByteBufferAllocator()); this.httpResponse.setEntity(new ContentBufferEntity(entity, this.buf)); } }
Example #9
Source File: HttpClientFactory.java From log4j2-elasticsearch with Apache License 2.0 | 5 votes |
private GenericItemSourcePool<SimpleInputBuffer> createPool() { GenericItemSourcePool<SimpleInputBuffer> bufferPool = new GenericItemSourcePool<>( "hc-responseBufferPool", new SimpleInputBufferPooledObjectOps( HeapByteBufferAllocator.INSTANCE, pooledResponseBuffersSizeInBytes ), new UnlimitedResizePolicy.Builder().withResizeFactor(0.5).build(), 1000L, false, 30000, maxTotalConnections ); return bufferPool; }
Example #10
Source File: ResponseConsumer.java From aliyun-tablestore-java-sdk with Apache License 2.0 | 5 votes |
@Override protected void onEntityEnclosed(final HttpEntity entity, final ContentType contentType) throws IOException { long len = entity.getContentLength(); if (len > Integer.MAX_VALUE) { throw new ContentTooLongException("Entity content is too long: " + len); } if (len < 0) { len = BUFFER_SIZE; } this.buf = new SimpleInputBuffer((int) len, new HeapByteBufferAllocator()); this.httpResponse.setEntity(new ContentBufferEntity(entity, this.buf)); }
Example #11
Source File: AsyncHTTPConduit.java From cxf with Apache License 2.0 | 5 votes |
protected void setupNewConnection(String newURL) throws IOException { httpResponse = null; isAsync = outMessage != null && outMessage.getExchange() != null && !outMessage.getExchange().isSynchronous(); exception = null; connectionFuture = null; session = null; sslState = null; sslURL = null; //reset the buffers HeapByteBufferAllocator allocator = new HeapByteBufferAllocator(); int bufSize = csPolicy.getChunkLength() > 0 ? csPolicy.getChunkLength() : 16320; inbuf = new SharedInputBuffer(bufSize, allocator); outbuf = new SharedOutputBuffer(bufSize, allocator); try { if (defaultAddress.getString().equals(newURL)) { setupConnection(outMessage, defaultAddress, csPolicy); } else { Address address = new Address(newURL); this.url = address.getURI(); setupConnection(outMessage, address, csPolicy); } entity = outMessage.get(CXFHttpRequest.class); basicEntity = (BasicHttpEntity)entity.getEntity(); entity.setOutputStream(this); } catch (URISyntaxException e) { throw new IOException(e); } }
Example #12
Source File: SimpleInputBufferObjectOpsTest.java From log4j2-elasticsearch with Apache License 2.0 | 4 votes |
public static SimpleInputBufferPooledObjectOps createDefaultTestObject() { return new SimpleInputBufferPooledObjectOps(HeapByteBufferAllocator.INSTANCE, DEFAULT_TEST_ITEM_SIZE_IN_BYTES); }