private void addAddressToProperties( String addressName, SocketBindingCfg socketBindingCfg, Properties properties, ObjectMapper objectMapper) throws JsonProcessingException { final InetSocketAddress inetSocketAddress = socketBindingCfg.toSocketAddress().toInetSocketAddress(); final String value = objectMapper.writeValueAsString(inetSocketAddress); properties.setProperty(addressName, value); }
public boolean beginConnect(int attempt) { if (STATE_FIELD.compareAndSet(this, CLOSED, CONNECTING)) { connectAttempt = attempt; try { media = SocketChannel.open(); media.setOption(StandardSocketOptions.TCP_NODELAY, true); media.configureBlocking(false); media.connect(remoteAddress.getAddress().toInetSocketAddress()); return true; } catch (Exception e) { LOG.trace("Failed to begin connect to {}", remoteAddress, e); doClose(); return false; } } else { return false; } }
public boolean beginConnect(int attempt) { if (STATE_FIELD.compareAndSet(this, CLOSED, CONNECTING)) { connectAttempt = attempt; try { media = SocketChannel.open(); media.setOption(StandardSocketOptions.TCP_NODELAY, true); media.configureBlocking(false); media.connect(remoteAddress.getAddress().toInetSocketAddress()); return true; } catch (Exception e) { LOG.trace("Failed to begin connect to {}", remoteAddress, e); doClose(); return false; } } else { return false; } }
public void bindTransport() { if (transport == null) { transport = Transports.newServerTransport() .bindAddress(socketAddress.toInetSocketAddress()) .scheduler(scheduler) .build(null, channelHandler); } else { throw new RuntimeException("transport already open"); } }
public void bindTransport() { if (transport == null) { transport = Transports.newServerTransport() .bindAddress(socketAddress.toInetSocketAddress()) .scheduler(scheduler) .build(null, channelHandler); } else { throw new RuntimeException("transport already open"); } }
protected ActorFuture<BufferingServerTransport> bindBufferingProtocolEndpoint( final SystemContext systemContext, final ServiceContainer serviceContainer, final String name, final SocketBindingCfg socketBindingCfg, final ByteValue receiveBufferSize) { final SocketAddress bindAddr = socketBindingCfg.toSocketAddress(); return createBufferingServerTransport( systemContext, serviceContainer, name, bindAddr.toInetSocketAddress(), new ByteValue(socketBindingCfg.getSendBufferSize()), receiveBufferSize); }
protected ActorFuture<BufferingServerTransport> bindBufferingProtocolEndpoint( final SystemContext systemContext, final ServiceContainer serviceContainer, final String name, final SocketBindingCfg socketBindingCfg, final ByteValue receiveBufferSize) { final SocketAddress bindAddr = socketBindingCfg.toSocketAddress(); return createBufferingServerTransport( systemContext, serviceContainer, name, bindAddr.toInetSocketAddress(), new ByteValue(socketBindingCfg.getSendBufferSize()), receiveBufferSize); }
@Test public void shouldConfigureGateway() { InetSocketAddress address = brokerWithEnabledGateway.getGatewayAddress().toInetSocketAddress(); try (Socket socket = new Socket(address.getHostName(), address.getPort())) { // expect no error } catch (Exception e) { fail("Failed to connect to gateway with address: " + address, e); } address = brokerWithDisabledGateway.getGatewayAddress().toInetSocketAddress(); try (Socket socket = new Socket(address.getHostName(), address.getPort())) { fail("Unexpected to be able to connect to gateway with address: " + address); } catch (Exception e) { // expect error } } }
protected ActorFuture<ServerTransport> bindNonBufferingProtocolEndpoint( final SystemContext systemContext, final ServiceContainer serviceContainer, final String name, final SocketBindingCfg socketBindingCfg, final ServiceName<? extends ServerRequestHandler> requestHandlerService, final ServiceName<? extends ServerMessageHandler> messageHandlerService) { final SocketAddress bindAddr = socketBindingCfg.toSocketAddress(); return createServerTransport( systemContext, serviceContainer, name, bindAddr.toInetSocketAddress(), new ByteValue(socketBindingCfg.getSendBufferSize()), requestHandlerService, messageHandlerService); }
@Test public void shouldConfigureGateway() { InetSocketAddress address = brokerWithEnabledGateway.getGatewayAddress().toInetSocketAddress(); try (Socket socket = new Socket(address.getHostName(), address.getPort())) { // expect no error } catch (Exception e) { fail("Failed to connect to gateway with address: " + address, e); } address = brokerWithDisabledGateway.getGatewayAddress().toInetSocketAddress(); try (Socket socket = new Socket(address.getHostName(), address.getPort())) { fail("Unexpected to be able to connect to gateway with address: " + address); } catch (Exception e) { // expect error } } }
protected ActorFuture<ServerTransport> bindNonBufferingProtocolEndpoint( final SystemContext systemContext, final ServiceContainer serviceContainer, final String name, final SocketBindingCfg socketBindingCfg, final ServiceName<? extends ServerRequestHandler> requestHandlerService, final ServiceName<? extends ServerMessageHandler> messageHandlerService) { final SocketAddress bindAddr = socketBindingCfg.toSocketAddress(); return createServerTransport( systemContext, serviceContainer, name, bindAddr.toInetSocketAddress(), new ByteValue(socketBindingCfg.getSendBufferSize()), requestHandlerService, messageHandlerService); }