• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java TransportFactory类的典型用法和代码示例

java 1次浏览

本文整理汇总了Java中backtype.storm.messaging.TransportFactory的典型用法代码示例。如果您正苦于以下问题:Java TransportFactory类的具体用法?Java TransportFactory怎么用?Java TransportFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

TransportFactory类属于backtype.storm.messaging包,在下文中一共展示了TransportFactory类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: test_netty

点赞 2

import backtype.storm.messaging.TransportFactory; //导入依赖的package包/类
@Test
public void test_netty() {
	Map storm_conf = Maps.newHashMap();
	storm_conf.put(Config.STORM_MESSAGING_TRANSPORT,
			"com.alibaba.jstorm.message.netty.NettyContext");
	storm_conf.put(Config.STORM_MESSAGING_NETTY_BUFFER_SIZE, 1024);
	storm_conf.put(Config.STORM_MESSAGING_NETTY_MAX_RETRIES, 10);
	storm_conf.put(Config.STORM_MESSAGING_NETTY_MIN_SLEEP_MS, 1000);
	storm_conf.put(Config.STORM_MESSAGING_NETTY_MAX_SLEEP_MS, 5000);
	storm_conf.put(Config.STORM_MESSAGING_NETTY_SERVER_WORKER_THREADS, 1);
	storm_conf.put(Config.STORM_MESSAGING_NETTY_CLIENT_WORKER_THREADS, 1);
	IContext context = TransportFactory.makeContext(storm_conf);
	Assert.assertNotNull(context);
}
 

开发者ID:zhangjunfang,
项目名称:jstorm-0.9.6.3-,
代码行数:15,
代码来源:ContextTest.java

示例2: test_netty

点赞 2

import backtype.storm.messaging.TransportFactory; //导入依赖的package包/类
@Test
public void test_netty() {
    Map storm_conf = Maps.newHashMap();
    storm_conf.put(Config.STORM_MESSAGING_TRANSPORT, "com.alibaba.jstorm.message.netty.NettyContext");
    storm_conf.put(Config.STORM_MESSAGING_NETTY_BUFFER_SIZE, 1024);
    storm_conf.put(Config.STORM_MESSAGING_NETTY_MAX_RETRIES, 10);
    storm_conf.put(Config.STORM_MESSAGING_NETTY_MIN_SLEEP_MS, 1000);
    storm_conf.put(Config.STORM_MESSAGING_NETTY_MAX_SLEEP_MS, 5000);
    storm_conf.put(Config.STORM_MESSAGING_NETTY_SERVER_WORKER_THREADS, 1);
    storm_conf.put(Config.STORM_MESSAGING_NETTY_CLIENT_WORKER_THREADS, 1);
    IContext context = TransportFactory.makeContext(storm_conf);
    Assert.assertNotNull(context);
}
 

开发者ID:kkllwww007,
项目名称:jstrom,
代码行数:14,
代码来源:ContextTest.java

示例3: test_netty

点赞 2

import backtype.storm.messaging.TransportFactory; //导入依赖的package包/类
@Test
public void test_netty() {
	Map storm_conf = Maps.newHashMap();
	storm_conf.put(Config.STORM_MESSAGING_TRANSPORT,
			"org.act.tstream.message.netty.NettyContext");
	storm_conf.put(Config.STORM_MESSAGING_NETTY_BUFFER_SIZE, 1024);
	storm_conf.put(Config.STORM_MESSAGING_NETTY_MAX_RETRIES, 10);
	storm_conf.put(Config.STORM_MESSAGING_NETTY_MIN_SLEEP_MS, 1000);
	storm_conf.put(Config.STORM_MESSAGING_NETTY_MAX_SLEEP_MS, 5000);
	storm_conf.put(Config.STORM_MESSAGING_NETTY_SERVER_WORKER_THREADS, 1);
	storm_conf.put(Config.STORM_MESSAGING_NETTY_CLIENT_WORKER_THREADS, 1);
	IContext context = TransportFactory.makeContext(storm_conf);
	Assert.assertNotNull(context);
}
 

