protected void connect(AbstractBootstrap bootstrap) { Channel channel = null; Constants.ahessianLogger.warn("reconnecting..."); while (channel == null && !_stop) try { channel = ((Bootstrap) bootstrap).connect().sync().channel(); } catch (Exception ex) { if (ex instanceof ConnectException) { System.out.println(ex); try { Thread.sleep(RECONNECT_DELAY); } catch (InterruptedException e) { e.printStackTrace(); } } } }
protected <A extends AbstractBootstrap<?, ?>, B extends AbstractBootstrap<?, ?>> List<BootstrapComboFactory<A, B>> combo(List<BootstrapFactory<A>> sbfs, List<BootstrapFactory<B>> cbfs) { List<BootstrapComboFactory<A, B>> list = new ArrayList<BootstrapComboFactory<A, B>>(); // Populate the combinations for (BootstrapFactory<A> sbf: sbfs) { for (BootstrapFactory<B> cbf: cbfs) { final BootstrapFactory<A> sbf0 = sbf; final BootstrapFactory<B> cbf0 = cbf; list.add(new BootstrapComboFactory<A, B>() { @Override public A newServerInstance() { return sbf0.newInstance(); } @Override public B newClientInstance() { return cbf0.newInstance(); } }); } } return list; }
private static void testMultipleBindDatagramChannelWithoutReusePortFails0(AbstractBootstrap<?, ?> bootstrap) { bootstrap.handler(new DummyHandler()); ChannelFuture future = bootstrap.bind().syncUninterruptibly(); try { bootstrap.bind().syncUninterruptibly(); Assert.fail(); } catch (Exception e) { Assert.assertTrue(e instanceof IOException); } future.channel().close().syncUninterruptibly(); }
@Test public void testInitChannelWithLogger() throws Exception { //given configurationBuilder.withAddLoggingHandler(true); Iso8583ChannelInitializer<Channel, AbstractBootstrap, ConnectorConfiguration> channelInitializer = createChannelInitializer(configurer); // when channelInitializer.initChannel(channel); //then verify(pipeline).addLast(same(workerGroup), eq("logging"), any(IsoMessageLoggingHandler.class)); }
@Test public void testInitChannelWithoutLogger() throws Exception { //given configurationBuilder.withAddLoggingHandler(false); Iso8583ChannelInitializer<Channel, AbstractBootstrap, ConnectorConfiguration> channelInitializer = createChannelInitializer(configurer); //when channelInitializer.initChannel(channel); //then verify(pipeline, never()).addLast(any(EventLoopGroup.class), anyString(), any(IsoMessageLoggingHandler.class)); }
private Iso8583ChannelInitializer<Channel, AbstractBootstrap, ConnectorConfiguration> createChannelInitializer(ConnectorConfigurer<ConnectorConfiguration, AbstractBootstrap> configurer) { return new Iso8583ChannelInitializer<>( configurationBuilder.build(), configurer, workerGroup, messageFactory, handlers); }
@Before public void setUp() throws Exception { compositeIsoMessageHandler = new CompositeIsoMessageHandler<>(); subject = new AbstractIso8583Connector<ConnectorConfiguration, AbstractBootstrap, M>( config, messageFactory, compositeIsoMessageHandler ) { @Override protected AbstractBootstrap createBootstrap() { throw new UnsupportedOperationException("Method is not implemented: .createBootstrap"); } }; }
public ChannelPipelineFactory create(EventExecutorGroup group, AbstractBootstrap bootstrap);
@Override public ChannelPipelineFactory create(EventExecutorGroup group, AbstractBootstrap bootstrap) { ChannelPipelineFactory result; if (isRPCServer() && isRPC() && _serverFactory == null) { _serverFactory = new HessianRPCServiceHandler( Executors.newCachedThreadPool(), _serviceOptions, TIMER); _serverFactory.setConnectListener(_connectedListener); _serverFactory.setDisconnectListener(_disconnectedListener); if (isExecutorService()) _serverFactory .addService( "default", new ExecutorInvokeService( _serverService, _serverServiceInterface, _serverFactory, Executors .newFixedThreadPool(_executorThreads))); else _serverFactory.addService("default", new ImmediateInvokeService(_serverService, _serverServiceInterface, _serverFactory)); } else if (isRPC() && _clientFactory == null) { Executor executor = _executorThreads > 0 ? Executors .newFixedThreadPool(_executorThreads) : Executors .newSingleThreadExecutor(); String name = "NONAME?"; _clientFactory = new HessianProxyFactory(executor, name, _serviceOptions); } if (hasSession()) { result = basePipelineFactory( mixinPipelineFactory(group, bootstrap), group, bootstrap); } else result = mergePipelineFactory( basePipelineFactory(group, bootstrap), mixinPipelineFactory(group, bootstrap)); if (_debug) result.debug(); return result; }
private ChannelPipelineFactory basePipelineFactory( EventExecutorGroup group, AbstractBootstrap bootstrap) { return basePipelineFactory(null, group, bootstrap); }
private void defaultNettyOptions(AbstractBootstrap<?, ?> bootstrap) { bootstrap.option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT); }
public AbstractBootstrap getBootstrap();
protected abstract AbstractBootstrap bootstrap(boolean enableEpoll);