當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。