开发者ID:greeenSY,
项目名称:Tstream,
代码行数:15,
代码来源:ContextTest.java

示例4: setup

点赞 2

import backtype.storm.messaging.TransportFactory; //导入依赖的package包/类
@BeforeClass
public static void setup() {
    storm_conf = Utils.readDefaultConfig();
    ConfigExtension.setLocalWorkerPort(storm_conf, port);
    ConfigExtension.setNettyASyncBlock(storm_conf, false);
    storm_conf.put(ConfigExtension.TOPOLOGY_BACKPRESSURE_ENABLE, false);

    // Check whether context can be reused or not
    context = TransportFactory.makeContext(storm_conf);
    FlusherPool flusherPool = new FlusherPool(1, 100, 30, TimeUnit.SECONDS);
    Flusher.setFlusherPool(flusherPool);
}
 

开发者ID:alibaba,
项目名称:jstorm,
代码行数:13,
代码来源:NettyUnitTest.java

示例5: test_first_client

点赞 2

import backtype.storm.messaging.TransportFactory; //导入依赖的package包/类
@Test
public void test_first_client() throws InterruptedException {
	System.out.println("!!!!!!!!Start test_first_client !!!!!!!!!!!");
	final String req_msg = setupLargMsg();

	final IContext context = TransportFactory.makeContext(storm_conf);

	new Thread(new Runnable() {

		@Override
		public void run() {

		    lock.lock();
			IConnection client = context.connect(null, "localhost", port);

			List<TaskMessage> list = new ArrayList<TaskMessage>();
			TaskMessage message = new TaskMessage(task, req_msg.getBytes());
			list.add(message);

			client.send(message);
			System.out.println("!!Client has sent data");
			JStormUtils.sleepMs(1000);
			
			try {
                   clientClose.await();
               } catch (InterruptedException e) {
                   
                   e.printStackTrace();
               }
			client.close();
			contextClose.signal();
			lock.unlock();
			
		}
	}).start();

	
	IConnection server = null;

	JStormUtils.sleepMs(1000);
	System.out.println("!!server begin start!!!!!");

	server = context.bind(null, port);

	WaitStrategy waitStrategy = (WaitStrategy) Utils
			.newInstance((String) storm_conf
					.get(Config.TOPOLOGY_DISRUPTOR_WAIT_STRATEGY));
	DisruptorQueue recvQueue = DisruptorQueue.mkInstance(
			"NettyUnitTest", ProducerType.SINGLE, 1024, waitStrategy);
	server.registerQueue(recvQueue);

	TaskMessage recv = server.recv(0);
	Assert.assertEquals(req_msg, new String(recv.message()));

	lock.lock();
	clientClose.signal();
	server.close();
	contextClose.await();
	context.term();
	lock.unlock();

	System.out.println("!!!!!!!!!!!!End test_first_client!!!!!!!!!!!!!");
}
 

开发者ID:zhangjunfang,
项目名称:jstorm-0.9.6.3-,
代码行数:64,
代码来源:NettyUnitTest.java

示例6: test_server_reboot

点赞 2

