当前位置: 首页>>代码示例>>Java>>正文


Java ChannelPipelineFactory类代码示例

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


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

示例1: run

import org.jboss.netty.channel.ChannelPipelineFactory; //导入依赖的package包/类
/**
 * Tell controller that we're ready to accept pcc connections.
 */
public void run() {
    try {
        final ServerBootstrap bootstrap = createServerBootStrap();

        bootstrap.setOption("reuseAddr", true);
        bootstrap.setOption("child.keepAlive", true);
        bootstrap.setOption("child.tcpNoDelay", true);
        bootstrap.setOption("child.sendBufferSize", Controller.SEND_BUFFER_SIZE);

        ChannelPipelineFactory pfact = new PcepPipelineFactory(this);

        bootstrap.setPipelineFactory(pfact);
        InetSocketAddress sa = new InetSocketAddress(pcepPort);
        cg = new DefaultChannelGroup();
        cg.add(bootstrap.bind(sa));
        log.info("Listening for PCC connection on {}", sa);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:24,代码来源:Controller.java

示例2: doOpen

import org.jboss.netty.channel.ChannelPipelineFactory; //导入依赖的package包/类
@Override
protected void doOpen() throws Throwable {
    NettyHelper.setNettyLoggerFactory();
    bootstrap = new ClientBootstrap(channelFactory);
    // config
    // @see org.jboss.netty.channel.socket.SocketChannelConfig
    bootstrap.setOption("keepAlive", true);
    bootstrap.setOption("tcpNoDelay", true);
    bootstrap.setOption("connectTimeoutMillis", getTimeout());
    final NettyHandler nettyHandler = new NettyHandler(getUrl(), this);
    bootstrap.setPipelineFactory(new ChannelPipelineFactory() {
        public ChannelPipeline getPipeline() {
            NettyCodecAdapter adapter = new NettyCodecAdapter(getCodec(), getUrl(), NettyClient.this);
            ChannelPipeline pipeline = Channels.pipeline();
            pipeline.addLast("decoder", adapter.getDecoder());
            pipeline.addLast("encoder", adapter.getEncoder());
            pipeline.addLast("handler", nettyHandler);
            return pipeline;
        }
    });
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:22,代码来源:NettyClient.java

示例3: NettyServerCnxnFactory

import org.jboss.netty.channel.ChannelPipelineFactory; //导入依赖的package包/类
NettyServerCnxnFactory() {
    bootstrap = new ServerBootstrap(
            new NioServerSocketChannelFactory(
                    Executors.newCachedThreadPool(),
                    Executors.newCachedThreadPool()));
    // parent channel
    bootstrap.setOption("reuseAddress", true);
    // child channels
    bootstrap.setOption("child.tcpNoDelay", true);
    /* set socket linger to off, so that socket close does not block */
    bootstrap.setOption("child.soLinger", -1);
    bootstrap.setPipelineFactory(new ChannelPipelineFactory() {
        @Override
        public ChannelPipeline getPipeline() throws Exception {
            ChannelPipeline p = Channels.pipeline();
            if (secure) {
                initSSL(p);
            }
            p.addLast("servercnxnfactory", channelHandler);

            return p;
        }
    });
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:25,代码来源:NettyServerCnxnFactory.java

示例4: startHttpServer

import org.jboss.netty.channel.ChannelPipelineFactory; //导入依赖的package包/类
private ServerBootstrap startHttpServer(int port,
    final Token<DelegationTokenIdentifier> token, final URI url) {
  ServerBootstrap bootstrap = new ServerBootstrap(
      new NioServerSocketChannelFactory(Executors.newCachedThreadPool(),
          Executors.newCachedThreadPool()));

  bootstrap.setPipelineFactory(new ChannelPipelineFactory() {
    @Override
    public ChannelPipeline getPipeline() throws Exception {
      return Channels.pipeline(new HttpRequestDecoder(),
          new HttpChunkAggregator(65536), new HttpResponseEncoder(),
          new CredentialsLogicHandler(token, url.toString()));
    }
  });
  bootstrap.bind(new InetSocketAddress("localhost", port));
  return bootstrap;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:18,代码来源:TestDelegationTokenRemoteFetcher.java

示例5: run

import org.jboss.netty.channel.ChannelPipelineFactory; //导入依赖的package包/类
/**
 * Tell controller that we're ready to accept switches loop.
 */
public void run() {

    try {
        final ServerBootstrap bootstrap = createServerBootStrap();

        bootstrap.setOption("reuseAddr", true);
        bootstrap.setOption("child.keepAlive", true);
        bootstrap.setOption("child.tcpNoDelay", true);
        bootstrap.setOption("child.sendBufferSize", Controller.SEND_BUFFER_SIZE);

        ChannelPipelineFactory pfact =
                new OpenflowPipelineFactory(this, null, sslContext);
        bootstrap.setPipelineFactory(pfact);
        cg = new DefaultChannelGroup();
        openFlowPorts.forEach(port -> {
            InetSocketAddress sa = new InetSocketAddress(port);
            cg.add(bootstrap.bind(sa));
            log.info("Listening for switch connections on {}", sa);
        });

    } catch (Exception e) {
        throw new RuntimeException(e);
    }

}
 
开发者ID:shlee89,项目名称:athena,代码行数:29,代码来源:Controller.java

示例6: connect

import org.jboss.netty.channel.ChannelPipelineFactory; //导入依赖的package包/类
/**
  * Starts the BGP peer.
  *
  * @param connectToSocket the socket to connect to
  */
 private void connect(InetSocketAddress connectToSocket)
     throws InterruptedException {

     ChannelFactory channelFactory =
         new NioClientSocketChannelFactory(
                 Executors.newCachedThreadPool(),
                 Executors.newCachedThreadPool());
     ChannelPipelineFactory pipelineFactory = () -> {
         ChannelPipeline pipeline = Channels.pipeline();
         pipeline.addLast("BgpPeerFrameDecoderTest",
                 peerFrameDecoder);
         pipeline.addLast("BgpPeerChannelHandlerTest",
                 peerChannelHandler);
         return pipeline;
     };

     peerBootstrap = new ClientBootstrap(channelFactory);
     peerBootstrap.setOption("child.keepAlive", true);
     peerBootstrap.setOption("child.tcpNoDelay", true);
     peerBootstrap.setPipelineFactory(pipelineFactory);
     peerBootstrap.connect(connectToSocket);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:28,代码来源:BgpControllerImplTest.java

示例7: connectFrom

import org.jboss.netty.channel.ChannelPipelineFactory; //导入依赖的package包/类
private Channel connectFrom(InetSocketAddress connectToSocket, SocketAddress localAddress)
     throws InterruptedException {

     ChannelFactory channelFactory =
         new NioClientSocketChannelFactory(
                 Executors.newCachedThreadPool(),
                 Executors.newCachedThreadPool());
     ChannelPipelineFactory pipelineFactory = () -> {
         ChannelPipeline pipeline = Channels.pipeline();
         pipeline.addLast("BgpPeerFrameDecoderTest",
                 peerFrameDecoder);
         pipeline.addLast("BgpPeerChannelHandlerTest",
                 peerChannelHandler);
         return pipeline;
     };

     peerBootstrap = new ClientBootstrap(channelFactory);
     peerBootstrap.setOption("child.keepAlive", true);
     peerBootstrap.setOption("child.tcpNoDelay", true);
     peerBootstrap.setPipelineFactory(pipelineFactory);
     Channel channel = peerBootstrap.connect(connectToSocket, localAddress).getChannel();
     return channel;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:24,代码来源:BgpControllerImplTest.java

示例8: startClients

import org.jboss.netty.channel.ChannelPipelineFactory; //导入依赖的package包/类
/**
 * Connect to remote servers.  We'll initiate the connection to
 * any nodes with a lower ID so that there will be a single connection
 * between each pair of nodes which we'll use symmetrically
 */
protected void startClients(ChannelPipelineFactory pipelineFactory) {
    final ClientBootstrap bootstrap =
            new ClientBootstrap(
                 new NioClientSocketChannelFactory(bossExecutor,
                                                   workerExecutor));
    bootstrap.setOption("child.reuseAddr", true);
    bootstrap.setOption("child.keepAlive", true);
    bootstrap.setOption("child.tcpNoDelay", true);
    bootstrap.setOption("child.sendBufferSize", SEND_BUFFER_SIZE);
    bootstrap.setOption("child.connectTimeoutMillis", CONNECT_TIMEOUT);
    bootstrap.setPipelineFactory(pipelineFactory);
    clientBootstrap = bootstrap;

    ScheduledExecutorService ses = 
            syncManager.getThreadPool().getScheduledExecutor();
    reconnectTask = new SingletonTask(ses, new ConnectTask());
    reconnectTask.reschedule(0, TimeUnit.SECONDS);
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:24,代码来源:RPCService.java

示例9: bootstrapNetty

import org.jboss.netty.channel.ChannelPipelineFactory; //导入依赖的package包/类
/**
 * Bootstraps netty, the server that handles all openflow connections
 */
public void bootstrapNetty() {
	try {
		final ServerBootstrap bootstrap = createServerBootStrap();

		bootstrap.setOption("reuseAddr", true);
		bootstrap.setOption("child.keepAlive", true);
		bootstrap.setOption("child.tcpNoDelay", true);
		bootstrap.setOption("child.sendBufferSize", Controller.SEND_BUFFER_SIZE);

		ChannelPipelineFactory pfact = useSsl ? new OpenflowPipelineFactory(this, floodlightProvider.getTimer(), this, debugCounterService, keyStore, keyStorePassword) :
			new OpenflowPipelineFactory(this, floodlightProvider.getTimer(), this, debugCounterService);

		bootstrap.setPipelineFactory(pfact);
		InetSocketAddress sa = new InetSocketAddress(floodlightProvider.getOFPort());
		final ChannelGroup cg = new DefaultChannelGroup();
		cg.add(bootstrap.bind(sa));

		log.info("Listening for switch connections on {}", sa);
	} catch (Exception e) {
		throw new RuntimeException(e);
	}
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:26,代码来源:OFSwitchManager.java

示例10: connect

import org.jboss.netty.channel.ChannelPipelineFactory; //导入依赖的package包/类
/**
 * Startup a ServerBootstrap with NioServerSocketChannelFactory using the
 * portNo specified in the constructor.
 * 
 * @return
 */
public ServerBootstrap connect() {

	bootstrap = new ServerBootstrap(new NioServerSocketChannelFactory(
			Executors.newCachedThreadPool(),
			Executors.newCachedThreadPool()));

	bootstrap.setPipelineFactory(new ChannelPipelineFactory() {
		@Override
		public ChannelPipeline getPipeline() throws Exception {
			return Channels.pipeline(new MessageFrameDecoder(),  new MessageEventBagHandler(bagList));
		}
	});

	System.out.println("Binding to: localhost:" + portNo);
	bootstrap.bind(new InetSocketAddress("localhost", portNo));

	return bootstrap;

}
 
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:26,代码来源:ServerUtil.java

示例11: connectServer

import org.jboss.netty.channel.ChannelPipelineFactory; //导入依赖的package包/类
private ServerBootstrap connectServer(boolean simulateConflict,
		boolean simulateConflictErrorPointer) {

	ServerBootstrap bootstrap = new ServerBootstrap(
			new NioServerSocketChannelFactory(
					Executors.newCachedThreadPool(),
					Executors.newCachedThreadPool()));

	final MessageEventBagHandler messagEventBagHandler = new MessageEventBagHandler(
			bagList, simulateConflict, simulateConflictErrorPointer);
	bootstrap.setPipelineFactory(new ChannelPipelineFactory() {
		@Override
		public ChannelPipeline getPipeline() throws Exception {
			return Channels.pipeline(new MessageFrameDecoder(),
					messagEventBagHandler);
		}
	});

	bootstrap.bind(new InetSocketAddress(testPort));

	return bootstrap;

}
 
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:24,代码来源:TestFilesSendWorker.java

示例12: connectServer

import org.jboss.netty.channel.ChannelPipelineFactory; //导入依赖的package包/类
private ServerBootstrap connectServer() {

		ServerBootstrap bootstrap = new ServerBootstrap(
				new NioServerSocketChannelFactory(
						Executors.newCachedThreadPool(),
						Executors.newCachedThreadPool()));

		bootstrap.setPipelineFactory(new ChannelPipelineFactory() {
			@Override
			public ChannelPipeline getPipeline() throws Exception {
				return Channels.pipeline(new MessageFrameDecoder(),
						new MessageEventBagHandler(bagList));
			}
		});

		bootstrap.bind(new InetSocketAddress(testPort));

		return bootstrap;

	}
 
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:21,代码来源:TestFilesSendWorkerConflict.java

示例13: connect

import org.jboss.netty.channel.ChannelPipelineFactory; //导入依赖的package包/类
@Override
public void connect() {

	workerService = createWorkerService(getThreadPoolType(CollectorProperties.WRITER.COLLECTOR_WORKER_THREAD_POOL));

	workerbossService = createWorkderBossService(getThreadPoolType(CollectorProperties.WRITER.COLLECTOR_WORKERBOSS_THREAD_POOL));
	channelFactory = new NioServerSocketChannelFactory(workerbossService,
			workerService);

	bootstrap = new ServerBootstrap(channelFactory);

	bootstrap.setPipelineFactory(new ChannelPipelineFactory() {
		@Override
		public ChannelPipeline getPipeline() throws Exception {
			return Channels.pipeline(ipFilterHandler,
					new MessageFrameDecoder(), new ReadTimeoutHandler(
							HashedWheelTimerFactory.getInstance(),
							readTimeout, TimeUnit.MILLISECONDS),
					metricsHandler, channelHandler);
		}
	});

	bootstrap.bind(new InetSocketAddress(port));

}
 
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:26,代码来源:CollectorServerImpl.java

示例14: connectLockBootstrap

import org.jboss.netty.channel.ChannelPipelineFactory; //导入依赖的package包/类
/**
 * Startup a ServerBootstrap with NioServerSocketChannelFactory using the
 * portNo specified in the constructor.
 * 
 */
private void connectLockBootstrap() {

	lockBootstrap = new ServerBootstrap(new NioServerSocketChannelFactory(
			Executors.newCachedThreadPool(),
			Executors.newCachedThreadPool()));

	lockBootstrap.setPipelineFactory(new ChannelPipelineFactory() {
		@Override
		public ChannelPipeline getPipeline() throws Exception {
			return Channels.pipeline(new MessageFrameDecoder(),
					metricHandler, lockHandler);
		}
	});

	lockBootstrap.bind(new InetSocketAddress(lockPort));

}
 
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:23,代码来源:CoordinationServerImpl.java

示例15: connectUnlockBootstrap

import org.jboss.netty.channel.ChannelPipelineFactory; //导入依赖的package包/类
/**
 * Startup a ServerBootstrap with NioServerSocketChannelFactory using the
 * portNo specified in the constructor.
 * 
 */
private void connectUnlockBootstrap() {

	unlockBootstrap = new ServerBootstrap(
			new NioServerSocketChannelFactory(
					Executors.newCachedThreadPool(),
					Executors.newCachedThreadPool()));

	unlockBootstrap.setPipelineFactory(new ChannelPipelineFactory() {
		@Override
		public ChannelPipeline getPipeline() throws Exception {
			return Channels.pipeline(new MessageFrameDecoder(),
					unlockHandler);
		}
	});

	unlockBootstrap.bind(new InetSocketAddress(releaseLockPort));

}
 
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:24,代码来源:CoordinationServerImpl.java


注:本文中的org.jboss.netty.channel.ChannelPipelineFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。