public class Scheduler
extends java.lang.Thread
The listener/s are the thread/s where the client request are received, and workers are a thread pool that process the requests and send the response to the client.
Usage example:
construct
setParameters
run
Modifier and Type | Field and Description |
---|---|
private java.lang.String |
cachePath
Is the path directory that will be used to save the temporary files
used to cache client data.
|
private ServerClientSessions |
clientSessions
It is a list that contains information about the clients that are being
served.
|
private int |
deliveringMode
Further information, see
ServerParser.serverArguments . |
private int |
deliveringSubtype
Indicates a subtype of the
deliveringMode attribute. |
private boolean |
finish
Indicates when the scheduler has to finish
|
private boolean |
independentMessageHeaders
Definition in
CADI.Server.Network.JPIPMessageEncoder#independentForm . |
private int |
keepAliveTimeout
It is the timeout (in milliseconds) that will be used to wait for a new
client request when the HTTP keep-alive mode is set.
|
private CADILog |
log
It is an object that will be used to log the server process
|
private boolean |
logEnabled
Indicates whether the log is enabled or disabled.
|
private java.lang.String |
logFile
It is the file name where the server logs are stored.
|
private ServerLogicalTargetList |
logicalTargetList
It is a list that contais information about the logical targets
(typically an image) that are being served.
|
private long |
maxTxRate
Is the maximum rate (bytes per second) which will be used to delivery
data from the server to the client. 0 value means unlimited.
|
private int |
numOfWorkers
Indicates the number of threads of the
Worker that will
be running. |
private int[] |
ports
Ports where the server is listening to the client requests.
|
private boolean |
predictiveModel
This attribute indicates whether a predictive model is being used to
deliver the image data.
|
private RequestListener[] |
requestListenersPool
This thread pool will listen to in a port to receive client requests.
|
private RequestQueue |
requestQueue
It is a queue where the client request are stored.
|
private java.lang.String |
targetsPath
Is the path directory where the logical targets are stored.
|
private TasksQueue[] |
tasksQueue
Is an array of queues to storage the tasks for each
Worker thread. |
private int |
trafficShaping |
private Worker[] |
workersPool
This thread pool will process the client requests and will send the
server responses to the client.
|
private boolean |
XMLLogFormat
Indicates whether the log information is stored in XML format or simple
text format.
|
Constructor and Description |
---|
Scheduler(int[] ports,
int numOfWorkers,
boolean logEnabled,
int logLevel,
java.lang.String logFile,
boolean XMLLogFormat)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
finish()
This method is used to indicate that the thread has to finish.
|
private void |
launchListeners() |
private void |
launchWorkers() |
void |
list(java.io.PrintStream out)
Prints this Scheduler's fields to the specified output stream.
|
void |
run()
This method manages the
RequestListener pool and the
Worker pool. |
void |
setCachePath(java.lang.String cachePath)
Sets the
cachePath attribute. |
void |
setDeliveringMode(int deliveringMode,
int deliveringSubtype)
Sets the mode used to deliver precinct data to the client.
|
void |
setIndependentMessageHeaders(boolean independentMessageHeaders)
Sets the
#independentMesssageHeaders attribute. |
void |
setKeepAliveTimeout(int keepAliveTimeout)
Sets the
keepAliveTimeout attribute. |
void |
setMaxTxRate(long maxTxRate)
Sets the
maxTxRate attribute. |
void |
setPredictiveModel(boolean predictiveModel)
Sets the
predictiveModel attribute. |
void |
setTargetsPath(java.lang.String targetsPath)
Sets the
targetsPath attribute. |
void |
setTrafficShaping(int trafficShaping)
Sets the
trafficShaping attribute. |
java.lang.String |
toString() |
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, yield
private int[] ports
private int numOfWorkers
Worker
that will
be running.private java.lang.String logFile
private boolean XMLLogFormat
private boolean logEnabled
private int keepAliveTimeout
private long maxTxRate
Only positive values are allowed.
private int trafficShaping
private boolean independentMessageHeaders
CADI.Server.Network.JPIPMessageEncoder#independentForm
.private boolean predictiveModel
private java.lang.String targetsPath
private java.lang.String cachePath
private int deliveringMode
ServerParser.serverArguments
.private int deliveringSubtype
deliveringMode
attribute. Thus, its
value will depend on the value taken by deliveringMode
.
Further information, see ServerParser.serverArguments
.
#rateDistortionMethod
value.
private RequestListener[] requestListenersPool
private Worker[] workersPool
private RequestQueue requestQueue
private ServerLogicalTargetList logicalTargetList
private ServerClientSessions clientSessions
private TasksQueue[] tasksQueue
Worker
thread. Therefore, each queue of the array
belongs to a Workder
.private CADILog log
private boolean finish
public Scheduler(int[] ports, int numOfWorkers, boolean logEnabled, int logLevel, java.lang.String logFile, boolean XMLLogFormat)
ports
- they are the ports where the server will listen to the
client request.numOfWorkers
- they are the number of workers that will be launched to
process the client request.logEnabled
- definition in logEnabled
logLevel
- definition in CADILog.logLevel
logFile
- definition in logFile
.XMLLogFormat
- definition in XMLLogFormat
.ErrorException
- when the server can not be launched because the
server socket can not be opened it will be thrown.public void setTargetsPath(java.lang.String targetsPath)
targetsPath
attribute.targetsPath
- definition in targetsPath
.public void setCachePath(java.lang.String cachePath)
cachePath
attribute.cachePath
- definition in cachePath
.public void setDeliveringMode(int deliveringMode, int deliveringSubtype)
deliveringMode
- definition in deliveringMode
.deliveringSubtype
- definition in deliveringSubtype
.public void setKeepAliveTimeout(int keepAliveTimeout)
keepAliveTimeout
attribute.keepAliveTimeout
- definition in keepAliveTimeout
.public void setMaxTxRate(long maxTxRate)
maxTxRate
attribute.maxTxRate
- definition in maxTxRate
attribute.public void setTrafficShaping(int trafficShaping)
trafficShaping
attribute.maxTxRate
- definition in trafficShaping
attribute.public void setIndependentMessageHeaders(boolean independentMessageHeaders)
#independentMesssageHeaders
attribute.independentMesssageHeaders
- definition in #independentMesssageHeaders
attribute.public void setPredictiveModel(boolean predictiveModel)
predictiveModel
attribute.predictiveModel
- definition in predictiveModel
.public void run()
RequestListener
pool and the
Worker
pool. It gets the client request (received by the
RequestListener
) and assigns the tasks to the Worker
.
The method will be running until the finish
attibute is set
to false
.
run
in interface java.lang.Runnable
run
in class java.lang.Thread
public void finish()
public java.lang.String toString()
toString
in class java.lang.Thread
public void list(java.io.PrintStream out)
out
- an output stream.private void launchListeners() throws ErrorException
ErrorException
private void launchWorkers()
CADI - Copyright (C) 2007
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
Group on Interactive Coding of Images (GICI) (contact)