import backtype.storm.messaging.TransportFactory; //导入依赖的package包/类
@Test
public void test_server_reboot() throws InterruptedException {
	System.out.println("!!!!!!!!!!Start server reboot test!!!!!!!!");
	final String req_msg = setupLargMsg();

	final IContext context = TransportFactory.makeContext(storm_conf);
	IConnection server = null;
	

	new Thread(new Runnable() {

		@Override
		public void run() {
		    final IConnection client = context.connect(null, "localhost", port);
		    
		    lock.lock();
		    
			List<TaskMessage> list = new ArrayList<TaskMessage>();
			TaskMessage message = new TaskMessage(task, req_msg.getBytes());
			list.add(message);

			client.send(message);

			System.out.println("Send first");

			JStormUtils.sleepMs(10000);

			System.out.println("Begin to Send second");
			client.send(message);
			System.out.println("Send second");

			JStormUtils.sleepMs(15000);
			client.send(message);
			System.out.println("Send third time");
			
			try {
                   clientClose.await();
               } catch (InterruptedException e) {
                   
                   e.printStackTrace();
               }
               client.close();
               contextClose.signal();
               lock.unlock();

		}
	}).start();

	server = context.bind(null, port);

	WaitStrategy waitStrategy = (WaitStrategy) Utils
			.newInstance((String) storm_conf
					.get(Config.TOPOLOGY_DISRUPTOR_WAIT_STRATEGY));
	DisruptorQueue recvQueue = DisruptorQueue.mkInstance(
			"NettyUnitTest", ProducerType.SINGLE, 1024, waitStrategy);
	server.registerQueue(recvQueue);

	TaskMessage recv = server.recv(0);
	System.out.println("Receive first");
	Assert.assertEquals(req_msg, new String(recv.message()));

	server.close();

	System.out.println("!!shutdow server and sleep 30s, please wait!!");
	Thread.sleep(30000);

	IConnection server2 = context.bind(null, port);
	server2.registerQueue(recvQueue);
	System.out.println("!!!!!!!!!!!!!!!!!!!! restart server !!!!!!!!!!!");

	TaskMessage recv2 = server2.recv(0);
	Assert.assertEquals(req_msg, new String(recv2.message()));

	lock.lock();
       clientClose.signal();
       server2.close();
       contextClose.await();
       context.term();
       lock.unlock();
	System.out.println("!!!!!!!!!!End server reboot test!!!!!!!!");
}
 

开发者ID:zhangjunfang,
项目名称:jstorm-0.9.6.3-,
代码行数:82,
代码来源:NettyUnitTest.java

示例7: test_first_client

点赞 2

import backtype.storm.messaging.TransportFactory; //导入依赖的package包/类
@Test
public void test_first_client() throws InterruptedException {
	System.out.println("!!!!!!!!Start test_first_client !!!!!!!!!!!");
	final String req_msg = setupLargMsg();

	final IContext context = TransportFactory.makeContext(storm_conf);

	new Thread(new Runnable() {

		@Override
		public void run() {

		    lock.lock();
			IConnection client = context.connect(null, "localhost", port);

			List<TaskMessage> list = new ArrayList<TaskMessage>();
			TaskMessage message = new TaskMessage(task, req_msg.getBytes());
			list.add(message);

			client.send(message);
			System.out.println("!!Client has sent data");
			JStormUtils.sleepMs(1000);
			
			try {
                   clientClose.await();
               } catch (InterruptedException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
               }
			client.close();
			contextClose.signal();
			lock.unlock();
			
		}
	}).start();

	
	IConnection server = null;

	JStormUtils.sleepMs(1000);
	System.out.println("!!server begin start!!!!!");

	server = context.bind(null, port);

	WaitStrategy waitStrategy = (WaitStrategy) Utils
			.newInstance((String) storm_conf
					.get(Config.TOPOLOGY_DISRUPTOR_WAIT_STRATEGY));
	DisruptorQueue recvQueue = DisruptorQueue.mkInstance(
			"NettyUnitTest", ProducerType.SINGLE, 1024, waitStrategy);
	server.registerQueue(recvQueue);

	TaskMessage recv = server.recv(0);
	Assert.assertEquals(req_msg, new String(recv.message()));

	lock.lock();
	clientClose.signal();
	server.close();
	contextClose.await();
	context.term();
	lock.unlock();

	System.out.println("!!!!!!!!!!!!End test_first_client!!!!!!!!!!!!!");
}
 

开发者ID:songtk,
项目名称:learn_jstorm,
代码行数:64,
代码来源:NettyUnitTest.java

示例8: test_server_reboot

点赞 2

