org.apache.flink.shaded.netty4.io.netty.buffer.UnpooledByteBufAllocator Java Examples
The following examples show how to use
org.apache.flink.shaded.netty4.io.netty.buffer.UnpooledByteBufAllocator.
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: PartitionRequestClientHandlerTest.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
/** * Returns a deserialized buffer message as it would be received during runtime. */ static BufferResponse createBufferResponse( Buffer buffer, int sequenceNumber, InputChannelID receivingChannelId, int backlog) throws IOException { // Mock buffer to serialize BufferResponse resp = new BufferResponse(buffer, sequenceNumber, receivingChannelId, backlog); ByteBuf serialized = resp.write(UnpooledByteBufAllocator.DEFAULT); // Skip general header bytes serialized.readBytes(NettyMessage.FRAME_HEADER_LENGTH); // Deserialize the bytes again. We have to go this way, because we only partly deserialize // the header of the response and wait for a buffer from the buffer pool to copy the payload // data into. BufferResponse deserialized = BufferResponse.readFrom(serialized); return deserialized; }
Example #2
Source File: PartitionRequestClientHandlerTest.java From flink with Apache License 2.0 | 6 votes |
/** * Returns a deserialized buffer message as it would be received during runtime. */ static BufferResponse createBufferResponse( Buffer buffer, int sequenceNumber, InputChannelID receivingChannelId, int backlog) throws IOException { // Mock buffer to serialize BufferResponse resp = new BufferResponse(buffer, sequenceNumber, receivingChannelId, backlog); ByteBuf serialized = resp.write(UnpooledByteBufAllocator.DEFAULT); // Skip general header bytes serialized.readBytes(NettyMessage.FRAME_HEADER_LENGTH); // Deserialize the bytes again. We have to go this way, because we only partly deserialize // the header of the response and wait for a buffer from the buffer pool to copy the payload // data into. BufferResponse deserialized = BufferResponse.readFrom(serialized); return deserialized; }
Example #3
Source File: CreditBasedPartitionRequestClientHandlerTest.java From flink with Apache License 2.0 | 6 votes |
/** * Returns a deserialized buffer message as it would be received during runtime. */ private static BufferResponse createBufferResponse( Buffer buffer, int sequenceNumber, InputChannelID receivingChannelId, int backlog, NetworkBufferAllocator allocator) throws IOException { // Mock buffer to serialize BufferResponse resp = new BufferResponse(buffer, sequenceNumber, receivingChannelId, backlog); ByteBuf serialized = resp.write(UnpooledByteBufAllocator.DEFAULT); // Skip general header bytes serialized.readBytes(NettyMessage.FRAME_HEADER_LENGTH); // Deserialize the bytes to construct the BufferResponse. return BufferResponse.readFrom(serialized, allocator); }
Example #4
Source File: SSLUtilsTest.java From flink with Apache License 2.0 | 5 votes |
/** * Tests that {@link SSLHandlerFactory} is created correctly. */ @Test public void testCreateSSLEngineFactory() throws Exception { Configuration serverConfig = createInternalSslConfigWithKeyAndTrustStores(); final String[] sslAlgorithms; final String[] expectedSslProtocols; if (sslProvider.equalsIgnoreCase("OPENSSL")) { // openSSL does not support the same set of cipher algorithms! sslAlgorithms = new String[] {"TLS_RSA_WITH_AES_128_GCM_SHA256", "TLS_RSA_WITH_AES_256_GCM_SHA384"}; expectedSslProtocols = new String[] {"SSLv2Hello", "TLSv1"}; } else { sslAlgorithms = new String[] {"TLS_DHE_RSA_WITH_AES_128_CBC_SHA", "TLS_DHE_RSA_WITH_AES_128_CBC_SHA256"}; expectedSslProtocols = new String[] {"TLSv1"}; } // set custom protocol and cipher suites serverConfig.setString(SecurityOptions.SSL_PROTOCOL, "TLSv1"); serverConfig.setString(SecurityOptions.SSL_ALGORITHMS, String.join(",", sslAlgorithms)); final SSLHandlerFactory serverSSLHandlerFactory = SSLUtils.createInternalServerSSLEngineFactory(serverConfig); final SslHandler sslHandler = serverSSLHandlerFactory.createNettySSLHandler(UnpooledByteBufAllocator.DEFAULT); assertEquals(expectedSslProtocols.length, sslHandler.engine().getEnabledProtocols().length); assertThat( sslHandler.engine().getEnabledProtocols(), arrayContainingInAnyOrder(expectedSslProtocols)); assertEquals(sslAlgorithms.length, sslHandler.engine().getEnabledCipherSuites().length); assertThat( sslHandler.engine().getEnabledCipherSuites(), arrayContainingInAnyOrder(sslAlgorithms)); }
Example #5
Source File: SSLUtilsTest.java From flink with Apache License 2.0 | 5 votes |
/** * Tests that {@link SSLHandlerFactory} is created correctly. */ @Test public void testCreateSSLEngineFactory() throws Exception { Configuration serverConfig = createInternalSslConfigWithKeyAndTrustStores(); final String[] sslAlgorithms; final String[] expectedSslProtocols; if (sslProvider.equalsIgnoreCase("OPENSSL")) { // openSSL does not support the same set of cipher algorithms! sslAlgorithms = new String[] {"TLS_RSA_WITH_AES_128_GCM_SHA256", "TLS_RSA_WITH_AES_256_GCM_SHA384"}; expectedSslProtocols = new String[] {"SSLv2Hello", "TLSv1"}; } else { sslAlgorithms = new String[] {"TLS_DHE_RSA_WITH_AES_128_CBC_SHA", "TLS_DHE_RSA_WITH_AES_128_CBC_SHA256"}; expectedSslProtocols = new String[] {"TLSv1"}; } // set custom protocol and cipher suites serverConfig.setString(SecurityOptions.SSL_PROTOCOL, "TLSv1"); serverConfig.setString(SecurityOptions.SSL_ALGORITHMS, String.join(",", sslAlgorithms)); final SSLHandlerFactory serverSSLHandlerFactory = SSLUtils.createInternalServerSSLEngineFactory(serverConfig); final SslHandler sslHandler = serverSSLHandlerFactory.createNettySSLHandler(UnpooledByteBufAllocator.DEFAULT); assertEquals(expectedSslProtocols.length, sslHandler.engine().getEnabledProtocols().length); assertThat( sslHandler.engine().getEnabledProtocols(), arrayContainingInAnyOrder(expectedSslProtocols)); assertEquals(sslAlgorithms.length, sslHandler.engine().getEnabledCipherSuites().length); assertThat( sslHandler.engine().getEnabledCipherSuites(), arrayContainingInAnyOrder(sslAlgorithms)); }