com.continuuity.http
Class NettyHttpService.Builder

java.lang.Object
  extended by com.continuuity.http.NettyHttpService.Builder
Enclosing class:
NettyHttpService

public static class NettyHttpService.Builder
extends Object

Builder to help create the NettyHttpService.


Method Summary
 NettyHttpService.Builder addHttpHandlers(Iterable<? extends HttpHandler> handlers)
          Add HttpHandlers that service the request.
 NettyHttpService build()
           
 NettyHttpService.Builder enableSSL(File keyStore, String keyStorePassword, String certificatePassword)
          Enable SSL by using the provided SSL information
 NettyHttpService.Builder modifyChannelPipeline(com.google.common.base.Function<org.jboss.netty.channel.ChannelPipeline,org.jboss.netty.channel.ChannelPipeline> function)
          Modify the pipeline upon build by applying the function.
 NettyHttpService.Builder setBossThreadPoolSize(int bossThreadPoolSize)
          Set size of bossThreadPool in netty default value is 1 if it is not set.
 NettyHttpService.Builder setChannelConfig(String key, Object value)
          Sets channel configuration for the the netty service.
 NettyHttpService.Builder setConnectionBacklog(int connectionBacklog)
          Set size of backlog in netty service - size of accept queue of the TCP stack.
 NettyHttpService.Builder setExecThreadKeepAliveSeconds(long threadKeepAliveSecs)
          Set threadKeepAliveSeconds - maximum time that excess idle threads will wait for new tasks before terminating.
 NettyHttpService.Builder setExecThreadPoolSize(int execThreadPoolSize)
          Set size of executorThreadPool in netty default value is 60 if it is not set.
 NettyHttpService.Builder setHandlerHooks(Iterable<? extends HandlerHook> handlerHooks)
          Set HandlerHooks to be executed pre and post handler calls.
 NettyHttpService.Builder setHost(String host)
          Set the bindAddress for the service.
 NettyHttpService.Builder setHttpChunkLimit(int value)
           
 NettyHttpService.Builder setPort(int port)
          Set the port on which the service should listen to.
 NettyHttpService.Builder setRejectedExecutionHandler(RejectedExecutionHandler rejectedExecutionHandler)
          Set RejectedExecutionHandler - rejection policy for executor.
 NettyHttpService.Builder setUrlRewriter(URLRewriter urlRewriter)
          Set URLRewriter to re-write URL of an incoming request before any handlers or their hooks are called.
 NettyHttpService.Builder setWorkerThreadPoolSize(int workerThreadPoolSize)
          Set size of workerThreadPool in netty default value is 10 if it is not set.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

modifyChannelPipeline

public NettyHttpService.Builder modifyChannelPipeline(com.google.common.base.Function<org.jboss.netty.channel.ChannelPipeline,org.jboss.netty.channel.ChannelPipeline> function)
Modify the pipeline upon build by applying the function.

Parameters:
function - Function that modifies and returns a pipeline.
Returns:
builder

addHttpHandlers

public NettyHttpService.Builder addHttpHandlers(Iterable<? extends HttpHandler> handlers)
Add HttpHandlers that service the request.

Parameters:
handlers - Iterable of HttpHandlers.
Returns:
instance of Builder.

setHandlerHooks

public NettyHttpService.Builder setHandlerHooks(Iterable<? extends HandlerHook> handlerHooks)
Set HandlerHooks to be executed pre and post handler calls. They are executed in the same order as specified by the iterable.

Parameters:
handlerHooks - Iterable of HandlerHooks.
Returns:
an instance of Builder.

setUrlRewriter

public NettyHttpService.Builder setUrlRewriter(URLRewriter urlRewriter)
Set URLRewriter to re-write URL of an incoming request before any handlers or their hooks are called.

Parameters:
urlRewriter - instance of URLRewriter.
Returns:
an instance of Builder.

setBossThreadPoolSize

public NettyHttpService.Builder setBossThreadPoolSize(int bossThreadPoolSize)
Set size of bossThreadPool in netty default value is 1 if it is not set.

Parameters:
bossThreadPoolSize - size of bossThreadPool.
Returns:
an instance of Builder.

setWorkerThreadPoolSize

public NettyHttpService.Builder setWorkerThreadPoolSize(int workerThreadPoolSize)
Set size of workerThreadPool in netty default value is 10 if it is not set.

Parameters:
workerThreadPoolSize - size of workerThreadPool.
Returns:
an instance of Builder.

setConnectionBacklog

public NettyHttpService.Builder setConnectionBacklog(int connectionBacklog)
Set size of backlog in netty service - size of accept queue of the TCP stack.

Parameters:
connectionBacklog - backlog in netty server. Default value is 1000.
Returns:
an instance of Builder.

setChannelConfig

public NettyHttpService.Builder setChannelConfig(String key,
                                                 Object value)
Sets channel configuration for the the netty service.

Parameters:
key - Name of the configuration.
value - Value of the configuration.
Returns:
an instance of Builder.
See Also:
ChannelConfig, ServerSocketChannelConfig

setExecThreadPoolSize

public NettyHttpService.Builder setExecThreadPoolSize(int execThreadPoolSize)
Set size of executorThreadPool in netty default value is 60 if it is not set. If the size is 0, then no executor will be used, hence calls to HttpHandler would be made from worker threads directly.

Parameters:
execThreadPoolSize - size of workerThreadPool.
Returns:
an instance of Builder.

setExecThreadKeepAliveSeconds

public NettyHttpService.Builder setExecThreadKeepAliveSeconds(long threadKeepAliveSecs)
Set threadKeepAliveSeconds - maximum time that excess idle threads will wait for new tasks before terminating. Default value is 60 seconds.

Parameters:
threadKeepAliveSecs - thread keep alive seconds.
Returns:
an instance of Builder.

setRejectedExecutionHandler

public NettyHttpService.Builder setRejectedExecutionHandler(RejectedExecutionHandler rejectedExecutionHandler)
Set RejectedExecutionHandler - rejection policy for executor.

Parameters:
rejectedExecutionHandler - rejectionExecutionHandler.
Returns:
an instance of Builder.

setPort

public NettyHttpService.Builder setPort(int port)
Set the port on which the service should listen to. By default the service will run on a random port.

Parameters:
port - port on which the service should listen to.
Returns:
instance of Builder.

setHost

public NettyHttpService.Builder setHost(String host)
Set the bindAddress for the service. Default value is localhost.

Parameters:
host - bindAddress for the service.
Returns:
instance of Builder.

setHttpChunkLimit

public NettyHttpService.Builder setHttpChunkLimit(int value)

enableSSL

public NettyHttpService.Builder enableSSL(File keyStore,
                                          String keyStorePassword,
                                          String certificatePassword)
Enable SSL by using the provided SSL information


build

public NettyHttpService build()
Returns:
instance of NettyHttpService


Copyright 2013 Continuuity, Inc. Licensed under the Apache License, Version 2.0