import backtype.storm.messaging.TransportFactory; //导入依赖的package包/类
@Test
public void test_server_reboot() throws InterruptedException {
	System.out.println("!!!!!!!!!!Start server reboot test!!!!!!!!");
	final String req_msg = setupLargMsg();

	final IContext context = TransportFactory.makeContext(storm_conf);
	IConnection server = null;
	

	new Thread(new Runnable() {

		@Override
		public void run() {
		    final IConnection client = context.connect(null, "localhost", port);
		    
		    lock.lock();
		    
			List<TaskMessage> list = new ArrayList<TaskMessage>();
			TaskMessage message = new TaskMessage(task, req_msg.getBytes());
			list.add(message);

			client.send(message);

			System.out.println("Send first");

			JStormUtils.sleepMs(10000);

			System.out.println("Begin to Send second");
			client.send(message);
			System.out.println("Send second");

			JStormUtils.sleepMs(15000);
			client.send(message);
			System.out.println("Send third time");
			
			try {
                   clientClose.await();
               } catch (InterruptedException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
               }
               client.close();
               contextClose.signal();
               lock.unlock();

		}
	}).start();

	server = context.bind(null, port);

	WaitStrategy waitStrategy = (WaitStrategy) Utils
			.newInstance((String) storm_conf
					.get(Config.TOPOLOGY_DISRUPTOR_WAIT_STRATEGY));
	DisruptorQueue recvQueue = DisruptorQueue.mkInstance(
			"NettyUnitTest", ProducerType.SINGLE, 1024, waitStrategy);
	server.registerQueue(recvQueue);

	TaskMessage recv = server.recv(0);
	System.out.println("Receive first");
	Assert.assertEquals(req_msg, new String(recv.message()));

	server.close();

	System.out.println("!!shutdow server and sleep 30s, please wait!!");
	Thread.sleep(30000);

	IConnection server2 = context.bind(null, port);
	server2.registerQueue(recvQueue);
	System.out.println("!!!!!!!!!!!!!!!!!!!! restart server !!!!!!!!!!!");

	TaskMessage recv2 = server2.recv(0);
	Assert.assertEquals(req_msg, new String(recv2.message()));

	lock.lock();
       clientClose.signal();
       server2.close();
       contextClose.await();
       context.term();
       lock.unlock();
	System.out.println("!!!!!!!!!!End server reboot test!!!!!!!!");
}
 

开发者ID:songtk,
项目名称:learn_jstorm,
代码行数:82,
代码来源:NettyUnitTest.java

示例9: test_first_client

点赞 2

