public class ParallelTaskBuilder
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private int |
concurrency
The concurrency.
|
private ParallelTaskConfig |
config
The config using default values.
|
private HttpMeta |
httpMeta
The metadata about the HTTP request.
|
private static org.slf4j.Logger |
logger
The logger.
|
TaskRunMode |
mode
The mode.
|
private PingMeta |
pingMeta
The ping meta data.
|
private java.util.Map<java.lang.String,java.lang.String> |
replacementVarMap
The replacement var map.
|
private java.util.Map<java.lang.String,StrStrMap> |
replacementVarMapNodeSpecific
The replacement var map node specific.
|
private RequestProtocol |
requestProtocol
The request protocol.
|
private RequestReplacementType |
requestReplacementType
The request replacement type.
|
private java.util.Map<java.lang.String,java.lang.Object> |
responseContext
The response context.
|
private SshMeta |
sshMeta
The ssh meta.
|
private ITargetHostsBuilder |
targetHostBuilder
The targetHostBuilder.
|
private TargetHostMeta |
targetHostMeta
The target host meta data.
|
private java.util.List<java.lang.String> |
targetHosts
The target hosts.
|
private TcpMeta |
tcpMeta
The TCP request meta data.
|
private UdpMeta |
udpMeta
The UDP request meta data.
|
Constructor and Description |
---|
ParallelTaskBuilder()
Instantiates a new parallel task builder.
|
Modifier and Type | Method and Description |
---|---|
ParallelTaskBuilder |
async()
Execute the task asynchronously.
|
ParallelTask |
execute(ParallecResponseHandler handler)
key function.
|
com.ning.http.client.AsyncHttpClient |
getAsyncHttpClient()
Gets the async http client.
|
int |
getConcurrency()
Gets the concurrency.
|
ParallelTaskConfig |
getConfig()
Gets the config.
|
HttpMeta |
getHttpMeta()
Gets the HttpMeta.
|
TaskRunMode |
getMode()
Gets the mode of either sync or async.
|
java.util.Map<java.lang.String,java.lang.String> |
getReplacementVarMap()
Gets the replacement var map.
|
java.util.Map<java.lang.String,StrStrMap> |
getReplacementVarMapNodeSpecific()
Gets the replacement var map node specific.
|
RequestProtocol |
getRequestProtocol()
Gets the request protocol.
|
RequestReplacementType |
getRequestReplacementType()
Gets the request replacement type.
|
java.util.Map<java.lang.String,java.lang.Object> |
getResponseContext()
Gets the response context.
|
ITargetHostsBuilder |
getTargetHostBuilder()
Gets the TargetHostsBuilder.
|
TargetHostMeta |
getTargetHostMeta()
Gets the target host meta.
|
java.util.List<java.lang.String> |
getTargetHosts()
Gets the target hosts.
|
TcpMeta |
getTcpMeta()
Gets the tcp meta.
|
UdpMeta |
getUdpMeta()
Gets the udp meta.
|
ParallelTaskBuilder |
handleInManager()
Call response handler in manager (in a sequence after aggregation) Default mode.
|
ParallelTaskBuilder |
handleInWorker()
Call response handler in operation worker (in parallel before aggregation).
|
ParallelTaskBuilder |
saveResponseHeaders(ResponseHeaderMeta responseHeaderMeta)
Sets the HTTP response header meta data.
|
ParallelTaskBuilder |
setAsyncHttpClient(com.ning.http.client.AsyncHttpClient asyncHttpClient)
Sets the async http client.
|
ParallelTaskBuilder |
setAutoSaveLogToLocal(boolean autoSaveLogToLocal)
Sets the auto save log to local.
|
ParallelTaskBuilder |
setConcurrency(int concurrency)
Sets the max concurrency.
|
ParallelTaskBuilder |
setConfig(ParallelTaskConfig config)
Sets the config.
|
ParallelTaskBuilder |
setEnableCapacityAwareTaskScheduler(boolean enableCapacityAwareTaskScheduler)
Sets the enable capacity aware task scheduler.
|
ParallelTaskBuilder |
setHttpEntityBody(java.lang.String body)
Sets the body.
|
ParallelTaskBuilder |
setHttpHeaders(ParallecHeader pheader)
this will create the adhoc header.
|
void |
setHttpMeta(HttpMeta httpMeta)
Sets the HttpMeta.
|
ParallelTaskBuilder |
setHttpPollable(boolean isPollable)
Sets the HTTP pollable.
|
ParallelTaskBuilder |
setHttpPollerProcessor(HttpPollerProcessor httpPollerProcessor)
Sets the HTTP poller processor to handle Async API.
|
ParallelTaskBuilder |
setHttpPort(int port)
Sets the port.
|
ParallelTaskBuilder |
setHttpPortReplaceable(java.lang.String portVar)
Sets the port variable name such as $PORT.
|
void |
setMode(TaskRunMode mode)
Sets the mode.
|
ParallelTaskBuilder |
setPingMode(PingMode mode)
Sets the ping mode.
|
ParallelTaskBuilder |
setPingNumRetries(int numRetries)
Sets the ping num retries.
|
ParallelTaskBuilder |
setPingTimeoutMillis(int pingTimeoutMillis)
Sets the ping timeout millis.
|
ParallelTaskBuilder |
setProtocol(RequestProtocol protocol)
Sets the protocol.
|
ParallelTaskBuilder |
setReplacementVarMap(java.util.Map<java.lang.String,java.lang.String> replacementVarMap)
Sets the replacement var map.
|
ParallelTaskBuilder |
setReplacementVarMapNodeSpecific(java.util.Map<java.lang.String,StrStrMap> replacementVarMapNodeSpecific)
Sets the replacement var map node specific.
|
ParallelTaskBuilder |
setReplaceVarMapToSingleTarget(java.util.List<StrStrMap> replacementVarMapList,
java.lang.String uniformTargetHost)
Sets the replace var map to single target.
|
ParallelTaskBuilder |
setReplaceVarMapToSingleTargetFromMap(java.util.Map<java.lang.String,StrStrMap> replacementVarMapNodeSpecific,
java.lang.String uniformTargetHost)
Sets the replace var map to single target from map.
|
ParallelTaskBuilder |
setReplaceVarMapToSingleTargetSingleVar(java.lang.String variable,
java.util.List<java.lang.String> replaceList,
java.lang.String uniformTargetHost)
Sets the replace var map to single target single var.
|
ParallelTaskBuilder |
setRequestReplacementType(RequestReplacementType requestReplacementType)
Sets the request replacement type.
|
ParallelTaskBuilder |
setResponseContext(java.util.Map<java.lang.String,java.lang.Object> responseContext)
Sets the response context.
|
ParallelTaskBuilder |
setRunAsSuperUser(java.lang.Boolean runAsSuperUser)
Sets the ssh runAsSuperUser.
|
ParallelTaskBuilder |
setSaveResponseToTask(boolean saveResponseToTask)
Sets the save response to task.
|
ParallelTaskBuilder |
setSshCommandLine(java.lang.String commandLine)
Sets the ssh command line.
|
ParallelTaskBuilder |
setSshConnectionTimeoutMillis(int sshConnectionTimeoutMillis)
Sets the ssh connection timeout millis.
|
ParallelTaskBuilder |
setSshLoginType(SshLoginType sshLoginType)
Sets the ssh login type.
|
ParallelTaskBuilder |
setSshPassword(java.lang.String password)
Sets the ssh password.
|
ParallelTaskBuilder |
setSshPort(int sshPort)
Sets the ssh port.
|
ParallelTaskBuilder |
setSshPrivKeyRelativePath(java.lang.String privKeyRelativePath)
Sets the ssh priv key relative path.
|
ParallelTaskBuilder |
setSshPrivKeyRelativePathWtihPassphrase(java.lang.String privKeyRelativePath,
java.lang.String passphrase)
Sets the ssh priv key relative path wtih passphrase.
|
ParallelTaskBuilder |
setSshUserName(java.lang.String userName)
Sets the ssh user name.
|
void |
setTargetHostBuilder(ITargetHostsBuilder thb)
Sets the TargetHostsBuilder.
|
void |
setTargetHostMeta(TargetHostMeta targetHostMeta)
Sets the target host meta.
|
ParallelTaskBuilder |
setTargetHostsFromCmsQueryUrl(java.lang.String cmsQueryUrl)
Sets the target hosts from cms query url.
|
ParallelTaskBuilder |
setTargetHostsFromCmsQueryUrl(java.lang.String cmsQueryUrl,
java.lang.String projection)
CMS: configuration-management-service.
|
ParallelTaskBuilder |
setTargetHostsFromJsonPath(java.lang.String jsonPath,
java.lang.String sourcePath,
HostsSourceType sourceType)
Sets the target hosts from json path.
|
ParallelTaskBuilder |
setTargetHostsFromLineByLineText(java.lang.String sourcePath,
HostsSourceType sourceType)
Sets the target hosts from line by line text.
|
ParallelTaskBuilder |
setTargetHostsFromList(java.util.List<java.lang.String> targetHosts)
Sets the target hosts from list.
|
ParallelTaskBuilder |
setTargetHostsFromString(java.lang.String targetHostsStr)
Sets the target hosts from string.
|
ParallelTaskBuilder |
setTcpChannelFactory(org.jboss.netty.channel.ChannelFactory channelFactory)
Sets the tcp channel factory.
|
ParallelTaskBuilder |
setTcpConnectTimeoutMillis(int tcpConnectTimeoutMillis)
Sets the tcp connect timeout millis.
|
ParallelTaskBuilder |
setTcpIdleTimeoutSec(int tcpIdleTimeoutSec)
Sets the tcp idle timeout sec.
|
void |
setTcpMeta(TcpMeta tcpMeta)
Sets the tcp meta.
|
ParallelTaskBuilder |
setTcpPort(int tcpPort)
Sets the tcp port.
|
ParallelTaskBuilder |
setUdpIdleTimeoutSec(int udpIdleTimeoutSec)
Sets the udp read(idle) timeout millis.
|
void |
setUdpMeta(UdpMeta udpMeta)
Sets the udp meta.
|
ParallelTaskBuilder |
setUdpPort(int udpPort)
Sets the udp port.
|
ParallelTaskBuilder |
sync()
Execute the task synchronously (the default run mode).
|
java.lang.String |
toString() |
boolean |
validation()
add some validation to see if this miss anything.
|
private static org.slf4j.Logger logger
private HttpMeta httpMeta
private SshMeta sshMeta
private TcpMeta tcpMeta
private UdpMeta udpMeta
private PingMeta pingMeta
private TargetHostMeta targetHostMeta
private final java.util.Map<java.lang.String,StrStrMap> replacementVarMapNodeSpecific
private java.util.Map<java.lang.String,java.lang.String> replacementVarMap
private RequestReplacementType requestReplacementType
private java.util.List<java.lang.String> targetHosts
private ITargetHostsBuilder targetHostBuilder
private java.util.Map<java.lang.String,java.lang.Object> responseContext
public TaskRunMode mode
private ParallelTaskConfig config
private RequestProtocol requestProtocol
private int concurrency
public ParallelTaskBuilder()
public java.util.Map<java.lang.String,java.lang.Object> getResponseContext()
public ParallelTaskBuilder setResponseContext(java.util.Map<java.lang.String,java.lang.Object> responseContext)
responseContext
- the response contextpublic ParallelTaskBuilder handleInWorker()
public ParallelTaskBuilder handleInManager()
public ParallelTaskBuilder async()
public ParallelTaskBuilder sync()
public void setMode(TaskRunMode mode)
mode
- the new modepublic ParallelTask execute(ParallecResponseHandler handler)
handler
- the handlerpublic boolean validation() throws ParallelTaskInvalidException
ParallelTaskInvalidException
- the parallel task invalid exceptionpublic ParallelTaskBuilder setProtocol(RequestProtocol protocol)
protocol
- the protocolpublic ParallelTaskBuilder setConcurrency(int concurrency)
concurrency
- the concurrencypublic ParallelTaskBuilder setHttpEntityBody(java.lang.String body)
body
- the bodypublic ParallelTaskBuilder setHttpHeaders(ParallecHeader pheader)
pheader
- the pheaderpublic ParallelTaskBuilder setHttpPort(int port)
port
- the portpublic ParallelTaskBuilder setHttpPortReplaceable(java.lang.String portVar)
portVar
- the portpublic ParallelTaskBuilder setAsyncHttpClient(com.ning.http.client.AsyncHttpClient asyncHttpClient)
asyncHttpClient
- the async http clientpublic HttpMeta getHttpMeta()
public void setHttpMeta(HttpMeta httpMeta)
httpMeta
- the new httpMetapublic com.ning.http.client.AsyncHttpClient getAsyncHttpClient()
public java.util.List<java.lang.String> getTargetHosts()
public ParallelTaskBuilder setTargetHostsFromList(java.util.List<java.lang.String> targetHosts)
targetHosts
- the target hostspublic ParallelTaskBuilder setTargetHostsFromString(java.lang.String targetHostsStr)
targetHostsStr
- the target hosts strpublic ParallelTaskBuilder setTargetHostsFromJsonPath(java.lang.String jsonPath, java.lang.String sourcePath, HostsSourceType sourceType) throws TargetHostsLoadException
jsonPath
- the json pathsourcePath
- the source pathsourceType
- the source typeTargetHostsLoadException
- the target hosts load exceptionpublic ParallelTaskBuilder setTargetHostsFromLineByLineText(java.lang.String sourcePath, HostsSourceType sourceType) throws TargetHostsLoadException
sourcePath
- the source pathsourceType
- the source typeTargetHostsLoadException
- the target hosts load exceptionpublic ParallelTaskBuilder setTargetHostsFromCmsQueryUrl(java.lang.String cmsQueryUrl) throws TargetHostsLoadException
cmsQueryUrl
- the cms query urlTargetHostsLoadException
- the target hosts load exceptionpublic ParallelTaskBuilder setTargetHostsFromCmsQueryUrl(java.lang.String cmsQueryUrl, java.lang.String projection) throws TargetHostsLoadException
cmsQueryUrl
- the cms query urlprojection
- the projectionTargetHostsLoadException
- the target hosts load exceptionpublic ITargetHostsBuilder getTargetHostBuilder()
public void setTargetHostBuilder(ITargetHostsBuilder thb)
thb
- the new thbpublic TaskRunMode getMode()
public TargetHostMeta getTargetHostMeta()
public void setTargetHostMeta(TargetHostMeta targetHostMeta)
targetHostMeta
- the new target host metapublic java.util.Map<java.lang.String,StrStrMap> getReplacementVarMapNodeSpecific()
public ParallelTaskBuilder setReplacementVarMapNodeSpecific(java.util.Map<java.lang.String,StrStrMap> replacementVarMapNodeSpecific)
replacementVarMapNodeSpecific
- the replacement var map node specificpublic ParallelTaskBuilder setReplaceVarMapToSingleTargetFromMap(java.util.Map<java.lang.String,StrStrMap> replacementVarMapNodeSpecific, java.lang.String uniformTargetHost)
replacementVarMapNodeSpecific
- the replacement var map node specificuniformTargetHost
- the uniform target hostpublic ParallelTaskBuilder setReplaceVarMapToSingleTargetSingleVar(java.lang.String variable, java.util.List<java.lang.String> replaceList, java.lang.String uniformTargetHost)
variable
- the variablereplaceList
- : the list of strings that will replace the variableuniformTargetHost
- the uniform target hostpublic ParallelTaskBuilder setReplaceVarMapToSingleTarget(java.util.List<StrStrMap> replacementVarMapList, java.lang.String uniformTargetHost)
replacementVarMapList
- the replacement var map listuniformTargetHost
- the uniform target hostpublic java.util.Map<java.lang.String,java.lang.String> getReplacementVarMap()
public ParallelTaskBuilder setReplacementVarMap(java.util.Map<java.lang.String,java.lang.String> replacementVarMap)
replacementVarMap
- the replacement var mappublic RequestReplacementType getRequestReplacementType()
public ParallelTaskBuilder setRequestReplacementType(RequestReplacementType requestReplacementType)
requestReplacementType
- the new request replacement typepublic ParallelTaskBuilder setHttpPollable(boolean isPollable)
isPollable
- the is pollablepublic ParallelTaskBuilder saveResponseHeaders(ResponseHeaderMeta responseHeaderMeta)
responseHeaderMeta
- the response header metapublic ParallelTaskBuilder setHttpPollerProcessor(HttpPollerProcessor httpPollerProcessor)
httpPollerProcessor
- the http poller processorpublic java.lang.String toString()
toString
in class java.lang.Object
public ParallelTaskBuilder setSshCommandLine(java.lang.String commandLine)
commandLine
- the command linepublic ParallelTaskBuilder setRunAsSuperUser(java.lang.Boolean runAsSuperUser)
runAsSuperUser
- the runAsSuperUserpublic ParallelTaskBuilder setSshPort(int sshPort)
sshPort
- the ssh portpublic ParallelTaskBuilder setSshUserName(java.lang.String userName)
userName
- the user namepublic ParallelTaskBuilder setSshPassword(java.lang.String password)
password
- the passwordpublic ParallelTaskBuilder setSshLoginType(SshLoginType sshLoginType)
sshLoginType
- the ssh login typepublic ParallelTaskBuilder setSshPrivKeyRelativePath(java.lang.String privKeyRelativePath)
privKeyRelativePath
- the priv key relative pathpublic ParallelTaskBuilder setSshPrivKeyRelativePathWtihPassphrase(java.lang.String privKeyRelativePath, java.lang.String passphrase)
privKeyRelativePath
- the priv key relative pathpassphrase
- the passphrasepublic ParallelTaskBuilder setSshConnectionTimeoutMillis(int sshConnectionTimeoutMillis)
sshConnectionTimeoutMillis
- the ssh connection timeout millispublic ParallelTaskBuilder setTcpPort(int tcpPort)
tcpPort
- the tcp portpublic ParallelTaskBuilder setTcpConnectTimeoutMillis(int tcpConnectTimeoutMillis)
tcpConnectTimeoutMillis
- the tcp connect timeout millispublic ParallelTaskBuilder setTcpIdleTimeoutSec(int tcpIdleTimeoutSec)
tcpIdleTimeoutSec
- the tcp idle timeout secpublic ParallelTaskBuilder setTcpChannelFactory(org.jboss.netty.channel.ChannelFactory channelFactory)
channelFactory
- the channel factorypublic ParallelTaskBuilder setUdpPort(int udpPort)
udpPort
- the udp portpublic ParallelTaskBuilder setUdpIdleTimeoutSec(int udpIdleTimeoutSec)
udpIdleTimeoutSec
- the udp read timeout millispublic ParallelTaskBuilder setConfig(ParallelTaskConfig config)
config
- the configpublic ParallelTaskConfig getConfig()
public ParallelTaskBuilder setSaveResponseToTask(boolean saveResponseToTask)
saveResponseToTask
- the save response to taskpublic ParallelTaskBuilder setEnableCapacityAwareTaskScheduler(boolean enableCapacityAwareTaskScheduler)
enableCapacityAwareTaskScheduler
- the enable capacity aware task schedulerpublic ParallelTaskBuilder setAutoSaveLogToLocal(boolean autoSaveLogToLocal)
autoSaveLogToLocal
- the auto save log to localpublic TcpMeta getTcpMeta()
public void setTcpMeta(TcpMeta tcpMeta)
tcpMeta
- the new tcp metapublic RequestProtocol getRequestProtocol()
public int getConcurrency()
public ParallelTaskBuilder setPingMode(PingMode mode)
mode
- the modepublic ParallelTaskBuilder setPingTimeoutMillis(int pingTimeoutMillis)
pingTimeoutMillis
- the ping timeout millispublic ParallelTaskBuilder setPingNumRetries(int numRetries)
numRetries
- the num retriespublic UdpMeta getUdpMeta()
public void setUdpMeta(UdpMeta udpMeta)
udpMeta
- the new udp meta