use of org.jboss.netty.channel.ChannelPipelineFactory in project databus by linkedin.
the class TestHttpResponseProcessor method setUpClass.
@BeforeClass
public void setUpClass() {
TestUtil.setupLoggingWithTimestampedFile(true, "/tmp/TestGenericHttpResponseHandler_", ".log", Level.INFO);
InternalLoggerFactory.setDefaultFactory(new Log4JLoggerFactory());
_dummyServer = new SimpleTestServerConnection(ByteOrder.BIG_ENDIAN, SimpleTestServerConnection.ServerType.NIO);
_dummyServer.setPipelineFactory(new ChannelPipelineFactory() {
@Override
public ChannelPipeline getPipeline() throws Exception {
return Channels.pipeline(new HttpServerCodec());
}
});
_dummyServer.start(SERVER_ADDRESS_ID);
_logLevel = org.apache.log4j.Level.INFO;
}
use of org.jboss.netty.channel.ChannelPipelineFactory in project databus by linkedin.
the class TestHttpResponseProcessor method createChannelFuture.
static ChannelFuture createChannelFuture(final GenericHttpResponseHandler responseHandler, int port) {
ClientBootstrap client = new ClientBootstrap(new NioClientSocketChannelFactory(BOSS_POOL, IO_POOL));
client.setPipelineFactory(new ChannelPipelineFactory() {
@Override
public ChannelPipeline getPipeline() throws Exception {
return Channels.pipeline(new LoggingHandler(InternalLogLevel.DEBUG), new HttpClientCodec(), new LoggingHandler(InternalLogLevel.DEBUG), responseHandler);
}
});
final ChannelFuture connectFuture = client.connect(new InetSocketAddress("localhost", port));
return connectFuture;
}
use of org.jboss.netty.channel.ChannelPipelineFactory in project databus by linkedin.
the class TestNettyHttpDatabusBootstrapConnection method setUpClass.
@BeforeClass
public void setUpClass() throws InvalidConfigException {
TestUtil.setupLoggingWithTimestampedFile(true, "/tmp/TestNettyHttpDatabusBootstrapConnection_", ".log", Level.INFO);
InternalLoggerFactory.setDefaultFactory(new Log4JLoggerFactory());
_dummyServer = new SimpleTestServerConnection(new DbusEventV2Factory().getByteOrder(), SimpleTestServerConnection.ServerType.NIO);
_dummyServer.setPipelineFactory(new ChannelPipelineFactory() {
@Override
public ChannelPipeline getPipeline() throws Exception {
return Channels.pipeline(new LoggingHandler(InternalLogLevel.DEBUG), new HttpServerCodec(), new LoggingHandler(InternalLogLevel.DEBUG), new SimpleObjectCaptureHandler());
}
});
_dummyServer.start(SERVER_ADDRESS_ID);
DatabusHttpClientImpl.Config clientCfgBuilder = new DatabusHttpClientImpl.Config();
clientCfgBuilder.getContainer().setReadTimeoutMs(DEFAULT_READ_TIMEOUT_MS);
clientCfgBuilder.getContainer().setWriteTimeoutMs(DEFAULT_WRITE_TIMEOUT_MS);
CONN_FACTORY = new NettyHttpConnectionFactory(BOSS_POOL, IO_POOL, null, NETWORK_TIMER, clientCfgBuilder.getContainer().getWriteTimeoutMs(), clientCfgBuilder.getContainer().getReadTimeoutMs(), clientCfgBuilder.getContainer().getBstReadTimeoutMs(), // protocolVersion
4, MAX_EVENT_VERSION, TEST_CHANNELS_GROUP);
}
use of org.jboss.netty.channel.ChannelPipelineFactory in project databus by linkedin.
the class TestDatabusV2ClusterRegistrationImpl method setUpClass.
@BeforeClass
public void setUpClass() throws InvalidConfigException {
//setup logging
TestUtil.setupLogging(true, null, Level.INFO);
InternalLoggerFactory.setDefaultFactory(new Log4JLoggerFactory());
//initialize relays
for (int relayN = 0; relayN < RELAY_PORT.length; ++relayN) {
_dummyServer[relayN] = new SimpleTestServerConnection(new DbusEventV2Factory().getByteOrder(), SimpleTestServerConnection.ServerType.NIO);
_dummyServer[relayN].setPipelineFactory(new ChannelPipelineFactory() {
@Override
public ChannelPipeline getPipeline() throws Exception {
return Channels.pipeline(new LoggingHandler(InternalLogLevel.DEBUG), new HttpServerCodec(), new LoggingHandler(InternalLogLevel.DEBUG), new SimpleObjectCaptureHandler());
}
});
_dummyServer[relayN].start(RELAY_PORT[relayN]);
}
//create standard client config
DatabusHttpClientImpl.Config clientCfgBuilder = new DatabusHttpClientImpl.Config();
clientCfgBuilder.getContainer().setHttpPort(CLIENT_PORT);
clientCfgBuilder.getContainer().getJmx().setRmiEnabled(false);
clientCfgBuilder.getContainer().setReadTimeoutMs(10000000);
clientCfgBuilder.getConnectionDefaults().getPullerRetries().setInitSleep(10);
clientCfgBuilder.getRuntime().getBootstrap().setEnabled(false);
clientCfgBuilder.getCheckpointPersistence().setClearBeforeUse(true);
for (int i = 0; i < RELAY_PORT.length; ++i) {
clientCfgBuilder.getRuntime().getRelay(Integer.toString(i)).setHost("localhost");
clientCfgBuilder.getRuntime().getRelay(Integer.toString(i)).setPort(RELAY_PORT[i]);
clientCfgBuilder.getRuntime().getRelay(Integer.toString(i)).setSources(SOURCE1_NAME);
}
_stdClientCfgBuilder = clientCfgBuilder;
_stdClientCfg = clientCfgBuilder.build();
//create standard relay buffer config
DbusEventBuffer.Config bufCfgBuilder = new DbusEventBuffer.Config();
bufCfgBuilder.setAllocationPolicy(AllocationPolicy.HEAP_MEMORY.toString());
bufCfgBuilder.setMaxSize(100000);
bufCfgBuilder.setScnIndexSize(128);
bufCfgBuilder.setAverageEventSize(1);
_bufCfg = bufCfgBuilder.build();
}
use of org.jboss.netty.channel.ChannelPipelineFactory in project opennms by OpenNMS.
the class TcpOutputStrategyTest method setUpClass.
@BeforeClass
public static void setUpClass() {
// Setup a quick Netty TCP server that decodes the protobuf messages
// and appends these to a list when received
ChannelFactory factory = new NioServerSocketChannelFactory();
ServerBootstrap bootstrap = new ServerBootstrap(factory);
bootstrap.setPipelineFactory(new ChannelPipelineFactory() {
public ChannelPipeline getPipeline() {
return Channels.pipeline(new ProtobufDecoder(PerformanceDataReadings.getDefaultInstance()), new PerfDataServerHandler());
}
});
Channel channel = bootstrap.bind(new InetSocketAddress(0));
InetSocketAddress addr = (InetSocketAddress) channel.getLocalAddress();
// Point the TCP exporter to our server
System.setProperty("org.opennms.rrd.tcp.host", addr.getHostString());
System.setProperty("org.opennms.rrd.tcp.port", Integer.toString(addr.getPort()));
// Always use queueing during these tests
System.setProperty("org.opennms.rrd.usequeue", Boolean.TRUE.toString());
// Use the temporary folder as the base directory
System.setProperty("rrd.base.dir", tempFolder.getRoot().getAbsolutePath());
}
Aggregations