import backtype.storm.messaging.TransportFactory; //导入依赖的package包/类
@Test
public void test_first_client() throws InterruptedException {
    System.out.println("!!!!!!!!Start test_first_client !!!!!!!!!!!");
    final String req_msg = setupLargMsg();

    final IContext context = TransportFactory.makeContext(storm_conf);

    new Thread(new Runnable() {

        @Override
        public void run() {

            lock.lock();
            IConnection client = context.connect(null, "localhost", port);

            List<TaskMessage> list = new ArrayList<TaskMessage>();
            TaskMessage message = new TaskMessage(task, req_msg.getBytes());
            list.add(message);

            client.send(message);
            System.out.println("!!Client has sent data");
            JStormUtils.sleepMs(1000);

            try {
                clientClose.await();
            } catch (InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            client.close();
            contextClose.signal();
            lock.unlock();

        }
    }).start();

    IConnection server = null;

    JStormUtils.sleepMs(1000);
    System.out.println("!!server begin start!!!!!");

    server = initNettyServer();
    JStormUtils.sleepMs(5000);

    System.out.println("Begin to receive message");
    byte[] recv = (byte[]) server.recv(task, 1);
    Assert.assertEquals(req_msg, new String(recv));

    System.out.println("Finished to receive message");

    lock.lock();
    clientClose.signal();
    server.close();
    contextClose.await();
    context.term();
    lock.unlock();

    System.out.println("!!!!!!!!!!!!End test_first_client!!!!!!!!!!!!!");
}
 

开发者ID:kkllwww007,
项目名称:jstrom,
代码行数:60,
代码来源:NettyUnitTest.java

示例10: test_msg_buffer_timeout

点赞 2

import backtype.storm.messaging.TransportFactory; //导入依赖的package包/类
@Test
public void test_msg_buffer_timeout() throws InterruptedException {
    System.out.println("!!!!!!!!Start test_msg_buffer_timeout !!!!!!!!!!!");
    final String req_msg = setupLargMsg();

    ConfigExtension.setNettyPendingBufferTimeout(storm_conf, 10 * 1000l);
    final IContext context = TransportFactory.makeContext(storm_conf);

    new Thread(new Runnable() {

        @Override
        public void run() {

            lock.lock();
            IConnection client = context.connect(null, "localhost", port);

            List<TaskMessage> list = new ArrayList<TaskMessage>();
            TaskMessage message = new TaskMessage(task, req_msg.getBytes());
            list.add(message);

            client.send(message);
            System.out.println("!!Client has sent data");
            JStormUtils.sleepMs(1000);

            try {
                clientClose.await();
            } catch (InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            client.close();
            contextClose.signal();
            lock.unlock();

        }
    }).start();

    IConnection server = null;

    JStormUtils.sleepMs(11000);
    System.out.println("!!server begin start!!!!!");

    server = initNettyServer();
    JStormUtils.sleepMs(5000);

    System.out.println("Begin to receive message");
    byte[] recv = (byte[]) server.recv(task, 1);
    Assert.assertEquals(null, recv);

    System.out.println("Pending message was timouout:" + (recv == null));

    lock.lock();
    clientClose.signal();
    server.close();
    contextClose.await();
    context.term();
    lock.unlock();

    System.out.println("!!!!!!!!!!!!End test_msg_buffer_timeout!!!!!!!!!!!!!");
}
 

开发者ID:kkllwww007,
项目名称:jstrom,
代码行数:61,
代码来源:NettyUnitTest.java

示例11: test_server_reboot

点赞 2

import backtype.storm.messaging.TransportFactory; //导入依赖的package包/类
@Test
public void test_server_reboot() throws InterruptedException {
    System.out.println("!!!!!!!!!!Start server reboot test!!!!!!!!");
    final String req_msg = setupLargMsg();

    final IContext context = TransportFactory.makeContext(storm_conf);
    IConnection server = null;

    new Thread(new Runnable() {

        @Override
        public void run() {
            final IConnection client = context.connect(null, "localhost", port);

            lock.lock();

            List<TaskMessage> list = new ArrayList<TaskMessage>();
            TaskMessage message = new TaskMessage(task, req_msg.getBytes());
            list.add(message);

            client.send(message);

            System.out.println("Send first");

            JStormUtils.sleepMs(10000);

            System.out.println("Begin to Send second");
            client.send(message);
            System.out.println("Send second");

            JStormUtils.sleepMs(15000);
            client.send(message);
            System.out.println("Send third time");

            try {
                clientClose.await();
            } catch (InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            client.close();
            contextClose.signal();
            lock.unlock();

        }
    }).start();

    server = initNettyServer();

    byte[] recv = (byte[]) server.recv(task, 0);
    System.out.println("Receive first");
    Assert.assertEquals(req_msg, new String(recv));

    server.close();

    System.out.println("!!shutdow server and sleep 30s, please wait!!");
    Thread.sleep(30000);

    IConnection server2 = server = initNettyServer();
    System.out.println("!!!!!!!!!!!!!!!!!!!! restart server !!!!!!!!!!!");

    byte[] recv2 = (byte[]) server2.recv(task, 0);
    Assert.assertEquals(req_msg, new String(recv2));

    lock.lock();
    clientClose.signal();
    server2.close();
    contextClose.await();
    context.term();
    lock.unlock();
    System.out.println("!!!!!!!!!!End server reboot test!!!!!!!!");
}
 

开发者ID:kkllwww007,
项目名称:jstrom,
代码行数:73,
代码来源:NettyUnitTest.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)